blob: f24c8d4a1f833d1ea76a42396eeaecec9bab407f [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
Romain Guy79537452011-10-12 13:48:51 -070020#include <cutils/compiler.h>
21
Romain Guy6c319ca2011-01-11 14:29:25 -080022#include "OpenGLRenderer.h"
Romain Guyada830f2011-01-13 12:13:20 -080023#include "Layer.h"
Romain Guy6c319ca2011-01-11 14:29:25 -080024
Romain Guy77a81162011-06-14 16:45:55 -070025#include <SkBitmap.h>
26
Romain Guy6c319ca2011-01-11 14:29:25 -080027namespace android {
28namespace uirenderer {
29
30///////////////////////////////////////////////////////////////////////////////
Romain Guy1fc883b2011-01-12 14:30:59 -080031// Defines
32///////////////////////////////////////////////////////////////////////////////
33
34// Debug
35#if DEBUG_LAYER_RENDERER
Steve Block5baa3a62011-12-20 16:23:08 +000036 #define LAYER_RENDERER_LOGD(...) ALOGD(__VA_ARGS__)
Romain Guy1fc883b2011-01-12 14:30:59 -080037#else
38 #define LAYER_RENDERER_LOGD(...)
39#endif
40
41///////////////////////////////////////////////////////////////////////////////
Romain Guy6c319ca2011-01-11 14:29:25 -080042// Renderer
43///////////////////////////////////////////////////////////////////////////////
44
45class LayerRenderer: public OpenGLRenderer {
46public:
Romain Guy79537452011-10-12 13:48:51 -070047 ANDROID_API LayerRenderer(Layer* layer);
48 virtual ~LayerRenderer();
Romain Guy6c319ca2011-01-11 14:29:25 -080049
Romain Guy35643dd2012-09-18 15:40:58 -070050 virtual void setViewport(int width, int height);
Romain Guy7c25aab2012-10-18 15:05:02 -070051 virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
52 virtual status_t clear(float left, float top, float right, float bottom, bool opaque);
Romain Guy79537452011-10-12 13:48:51 -070053 virtual void finish();
Romain Guy6c319ca2011-01-11 14:29:25 -080054
Romain Guy79537452011-10-12 13:48:51 -070055 ANDROID_API static Layer* createTextureLayer(bool isOpaque);
56 ANDROID_API static Layer* createLayer(uint32_t width, uint32_t height, bool isOpaque = false);
57 ANDROID_API static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height);
58 ANDROID_API static void updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
Romain Guya9489272011-06-22 20:58:11 -070059 bool isOpaque, GLenum renderTarget, float* transform);
Romain Guy79537452011-10-12 13:48:51 -070060 ANDROID_API static void destroyLayer(Layer* layer);
61 ANDROID_API static void destroyLayerDeferred(Layer* layer);
62 ANDROID_API static bool copyLayer(Layer* layer, SkBitmap* bitmap);
Romain Guy6c319ca2011-01-11 14:29:25 -080063
Chet Haase98d3a642012-09-26 10:27:40 -070064 static void flushLayer(Layer* layer);
65
Romain Guy11cb6422012-09-21 00:39:43 -070066protected:
Romain Guy8ce00302013-01-15 18:51:42 -080067 virtual void ensureStencilBuffer();
Romain Guy624234f2013-03-05 16:43:31 -080068 virtual bool hasLayer() const;
69 virtual Region* getRegion() const;
Chris Craik14e51302013-12-30 15:32:54 -080070 virtual GLuint getTargetFbo() const;
Romain Guy624234f2013-03-05 16:43:31 -080071 virtual bool suppressErrorChecks() const;
Romain Guy11cb6422012-09-21 00:39:43 -070072
Romain Guy6c319ca2011-01-11 14:29:25 -080073private:
Romain Guyf219da52011-01-16 12:54:25 -080074 void generateMesh();
75
Romain Guyada830f2011-01-13 12:13:20 -080076 Layer* mLayer;
Romain Guy6c319ca2011-01-11 14:29:25 -080077}; // class LayerRenderer
78
79}; // namespace uirenderer
80}; // namespace android
81
82#endif // ANDROID_HWUI_LAYER_RENDERER_H