2 * Copyright (C) 2017 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.
24 namespace uirenderer {
26 // Forward declarations
30 * A layer has dimensions and is backed by an OpenGL texture or FBO.
32 class GlLayer : public Layer {
34 GlLayer(RenderState& renderState, uint32_t layerWidth, uint32_t layerHeight,
35 SkColorFilter* colorFilter, int alpha, SkBlendMode mode, bool blend);
38 uint32_t getWidth() const override {
39 return texture.mWidth;
42 uint32_t getHeight() const override {
43 return texture.mHeight;
46 void setSize(uint32_t width, uint32_t height) override {
47 texture.updateLayout(width, height, texture.internalFormat(), texture.format(),
51 void setBlend(bool blend) override {
52 texture.blend = blend;
55 bool isBlend() const override {
59 inline GLuint getTextureId() const {
63 inline Texture& getTexture() {
67 inline GLenum getRenderTarget() const {
68 return texture.target();
71 inline bool isRenderable() const {
72 return texture.target() != GL_NONE;
75 void setRenderTarget(GLenum renderTarget);
77 void generateTexture();
80 * Lost the GL context but the layer is still around, mark it invalid internally
81 * so the dtor knows not to do any GL work
83 void onGlContextLost();
89 * The texture backing this layer.
94 }; // namespace uirenderer
95 }; // namespace android