Chet Haase | d15ebf2 | 2012-09-05 11:40:29 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 25 | namespace android { |
| 26 | namespace uirenderer { |
| 27 | |
Chet Haase | 603f6de | 2012-09-14 15:31:25 -0700 | [diff] [blame^] | 28 | Layer::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 Haase | d15ebf2 | 2012-09-05 11:40:29 -0700 | [diff] [blame] | 45 | Layer::~Layer() { |
| 46 | if (mesh) delete mesh; |
| 47 | if (meshIndices) delete meshIndices; |
| 48 | if (colorFilter) Caches::getInstance().resourceCache.decrementRefcount(colorFilter); |
Chet Haase | 603f6de | 2012-09-14 15:31:25 -0700 | [diff] [blame^] | 49 | if (fbo) Caches::getInstance().fboCache.put(fbo); |
| 50 | deleteTexture(); |
Chet Haase | d15ebf2 | 2012-09-05 11:40:29 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void Layer::setPaint(SkPaint* paint) { |
| 54 | OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode); |
| 55 | } |
| 56 | |
| 57 | void 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 |