LayerRenderer.h revision aa6c24c21c727a196451332448d4e3b11a80be69
1/*
2 * Copyright (C) 2011 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#ifndef ANDROID_HWUI_LAYER_RENDERER_H
18#define ANDROID_HWUI_LAYER_RENDERER_H
19
20#include "OpenGLRenderer.h"
21#include "Layer.h"
22
23namespace android {
24namespace uirenderer {
25
26///////////////////////////////////////////////////////////////////////////////
27// Defines
28///////////////////////////////////////////////////////////////////////////////
29
30// Debug
31#if DEBUG_LAYER_RENDERER
32    #define LAYER_RENDERER_LOGD(...) LOGD(__VA_ARGS__)
33#else
34    #define LAYER_RENDERER_LOGD(...)
35#endif
36
37///////////////////////////////////////////////////////////////////////////////
38// Renderer
39///////////////////////////////////////////////////////////////////////////////
40
41class LayerRenderer: public OpenGLRenderer {
42public:
43    LayerRenderer(Layer* layer): mLayer(layer) {
44    }
45
46    ~LayerRenderer() {
47    }
48
49    void prepareDirty(float left, float top, float right, float bottom, bool opaque);
50    void finish();
51
52    bool hasLayer();
53    Region* getRegion();
54    GLint getTargetFbo();
55
56    static Layer* createTextureLayer();
57    static Layer* createLayer(uint32_t width, uint32_t height, bool isOpaque = false);
58    static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height);
59    static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
60            float* transform);
61    static void destroyLayer(Layer* layer);
62    static void destroyLayerDeferred(Layer* layer);
63
64private:
65    void generateMesh();
66
67    Layer* mLayer;
68}; // class LayerRenderer
69
70}; // namespace uirenderer
71}; // namespace android
72
73#endif // ANDROID_HWUI_LAYER_RENDERER_H
74