blob: 224657397dd16c69d67eaca5fcf83620d6bce6a5 [file] [log] [blame]
Romain Guy6c319ca2011-01-11 14:29:25 -08001/*
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"
Romain Guyada830f2011-01-13 12:13:20 -080021#include "Layer.h"
Romain Guy6c319ca2011-01-11 14:29:25 -080022
Romain Guy77a81162011-06-14 16:45:55 -070023#include <SkBitmap.h>
24
Romain Guy6c319ca2011-01-11 14:29:25 -080025namespace android {
26namespace uirenderer {
27
28///////////////////////////////////////////////////////////////////////////////
Romain Guy1fc883b2011-01-12 14:30:59 -080029// Defines
30///////////////////////////////////////////////////////////////////////////////
31
32// Debug
33#if DEBUG_LAYER_RENDERER
34 #define LAYER_RENDERER_LOGD(...) LOGD(__VA_ARGS__)
35#else
36 #define LAYER_RENDERER_LOGD(...)
37#endif
38
39///////////////////////////////////////////////////////////////////////////////
Romain Guy6c319ca2011-01-11 14:29:25 -080040// Renderer
41///////////////////////////////////////////////////////////////////////////////
42
43class LayerRenderer: public OpenGLRenderer {
44public:
Romain Guyada830f2011-01-13 12:13:20 -080045 LayerRenderer(Layer* layer): mLayer(layer) {
Romain Guy6c319ca2011-01-11 14:29:25 -080046 }
47
48 ~LayerRenderer() {
49 }
50
Romain Guy7d7b5492011-01-24 16:33:45 -080051 void prepareDirty(float left, float top, float right, float bottom, bool opaque);
Romain Guy6c319ca2011-01-11 14:29:25 -080052 void finish();
53
Romain Guyf219da52011-01-16 12:54:25 -080054 bool hasLayer();
55 Region* getRegion();
Romain Guy42f3a4b2011-01-19 13:42:26 -080056 GLint getTargetFbo();
Romain Guyf219da52011-01-16 12:54:25 -080057
Romain Guya9489272011-06-22 20:58:11 -070058 static Layer* createTextureLayer(bool isOpaque);
Romain Guyada830f2011-01-13 12:13:20 -080059 static Layer* createLayer(uint32_t width, uint32_t height, bool isOpaque = false);
60 static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height);
Romain Guyaa6c24c2011-04-28 18:40:04 -070061 static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
Romain Guya9489272011-06-22 20:58:11 -070062 bool isOpaque, GLenum renderTarget, float* transform);
Romain Guyada830f2011-01-13 12:13:20 -080063 static void destroyLayer(Layer* layer);
64 static void destroyLayerDeferred(Layer* layer);
Romain Guy77a81162011-06-14 16:45:55 -070065 static bool copyLayer(Layer* layer, SkBitmap* bitmap);
Romain Guy6c319ca2011-01-11 14:29:25 -080066
67private:
Romain Guyf219da52011-01-16 12:54:25 -080068 void generateMesh();
69
Romain Guyada830f2011-01-13 12:13:20 -080070 Layer* mLayer;
Romain Guy6c319ca2011-01-11 14:29:25 -080071}; // class LayerRenderer
72
73}; // namespace uirenderer
74}; // namespace android
75
76#endif // ANDROID_HWUI_LAYER_RENDERER_H