2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #define LOG_TAG "OpenGLRenderer"
19 #include <utils/Log.h>
22 #include "OpenGLRenderer.h"
26 namespace uirenderer {
28 Layer::Layer(const uint32_t layerWidth, const uint32_t layerHeight) {
34 renderTarget = GL_TEXTURE_2D;
35 texture.width = layerWidth;
36 texture.height = layerHeight;
38 deferredUpdateScheduled = false;
42 Caches::getInstance().resourceCache.incrementRefcount(this);
46 if (mesh) delete mesh;
47 if (meshIndices) delete meshIndices;
48 if (colorFilter) Caches::getInstance().resourceCache.decrementRefcount(colorFilter);
49 if (fbo) Caches::getInstance().fboCache.put(fbo);
53 void Layer::freeResourcesLocked() {
55 Caches::getInstance().resourceCache.decrementRefcountLocked(colorFilter);
60 void Layer::setPaint(SkPaint* paint) {
61 OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
64 void Layer::setColorFilter(SkiaColorFilter* filter) {
66 Caches::getInstance().resourceCache.decrementRefcount(colorFilter);
70 Caches::getInstance().resourceCache.incrementRefcount(colorFilter);
76 }; // namespace uirenderer
77 }; // namespace android