blob: 76b274b00443724f53847f8f4c972df77a5e8b4b [file] [log] [blame]
Chet Haased15ebf22012-09-05 11:40:29 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "OpenGLRenderer"
18
19#include <utils/Log.h>
20
21#include "Layer.h"
22#include "OpenGLRenderer.h"
23#include "Caches.h"
24
25namespace android {
26namespace uirenderer {
27
Chet Haase603f6de2012-09-14 15:31:25 -070028Layer::Layer(const uint32_t layerWidth, const uint32_t layerHeight) {
29 mesh = NULL;
30 meshIndices = NULL;
31 meshElementCount = 0;
32 cacheable = true;
33 textureLayer = false;
34 renderTarget = GL_TEXTURE_2D;
35 texture.width = layerWidth;
36 texture.height = layerHeight;
37 colorFilter = NULL;
38 deferredUpdateScheduled = false;
39 renderer = NULL;
40 displayList = NULL;
41 fbo = 0;
42 Caches::getInstance().resourceCache.incrementRefcount(this);
43}
44
Chet Haased15ebf22012-09-05 11:40:29 -070045Layer::~Layer() {
46 if (mesh) delete mesh;
47 if (meshIndices) delete meshIndices;
48 if (colorFilter) Caches::getInstance().resourceCache.decrementRefcount(colorFilter);
Chet Haase603f6de2012-09-14 15:31:25 -070049 if (fbo) Caches::getInstance().fboCache.put(fbo);
50 deleteTexture();
Chet Haased15ebf22012-09-05 11:40:29 -070051}
52
53void Layer::setPaint(SkPaint* paint) {
54 OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
55}
56
57void Layer::setColorFilter(SkiaColorFilter* filter) {
58 if (colorFilter) {
59 Caches::getInstance().resourceCache.decrementRefcount(colorFilter);
60 }
61 colorFilter = filter;
62 if (colorFilter) {
63 Caches::getInstance().resourceCache.incrementRefcount(colorFilter);
64 }
65}
66
67
68
69}; // namespace uirenderer
70}; // namespace android