OpenGLRenderer.h revision 78dd96d5af20f489f0e8b288617d57774ec284f7
1e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy/*
2e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Copyright (C) 2010 The Android Open Source Project
3e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy *
4e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Licensed under the Apache License, Version 2.0 (the "License");
5e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * you may not use this file except in compliance with the License.
6e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * You may obtain a copy of the License at
7e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy *
8e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy *      http://www.apache.org/licenses/LICENSE-2.0
9e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy *
10e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Unless required by applicable law or agreed to in writing, software
11e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * distributed under the License is distributed on an "AS IS" BASIS,
12e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * See the License for the specific language governing permissions and
14e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * limitations under the License.
15e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy */
16e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#ifndef ANDROID_HWUI_OPENGL_RENDERER_H
185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#define ANDROID_HWUI_OPENGL_RENDERER_H
199d5316e3f56d138504565ff311145ac01621dff4Romain Guy
209d5316e3f56d138504565ff311145ac01621dff4Romain Guy#include <GLES2/gl2.h>
219d5316e3f56d138504565ff311145ac01621dff4Romain Guy#include <GLES2/gl2ext.h>
2285bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy
23ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include <SkBitmap.h>
24f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy#include <SkMatrix.h>
25ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include <SkPaint.h>
26079ba2c85b15e882629b8d188f5fbdb42f7f8eeaRomain Guy#include <SkRegion.h>
27d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy#include <SkShader.h>
2885bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy#include <SkXfermode.h>
29e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
30daf98e941e140e8739458126640183b9f296a2abChet Haase#include <utils/Functor.h>
31bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy#include <utils/RefBase.h>
32ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy#include <utils/SortedVector.h>
338694230ff25fa0a60e480d424843e56b718f0516Romain Guy#include <utils/Vector.h>
34bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
357953745dd565167113f8cbfc461bc0521d32d870Romain Guy#include <cutils/compiler.h>
367953745dd565167113f8cbfc461bc0521d32d870Romain Guy
373b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy#include <androidfw/ResourceTypes.h>
383b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy
39c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy#include "Debug.h"
4051769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#include "Extensions.h"
41f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy#include "Matrix.h"
425cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Program.h"
43bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy#include "Rect.h"
445cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Snapshot.h"
45f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy#include "Vertex.h"
4606f96e2652e4855b6520ad9dd70583677605b79aRomain Guy#include "SkiaShader.h"
47db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy#include "SkiaColorFilter.h"
483b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy#include "UvMapper.h"
49fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy#include "Caches.h"
50bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
51e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guynamespace android {
529d5316e3f56d138504565ff311145ac01621dff4Romain Guynamespace uirenderer {
53e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
54c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craikstruct DrawModifiers {
55c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    SkiaShader* mShader;
56c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    SkiaColorFilter* mColorFilter;
5716ecda5317c40fc3da284952d9b3add34d6763aeChris Craik    float mOverrideLayerAlpha;
58c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik
59c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    // Drop shadow
60c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    bool mHasShadow;
61c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    float mShadowRadius;
62c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    float mShadowDx;
63c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    float mShadowDy;
64c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    int mShadowColor;
65c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik
66c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    // Draw filters
67c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    bool mHasDrawFilter;
68c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    int mPaintFilterClearBits;
69c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    int mPaintFilterSetBits;
70c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik};
71c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik
72ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craikenum StateDeferFlags {
73ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    kStateDeferFlag_Draw = 0x1,
74ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    kStateDeferFlag_Clip = 0x2
75ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik};
76ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik
77527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craikenum DrawOpMode {
78527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    kDrawOpMode_Immediate,
79527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    kDrawOpMode_Defer,
80527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    kDrawOpMode_Flush
81527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik};
82527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik
83c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craikstruct DeferredDisplayState {
843b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    // global op bounds, mapped by mMatrix to be in screen space coordinates, clipped
853b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    Rect mBounds;
86c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik
87c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    // the below are set and used by the OpenGLRenderer at record and deferred playback
88527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    bool mClipValid;
89c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    Rect mClip;
90c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    mat4 mMatrix;
91c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    DrawModifiers mDrawModifiers;
92ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    float mAlpha;
93c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik};
94c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik
95f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy///////////////////////////////////////////////////////////////////////////////
96f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy// Renderer
97f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy///////////////////////////////////////////////////////////////////////////////
98f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy
990fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guyclass DisplayList;
100257ae3502cfad43df681b1783528d645bdabc63fRomain Guyclass TextSetupFunctor;
10165cd612face362d054a85d0f7e5881c59cd523beChris Craikclass VertexBuffer;
102b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
1035cbbce535744b89df5ecea95de21ee3733298260Romain Guy/**
1045cbbce535744b89df5ecea95de21ee3733298260Romain Guy * OpenGL renderer used to draw accelerated 2D graphics. The API is a
1055cbbce535744b89df5ecea95de21ee3733298260Romain Guy * simplified version of Skia's Canvas API.
1065cbbce535744b89df5ecea95de21ee3733298260Romain Guy */
10785bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guyclass OpenGLRenderer {
108e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guypublic:
1097953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API OpenGLRenderer();
110e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    virtual ~OpenGLRenderer();
111e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
11217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
113ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * Sets the name of this renderer. The name is optional and
114ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * empty by default. If the pointer is null the name is set
115ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * to the empty string.
116ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     */
117ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    ANDROID_API void setName(const char* name);
118ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy
119ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    /**
120ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * Returns the name of this renderer as UTF8 string.
121ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * The returned pointer is never null.
122ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     */
123ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    ANDROID_API const char* getName() const;
124ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy
125ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    /**
12687e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy     * Read externally defined properties to control the behavior
12787e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy     * of the renderer.
12887e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy     */
12987e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    ANDROID_API void initProperties();
13087e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy
13187e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    /**
13217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Indicates whether this renderer executes drawing commands immediately.
13317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * If this method returns true, the drawing commands will be executed
13417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * later.
13517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
13649c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy    virtual bool isDeferred();
13749c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy
13817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
13917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Sets the dimension of the underlying drawing surface. This method must
14017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * be called at least once every time the drawing surface changes size.
14117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *
14217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param width The width in pixels of the underlysing surface
14317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param height The height in pixels of the underlysing surface
14417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
145b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    virtual void setViewport(int width, int height);
146e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy
14717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
14817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Prepares the renderer to draw a frame. This method must be invoked
14917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * at the beginning of each frame. When this method is invoked, the
15017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * entire drawing surface is assumed to be redrawn.
15117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *
15217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param opaque If true, the target surface is considered opaque
15317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               and will not be cleared. If false, the target surface
15417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               will be cleared
15517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
1567c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    ANDROID_API status_t prepare(bool opaque);
15717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
15817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
15917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Prepares the renderer to draw a frame. This method must be invoked
16017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * at the beginning of each frame. Only the specified rectangle of the
16117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * frame is assumed to be dirty. A clip will automatically be set to
16217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * the specified rectangle.
16317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *
16417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param left The left coordinate of the dirty rectangle
16517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param top The top coordinate of the dirty rectangle
16617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param right The right coordinate of the dirty rectangle
16717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param bottom The bottom coordinate of the dirty rectangle
16817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param opaque If true, the target surface is considered opaque
16917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               and will not be cleared. If false, the target surface
17017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               will be cleared in the specified dirty rectangle
17117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
1727c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
173e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy
17417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
17517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Indicates the end of a frame. This method must be invoked whenever
17617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * the caller is done rendering a frame.
17717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
17817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    virtual void finish();
1796c319ca1275c8db892c39b48fc54864c949f9171Romain Guy
180c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    /**
181c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This method must be invoked before handing control over to a draw functor.
182c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * See callDrawGLFunction() for instance.
183c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     *
184c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This command must not be recorded inside display lists.
185c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     */
186c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    virtual void interrupt();
187c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy
188c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    /**
189c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This method must be invoked after getting control back from a draw functor.
190c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     *
191c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This command must not be recorded inside display lists.
192c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     */
193c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    virtual void resume();
194c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy
19578dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    ANDROID_API void setCountOverdrawEnabled(bool enabled) {
19678dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy        mCountOverdraw = enabled;
19778dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    }
19878dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy
19978dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    ANDROID_API float getOverdraw() {
20078dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy        return mCountOverdraw ? mOverdraw : 0.0f;
20178dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    }
20278dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy
2038f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    ANDROID_API status_t invokeFunctors(Rect& dirty);
204ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy    ANDROID_API void detachFunctor(Functor* functor);
205ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy    ANDROID_API void attachFunctor(Functor* functor);
2068f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty);
20708ae317c21ec3086b5017672bba87420cc38a407Romain Guy
20811cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    ANDROID_API void pushLayerUpdate(Layer* layer);
20911cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    ANDROID_API void clearLayerUpdates();
21011cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy
2117953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API int getSaveCount() const;
2124aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual int save(int flags);
2134aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void restore();
2144aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void restoreToCount(int saveCount);
215bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
216ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    ANDROID_API int saveLayer(float left, float top, float right, float bottom,
217ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik            SkPaint* paint, int flags) {
218ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik        SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode;
219ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik        if (paint) mode = getXfermode(paint->getXfermode());
220ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik        return saveLayer(left, top, right, bottom, paint ? paint->getAlpha() : 255, mode, flags);
221ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    }
222ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    ANDROID_API int saveLayerAlpha(float left, float top, float right, float bottom,
223ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik            int alpha, int flags) {
224ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik        return saveLayer(left, top, right, bottom, alpha, SkXfermode::kSrcOver_Mode, flags);
225ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    }
226e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    virtual int saveLayer(float left, float top, float right, float bottom,
227ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik            int alpha, SkXfermode::Mode mode, int flags);
228bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy
229d90144db52c7297879b950cbbc85137ed123ab5bChris Craik    int saveLayerDeferred(float left, float top, float right, float bottom,
230d90144db52c7297879b950cbbc85137ed123ab5bChris Craik            int alpha, SkXfermode::Mode mode, int flags);
231d90144db52c7297879b950cbbc85137ed123ab5bChris Craik
2324aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void translate(float dx, float dy);
2334aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void rotate(float degrees);
2344aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void scale(float sx, float sy);
235807daf7df615b60ce6fc41355aabe3aa353cebabRomain Guy    virtual void skew(float sx, float sy);
236f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy
237b98a016c6769b9e80d392df22fe77a2fca048d9fChris Craik    bool hasRectToRectTransform();
2387953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API void getMatrix(SkMatrix* matrix);
2394aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setMatrix(SkMatrix* matrix);
2404aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void concatMatrix(SkMatrix* matrix);
241f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy
2427953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API const Rect& getClipBounds();
2437953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API bool quickReject(float left, float top, float right, float bottom);
2448a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy    bool quickRejectNoScissor(float left, float top, float right, float bottom);
2454aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
246735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    virtual bool clipPath(SkPath* path, SkRegion::Op op);
247735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    virtual bool clipRegion(SkRegion* region, SkRegion::Op op);
248a23eed808a1ae4ec0d818c0a9238385e797fd056Chet Haase    virtual Rect* getClipRect();
249bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
250ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t replayFlags);
251c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    virtual void outputDisplayList(DisplayList* displayList);
252a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik    virtual status_t drawLayer(Layer* layer, float x, float y);
253486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
254527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    status_t drawBitmaps(SkBitmap* bitmap, int bitmapCount, TextureVertex* vertices,
255527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik            const Rect& bounds, SkPaint* paint);
256486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
257486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
258e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy            float srcRight, float srcBottom, float dstLeft, float dstTop,
2595c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            float dstRight, float dstBottom, SkPaint* paint);
260486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint);
261486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
2625a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy            float* vertices, int* colors, SkPaint* paint);
2633b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    virtual status_t drawPatch(SkBitmap* bitmap, Res_png_9patch* patch,
2645c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            float left, float top, float right, float bottom, SkPaint* paint);
2653b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    status_t drawPatch(SkBitmap* bitmap, Res_png_9patch* patch, AssetAtlas::Entry* entry,
266be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy            float left, float top, float right, float bottom, int alpha, SkXfermode::Mode mode);
267486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawColor(int color, SkXfermode::Mode mode);
268486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint);
269486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawRoundRect(float left, float top, float right, float bottom,
27001d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy            float rx, float ry, SkPaint* paint);
271486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint);
272486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint);
273486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawArc(float left, float top, float right, float bottom,
2748b2f5267f16c295f12faab810527cd6311997e34Romain Guy            float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
275486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPath(SkPath* path, SkPaint* paint);
276486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawLines(float* points, int count, SkPaint* paint);
277486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPoints(float* points, int count, SkPaint* paint);
278486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
279325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy            float hOffset, float vOffset, SkPaint* paint);
280486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPosText(const char* text, int bytesCount, int count,
281325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy            const float* positions, SkPaint* paint);
282c25259519f1b74bb62a2b051b74537f073436b5cRomain Guy    virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
283527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik            const float* positions, SkPaint* paint, float length = -1.0f,
284527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik            DrawOpMode drawOpMode = kDrawOpMode_Immediate);
285672433d90fab7383cd28beac9d4485b566a90940Romain Guy    virtual status_t drawRects(const float* rects, int count, SkPaint* paint);
28685bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy
2874aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void resetShader();
2884aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setupShader(SkiaShader* shader);
289d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy
2904aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void resetColorFilter();
2914aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setupColorFilter(SkiaColorFilter* filter);
292db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy
2934aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void resetShadow();
2944aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setupShadow(float radius, float dx, float dy, int color);
2951e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy
2965ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    virtual void resetPaintFilter();
2975ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    virtual void setupPaintFilter(int clearBits, int setBits);
2985ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy
29916ecda5317c40fc3da284952d9b3add34d6763aeChris Craik    // If this value is set to < 1.0, it overrides alpha set on layer (see drawBitmap, drawLayer)
30016ecda5317c40fc3da284952d9b3add34d6763aeChris Craik    void setOverrideLayerAlpha(float alpha) { mDrawModifiers.mOverrideLayerAlpha = alpha; }
30116ecda5317c40fc3da284952d9b3add34d6763aeChris Craik
302a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik    SkPaint* filterPaint(SkPaint* paint);
3035ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy
304ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    bool storeDisplayState(DeferredDisplayState& state, int stateDeferFlags);
305527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    void restoreDisplayState(const DeferredDisplayState& state, bool skipClipRestore = false);
306527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    void setFullScreenClip();
307c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik
308d90144db52c7297879b950cbbc85137ed123ab5bChris Craik    const DrawModifiers& getDrawModifiers() { return mDrawModifiers; }
309d90144db52c7297879b950cbbc85137ed123ab5bChris Craik    void setDrawModifiers(const DrawModifiers& drawModifiers) { mDrawModifiers = drawModifiers; }
310d90144db52c7297879b950cbbc85137ed123ab5bChris Craik
311672433d90fab7383cd28beac9d4485b566a90940Romain Guy    ANDROID_API bool isCurrentTransformSimple() {
312672433d90fab7383cd28beac9d4485b566a90940Romain Guy        return mSnapshot->transform->isSimple();
313672433d90fab7383cd28beac9d4485b566a90940Romain Guy    }
314672433d90fab7383cd28beac9d4485b566a90940Romain Guy
3150f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy    Caches& getCaches() {
3160f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy        return mCaches;
3170f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy    }
3180f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy
319ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    // simple rect clip
320ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    bool isCurrentClipSimple() {
321ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik        return mSnapshot->clipRegion->isEmpty();
322ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik    }
323ff78583d8a73ca35ce65b5d2592570ff6fb9901bChris Craik
32417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
325a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik     * Scales the alpha on the current snapshot. This alpha value will be modulated
32617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * with other alpha values when drawing primitives.
32717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
328a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik    void scaleAlpha(float alpha) {
329a08f95cfeca7217f9c533b03663bf0dceedd259aChris Craik        mSnapshot->alpha *= alpha;
33017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    }
33117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
33217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
3330f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy     * Inserts a named event marker in the stream of GL commands.
3340f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy     */
3350f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy    void eventMark(const char* name) const;
3360f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy
3370f6675332c04c74909425d1d328f02b32c0ff40eRomain Guy    /**
33817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Inserts a named group marker in the stream of GL commands. This marker
33917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * can be used by tools to group commands into logical groups. A call to
34017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * this method must always be followed later on by a call to endMark().
34117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
34213631f3da855f200a151e7837ed9f6b079622b58Romain Guy    void startMark(const char* name) const;
34317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
34417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
34517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Closes the last group marker opened by startMark().
34617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
34713631f3da855f200a151e7837ed9f6b079622b58Romain Guy    void endMark() const;
34813631f3da855f200a151e7837ed9f6b079622b58Romain Guy
349d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase    /**
350d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * Gets the alpha and xfermode out of a paint object. If the paint is null
351d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * alpha will be 255 and the xfermode will be SRC_OVER. This method does
35216ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     * not multiply the paint's alpha by the current snapshot's alpha, and does
35316ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     * not replace the alpha with the overrideLayerAlpha
354d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     *
355d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * @param paint The paint to extract values from
356d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * @param alpha Where to store the resulting alpha
357d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * @param mode Where to store the resulting xfermode
358d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     */
359d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase    static inline void getAlphaAndModeDirect(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) {
360527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        *mode = getXfermodeDirect(paint);
361527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        *alpha = getAlphaDirect(paint);
362527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    }
363527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik
364527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    static inline SkXfermode::Mode getXfermodeDirect(SkPaint* paint) {
365527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        if (!paint) return SkXfermode::kSrcOver_Mode;
366527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        return getXfermode(paint->getXfermode());
367527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    }
368527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik
369527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    static inline int getAlphaDirect(SkPaint* paint) {
370527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        if (!paint) return 255;
371527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        return paint->getAlpha();
372d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase    }
373d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase
374624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy    /**
375624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy     * Return the best transform to use to rasterize text given a full
376624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy     * transform matrix.
377624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy     */
378624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy    mat4 findBestFontTransform(const mat4& transform) const;
379624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy
380527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik#if DEBUG_MERGE_BEHAVIOR
381527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    void drawScreenSpaceColorRect(float left, float top, float right, float bottom, int color) {
382527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        mCaches.setScissorEnabled(false);
383527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik
384527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        // should only be called outside of other draw ops, so stencil can only be in test state
385527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        bool stencilWasEnabled = mCaches.stencil.isTestEnabled();
386527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        mCaches.stencil.disable();
387527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik
388527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        drawColorRect(left, top, right, bottom, color, SkXfermode::kSrcOver_Mode, true);
389527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik
390527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik        if (stencilWasEnabled) mCaches.stencil.enableTest();
391527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik    }
392527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik#endif
393527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik
394e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guyprotected:
395e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    /**
39635643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * Computes the projection matrix, initialize the first snapshot
39735643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * and stores the dimensions of the render target.
39835643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     */
39935643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    void initViewport(int width, int height);
40035643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy
40135643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    /**
40296885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy     * Perform the setup specific to a frame. This method does not
40396885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy     * issue any OpenGL commands.
40496885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy     */
40596885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    void setupFrameState(float left, float top, float right, float bottom, bool opaque);
40696885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy
40796885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    /**
40896885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy     * Indicates the start of rendering. This method will setup the
40996885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy     * initial OpenGL state (viewport, clearing the buffer, etc.)
41096885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy     */
41196885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    status_t startFrame();
41296885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy
41396885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    /**
4147c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy     * Clears the underlying surface if needed.
4157c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy     */
4167c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    virtual status_t clear(float left, float top, float right, float bottom, bool opaque);
4177c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy
4187c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    /**
41935643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * Call this method after updating a layer during a drawing pass.
42035643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     */
42135643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    void resumeAfterLayer();
42235643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy
42335643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    /**
4248ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * This method is called whenever a stencil buffer is required. Subclasses
4258ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * should override this method and call attachStencilBufferToLayer() on the
4268ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * appropriate layer(s).
4278ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
4288ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    virtual void ensureStencilBuffer();
4298ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
4308ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
4318ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Obtains a stencil render buffer (allocating it if necessary) and
4328ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * attaches it to the specified layer.
4338ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
4348ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void attachStencilBufferToLayer(Layer* layer);
4358ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
4368ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
437e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * Compose the layer defined in the current snapshot with the layer
438e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * defined by the previous snapshot.
439e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     *
440e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * The current snapshot *must* be a layer (flag kFlagIsLayer set.)
441e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     *
442e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * @param curent The current snapshot containing the layer to compose
443e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * @param previous The previous snapshot to compose the current layer with
444e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     */
445e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    virtual void composeLayer(sp<Snapshot> current, sp<Snapshot> previous);
446694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy
447ada830f639591b99c3e40de22b07296c7932a33fRomain Guy    /**
448f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Marks the specified region as dirty at the specified bounds.
449ada830f639591b99c3e40de22b07296c7932a33fRomain Guy     */
450f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    void dirtyLayerUnchecked(Rect& bounds, Region* region);
451ada830f639591b99c3e40de22b07296c7932a33fRomain Guy
452ada830f639591b99c3e40de22b07296c7932a33fRomain Guy    /**
453f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Returns the current snapshot.
454ada830f639591b99c3e40de22b07296c7932a33fRomain Guy     */
455624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy    sp<Snapshot> getSnapshot() const {
456f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy        return mSnapshot;
457f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    }
458ada830f639591b99c3e40de22b07296c7932a33fRomain Guy
45942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    /**
46042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     * Returns the region of the current layer.
46142f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     */
462624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy    virtual Region* getRegion() const {
463f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy        return mSnapshot->region;
464f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    }
465f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy
46642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    /**
46742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     * Indicates whether rendering is currently targeted at a layer.
46842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     */
469624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy    virtual bool hasLayer() const {
470f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy        return (mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region;
471f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    }
4721bd1bad0b4a75e633c5edbe802bf6fb4dd765161Romain Guy
47342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    /**
47442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     * Returns the name of the FBO this renderer is rendering into.
47542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     */
476624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy    virtual GLint getTargetFbo() const {
47742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        return 0;
47842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    }
47942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
48077a811610f99e21da7f88dafef60d09f345d0506Romain Guy    /**
48177a811610f99e21da7f88dafef60d09f345d0506Romain Guy     * Renders the specified layer as a textured quad.
48277a811610f99e21da7f88dafef60d09f345d0506Romain Guy     *
48377a811610f99e21da7f88dafef60d09f345d0506Romain Guy     * @param layer The layer to render
48477a811610f99e21da7f88dafef60d09f345d0506Romain Guy     * @param rect The bounds of the layer
48577a811610f99e21da7f88dafef60d09f345d0506Romain Guy     */
48677a811610f99e21da7f88dafef60d09f345d0506Romain Guy    void drawTextureLayer(Layer* layer, const Rect& rect);
48777a811610f99e21da7f88dafef60d09f345d0506Romain Guy
488be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    /**
489be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * Gets the alpha and xfermode out of a paint object. If the paint is null
49016ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     * alpha will be 255 and the xfermode will be SRC_OVER. Accounts for both
49116ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     * snapshot alpha, and overrideLayerAlpha
492be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     *
493be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * @param paint The paint to extract values from
494be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * @param alpha Where to store the resulting alpha
495be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * @param mode Where to store the resulting xfermode
496be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     */
49716ecda5317c40fc3da284952d9b3add34d6763aeChris Craik    inline void getAlphaAndMode(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) const;
49816ecda5317c40fc3da284952d9b3add34d6763aeChris Craik
49916ecda5317c40fc3da284952d9b3add34d6763aeChris Craik    /**
50016ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     * Gets the alpha from a layer, accounting for snapshot alpha and overrideLayerAlpha
50116ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     *
50216ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     * @param layer The layer from which the alpha is extracted
50316ecda5317c40fc3da284952d9b3add34d6763aeChris Craik     */
50416ecda5317c40fc3da284952d9b3add34d6763aeChris Craik    inline float getLayerAlpha(Layer* layer) const;
505be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy
506be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    /**
507be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * Safely retrieves the mode from the specified xfermode. If the specified
508be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * xfermode is null, the mode is assumed to be SkXfermode::kSrcOver_Mode.
509be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     */
510be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    static inline SkXfermode::Mode getXfermode(SkXfermode* mode) {
511be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        SkXfermode::Mode resultMode;
512be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        if (!SkXfermode::AsMode(mode, &resultMode)) {
513be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy            resultMode = SkXfermode::kSrcOver_Mode;
514be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        }
515be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        return resultMode;
516be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    }
517be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy
51811cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    /**
51911cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy     * Set to true to suppress error checks at the end of a frame.
52011cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy     */
521624234f69b2a4781d24f3e4c6ae6450729e38397Romain Guy    virtual bool suppressErrorChecks() const {
52211cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy        return false;
52311cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    }
52411cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy
52508ae317c21ec3086b5017672bba87420cc38a407Romain Guyprivate:
5265cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
527dcfc836b457a87881da409e1acf251515f121446Romain Guy     * Discards the content of the framebuffer if supported by the driver.
528dcfc836b457a87881da409e1acf251515f121446Romain Guy     * This method should be called at the beginning of a frame to optimize
529dcfc836b457a87881da409e1acf251515f121446Romain Guy     * rendering on some tiler architectures.
530dcfc836b457a87881da409e1acf251515f121446Romain Guy     */
531dcfc836b457a87881da409e1acf251515f121446Romain Guy    void discardFramebuffer(float left, float top, float right, float bottom);
532dcfc836b457a87881da409e1acf251515f121446Romain Guy
533dcfc836b457a87881da409e1acf251515f121446Romain Guy    /**
534ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy     * Ensures the state of the renderer is the same as the state of
535ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy     * the GL context.
536ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy     */
537ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy    void syncState();
538ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy
539ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy    /**
5402b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * Tells the GPU what part of the screen is about to be redrawn.
541c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * This method will use the clip rect that we started drawing the
542c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * frame with.
5432b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * This method needs to be invoked every time getTargetFbo() is
5442b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * bound again.
5452b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     */
54657b5268708c3b974296c7d4e58a02a957979224aRomain Guy    void startTiling(const sp<Snapshot>& snapshot, bool opaque = false);
5472b7028eabac80cec170572bc0e945a1d4224e595Romain Guy
5482b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    /**
549c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * Tells the GPU what part of the screen is about to be redrawn.
550c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * This method needs to be invoked every time getTargetFbo() is
551c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * bound again.
552c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     */
553c3fedafc5f50100219449125a000e3138f6fb987Romain Guy    void startTiling(const Rect& clip, int windowHeight, bool opaque = false);
554c3fedafc5f50100219449125a000e3138f6fb987Romain Guy
555c3fedafc5f50100219449125a000e3138f6fb987Romain Guy    /**
5562b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * Tells the GPU that we are done drawing the frame or that we
5572b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * are switching to another render target.
5582b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     */
5592b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    void endTiling();
5602b7028eabac80cec170572bc0e945a1d4224e595Romain Guy
5612b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    /**
5625cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Saves the current state of the renderer as a new snapshot.
5635cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * The new snapshot is saved in mSnapshot and the previous snapshot
5645cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * is linked from mSnapshot->previous.
5655cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
5668aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy     * @param flags The save flags; see SkCanvas for more information
5678aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy     *
5685cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @return The new save count. This value can be passed to #restoreToCount()
5695cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
5708aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy    int saveSnapshot(int flags);
5715cbbce535744b89df5ecea95de21ee3733298260Romain Guy
5725cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
5735cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Restores the current snapshot; mSnapshot becomes mSnapshot->previous.
5745cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
5752542d199745cdf3ec910b8e3e4cff5851ed24e9bRomain Guy     * @return True if the clip was modified.
5765cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
577bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    bool restoreSnapshot();
578bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
5795cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
5805cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Sets the clipping rectangle using glScissor. The clip is defined by
5815cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * the current snapshot's clipRect member.
5825cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
583bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    void setScissorFromClip();
584bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
5855cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
5868ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Sets the clipping region using the stencil buffer. The clip region
5878ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * is defined by the current snapshot's clipRegion member.
5888ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
5898ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void setStencilFromClip();
5908ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
5918ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
59235643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * Performs a quick reject but does not affect the scissor. Returns
59335643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * the transformed rect to test and the current clip.
59435643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     */
59535643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    bool quickRejectNoScissor(float left, float top, float right, float bottom,
59635643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy            Rect& transformed, Rect& clip);
59735643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy
59835643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    /**
599cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik     * Performs a quick reject but adjust the bounds to account for stroke width if necessary
600cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik     */
601cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik    bool quickRejectPreStroke(float left, float top, float right, float bottom, SkPaint* paint);
602cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik
603cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik    /**
604408eb12631376cbdc96803e918decf6ea804d346Chris Craik     * Given the local bounds of the layer, calculates ...
605d90144db52c7297879b950cbbc85137ed123ab5bChris Craik     */
606d90144db52c7297879b950cbbc85137ed123ab5bChris Craik    void calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool fboLayer);
607d90144db52c7297879b950cbbc85137ed123ab5bChris Craik
608d90144db52c7297879b950cbbc85137ed123ab5bChris Craik    /**
609408eb12631376cbdc96803e918decf6ea804d346Chris Craik     * Given the local bounds + clip of the layer, updates current snapshot's empty/invisible
610408eb12631376cbdc96803e918decf6ea804d346Chris Craik     */
611408eb12631376cbdc96803e918decf6ea804d346Chris Craik    void updateSnapshotIgnoreForLayer(const Rect& bounds, const Rect& clip,
612408eb12631376cbdc96803e918decf6ea804d346Chris Craik            bool fboLayer, int alpha);
613408eb12631376cbdc96803e918decf6ea804d346Chris Craik
614408eb12631376cbdc96803e918decf6ea804d346Chris Craik    /**
615d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * Creates a new layer stored in the specified snapshot.
616d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     *
617d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param snapshot The snapshot associated with the new layer
618d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param left The left coordinate of the layer
619d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param top The top coordinate of the layer
620d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param right The right coordinate of the layer
621d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param bottom The bottom coordinate of the layer
622d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param alpha The translucency of the layer
623d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param mode The blending mode of the layer
624d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param flags The layer save flags
625eb99356a0548684a501766e6a524529ab93304c8Romain Guy     * @param previousFbo The name of the current framebuffer
626d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     *
627d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @return True if the layer was successfully created, false otherwise
628d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     */
629d48885a6c8cd27a8a62552c33b5282e9882e19f6Chet Haase    bool createLayer(float left, float top, float right, float bottom,
630eb99356a0548684a501766e6a524529ab93304c8Romain Guy            int alpha, SkXfermode::Mode mode, int flags, GLuint previousFbo);
631d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy
632d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy    /**
6335b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * Creates a new layer stored in the specified snapshot as an FBO.
6345b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     *
6355b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param layer The layer to store as an FBO
6365b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param snapshot The snapshot associated with the new layer
6375b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param bounds The bounds of the layer
6385b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param previousFbo The name of the current framebuffer
6395b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     */
640d48885a6c8cd27a8a62552c33b5282e9882e19f6Chet Haase    bool createFboLayer(Layer* layer, Rect& bounds, Rect& clip, GLuint previousFbo);
6415b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy
6425b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    /**
6435b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * Compose the specified layer as a region.
6445b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     *
6455b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param layer The layer to compose
6465b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param rect The layer's bounds
6475b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     */
6485b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    void composeLayerRegion(Layer* layer, const Rect& rect);
6495b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy
6505b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    /**
6515b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * Compose the specified layer as a simple rectangle.
6525b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     *
6535b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param layer The layer to compose
6545b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param rect The layer's bounds
6555b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param swap If true, the source and destination are swapped
6565b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     */
6575b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    void composeLayerRect(Layer* layer, const Rect& rect, bool swap = false);
6585b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy
65954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
66054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Clears all the regions corresponding to the current list of layers.
66154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * This method MUST be invoked before any drawing operation.
66254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
66354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    void clearLayerRegions();
66454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy
66554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
666f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Mark the layer as dirty at the specified coordinates. The coordinates
667f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * are transformed with the supplied matrix.
668f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     */
669f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    void dirtyLayer(const float left, const float top,
670f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy            const float right, const float bottom, const mat4 transform);
671f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy
672f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    /**
673f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Mark the layer as dirty at the specified coordinates.
674f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     */
675f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    void dirtyLayer(const float left, const float top,
676f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy            const float right, const float bottom);
677f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy
678f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    /**
6795cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Draws a colored rectangle with the specified color. The specified coordinates
680735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * are transformed by the current snapshot's transform matrix unless specified
681735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * otherwise.
6825cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
6835cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param left The left coordinate of the rectangle
6845cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param top The top coordinate of the rectangle
6855cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param right The right coordinate of the rectangle
6865cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param bottom The bottom coordinate of the rectangle
6875cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param color The rectangle's ARGB color, defined as a packed 32 bits word
688026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param mode The Skia xfermode to use
6893d58c03de0d8877b36cdb78b0ca8b5cac7f600e2Romain Guy     * @param ignoreTransform True if the current transform should be ignored
6905cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
691026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    void drawColorRect(float left, float top, float right, float bottom,
6921c740bce8a762f02b5283045a0e2de7c8fb41277Romain Guy            int color, SkXfermode::Mode mode, bool ignoreTransform = false);
6935cbbce535744b89df5ecea95de21ee3733298260Romain Guy
69454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
695735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * Draws a series of colored rectangles with the specified color. The specified
696735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * coordinates are transformed by the current snapshot's transform matrix unless
697735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * specified otherwise.
698735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     *
699735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param rects A list of rectangles, 4 floats (left, top, right, bottom)
700735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     *              per rectangle
701735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param color The rectangles' ARGB color, defined as a packed 32 bits word
702735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param mode The Skia xfermode to use
703735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param ignoreTransform True if the current transform should be ignored
7048ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * @param dirty True if calling this method should dirty the current layer
7053bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy     * @param clip True if the rects should be clipped, false otherwise
706735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     */
707735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    status_t drawColorRects(const float* rects, int count, int color,
7083bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy            SkXfermode::Mode mode, bool ignoreTransform = false,
7093bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy            bool dirty = true, bool clip = true);
710735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy
711735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    /**
71254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Draws the shape represented by the specified path texture.
71354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * This method invokes drawPathTexture() but takes into account
71454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * the extra left/top offset and the texture offset to correctly
71554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * position the final shape.
71654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
71754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param left The left coordinate of the shape to render
71854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param top The top coordinate of the shape to render
71954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param texture The texture reprsenting the shape
72054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param paint The paint to draw the shape with
72154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
722486590963e2207d68eebd6944fec70d50d41116aChet Haase    status_t drawShape(float left, float top, const PathTexture* texture, SkPaint* paint);
72354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy
72454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
72554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Draws the specified texture as an alpha bitmap. Alpha bitmaps obey
72654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * different compositing rules.
72754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
72854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param texture The texture to draw with
72954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param left The x coordinate of the bitmap
73054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param top The y coordinate of the bitmap
73154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param paint The paint to render with
73254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
733a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy    void drawAlphaBitmap(Texture* texture, float left, float top, SkPaint* paint);
734a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy
73554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
73665cd612face362d054a85d0f7e5881c59cd523beChris Craik     * Renders a strip of polygons with the specified paint, used for tessellated geometry.
73765cd612face362d054a85d0f7e5881c59cd523beChris Craik     *
73865cd612face362d054a85d0f7e5881c59cd523beChris Craik     * @param vertexBuffer The VertexBuffer to be drawn
73965cd612face362d054a85d0f7e5881c59cd523beChris Craik     * @param paint The paint to render with
74065cd612face362d054a85d0f7e5881c59cd523beChris Craik     * @param useOffset Offset the vertexBuffer (used in drawing non-AA lines)
74165cd612face362d054a85d0f7e5881c59cd523beChris Craik     */
74265cd612face362d054a85d0f7e5881c59cd523beChris Craik    status_t drawVertexBuffer(const VertexBuffer& vertexBuffer, SkPaint* paint,
74365cd612face362d054a85d0f7e5881c59cd523beChris Craik            bool useOffset = false);
74465cd612face362d054a85d0f7e5881c59cd523beChris Craik
74565cd612face362d054a85d0f7e5881c59cd523beChris Craik    /**
746710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik     * Renders the convex hull defined by the specified path as a strip of polygons.
74754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
748710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik     * @param path The hull of the path to draw
749cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik     * @param paint The paint to render with
75054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
75165cd612face362d054a85d0f7e5881c59cd523beChris Craik    status_t drawConvexPath(const SkPath& path, SkPaint* paint);
752858aa93ddb6e69e0503382af63bb681b6728aef1Chet Haase
7535cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
7545cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Draws a textured rectangle with the specified texture. The specified coordinates
7555cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * are transformed by the current snapshot's transform matrix.
7565cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
7575cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param left The left coordinate of the rectangle
7585cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param top The top coordinate of the rectangle
7595cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param right The right coordinate of the rectangle
7605cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param bottom The bottom coordinate of the rectangle
7615cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param texture The texture name to map onto the rectangle
7625cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param alpha An additional translucency parameter, between 0.0f and 1.0f
763d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param mode The blending mode
764c1396e93b6a5286a5183c00c781b62e940a12c1fRomain Guy     * @param blend True if the texture contains an alpha channel
7655cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
766bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy    void drawTextureRect(float left, float top, float right, float bottom, GLuint texture,
767a979474f15b454c8e2963f239a3770e200bb227cRomain Guy            float alpha, SkXfermode::Mode mode, bool blend);
768c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy
769026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    /**
77082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * Draws a textured rectangle with the specified texture. The specified coordinates
77182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * are transformed by the current snapshot's transform matrix.
77282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     *
77382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param left The left coordinate of the rectangle
77482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param top The top coordinate of the rectangle
77582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param right The right coordinate of the rectangle
77682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param bottom The bottom coordinate of the rectangle
77782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param texture The texture to use
77882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param paint The paint containing the alpha, blending mode, etc.
77982ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     */
780a979474f15b454c8e2963f239a3770e200bb227cRomain Guy    void drawTextureRect(float left, float top, float right, float bottom,
7818164c2d338781c3a3c4a443941070dca5d88f2a7Romain Guy            Texture* texture, SkPaint* paint);
78282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy
78382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy    /**
78403750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * Draws a textured mesh with the specified texture. If the indices are omitted,
78503750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * the mesh is drawn as a simple quad. The mesh pointers become offsets when a
78603750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * VBO is bound.
78782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     *
78882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param left The left coordinate of the rectangle
78982ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param top The top coordinate of the rectangle
79082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param right The right coordinate of the rectangle
79182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param bottom The bottom coordinate of the rectangle
79282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param texture The texture name to map onto the rectangle
79382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param alpha An additional translucency parameter, between 0.0f and 1.0f
79482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param mode The blending mode
79582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param blend True if the texture contains an alpha channel
79682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param vertices The vertices that define the mesh
79782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param texCoords The texture coordinates of each vertex
79882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param elementsCount The number of elements in the mesh, required by indices
799f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy     * @param swapSrcDst Whether or not the src and dst blending operations should be swapped
800f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy     * @param ignoreTransform True if the current transform should be ignored
80103750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * @param vbo The VBO used to draw the mesh
8025b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param ignoreScale True if the model view matrix should not be scaled
8035b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param dirty True if calling this method should dirty the current layer
804f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy     */
805f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy    void drawTextureMesh(float left, float top, float right, float bottom, GLuint texture,
806a979474f15b454c8e2963f239a3770e200bb227cRomain Guy            float alpha, SkXfermode::Mode mode, bool blend,
8076820ac8b14b4558f5d8b833dde80895306a3e137Romain Guy            GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
8085b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy            bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0,
8095b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy            bool ignoreScale = false, bool dirty = true);
810f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy
8113b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    void drawIndexedTextureMesh(float left, float top, float right, float bottom, GLuint texture,
8123b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy            float alpha, SkXfermode::Mode mode, bool blend,
8133b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy            GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
8143b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy            bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0,
8153b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy            bool ignoreScale = false, bool dirty = true);
8163b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy
817886b275e529e44a59c54b933453d9bc902973178Romain Guy    void drawAlpha8TextureMesh(float left, float top, float right, float bottom,
818886b275e529e44a59c54b933453d9bc902973178Romain Guy            GLuint texture, bool hasColor, int color, int alpha, SkXfermode::Mode mode,
819886b275e529e44a59c54b933453d9bc902973178Romain Guy            GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
820527a3aace1dd72432c2e0472a570e030ad04bf16Chris Craik            bool ignoreTransform, bool ignoreScale = false, bool dirty = true);
821886b275e529e44a59c54b933453d9bc902973178Romain Guy
822f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy    /**
8230a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * Draws text underline and strike-through if needed.
8240a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     *
8250a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param text The text to decor
8260a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param bytesCount The number of bytes in the text
8270a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param length The length in pixels of the text, can be <= 0.0f to force a measurement
8280a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param x The x coordinate where the text will be drawn
8290a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param y The y coordinate where the text will be drawn
8300a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param paint The paint to draw the text with
8310a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     */
8320a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy    void drawTextDecorations(const char* text, int bytesCount, float length,
8330a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy            float x, float y, SkPaint* paint);
8341e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy
835416a847633680d94efb926837efdc18726d54918Raph Levien   /**
836416a847633680d94efb926837efdc18726d54918Raph Levien     * Draws shadow layer on text (with optional positions).
837416a847633680d94efb926837efdc18726d54918Raph Levien     *
838416a847633680d94efb926837efdc18726d54918Raph Levien     * @param paint The paint to draw the shadow with
839416a847633680d94efb926837efdc18726d54918Raph Levien     * @param text The text to draw
840416a847633680d94efb926837efdc18726d54918Raph Levien     * @param bytesCount The number of bytes in the text
841416a847633680d94efb926837efdc18726d54918Raph Levien     * @param count The number of glyphs in the text
842416a847633680d94efb926837efdc18726d54918Raph Levien     * @param positions The x, y positions of individual glyphs (or NULL)
843416a847633680d94efb926837efdc18726d54918Raph Levien     * @param fontRenderer The font renderer object
844416a847633680d94efb926837efdc18726d54918Raph Levien     * @param alpha The alpha value for drawing the shadow
845416a847633680d94efb926837efdc18726d54918Raph Levien     * @param mode The xfermode for drawing the shadow
846416a847633680d94efb926837efdc18726d54918Raph Levien     * @param x The x coordinate where the shadow will be drawn
847416a847633680d94efb926837efdc18726d54918Raph Levien     * @param y The y coordinate where the shadow will be drawn
848416a847633680d94efb926837efdc18726d54918Raph Levien     */
849416a847633680d94efb926837efdc18726d54918Raph Levien    void drawTextShadow(SkPaint* paint, const char* text, int bytesCount, int count,
850416a847633680d94efb926837efdc18726d54918Raph Levien            const float* positions, FontRenderer& fontRenderer, int alpha, SkXfermode::Mode mode,
851416a847633680d94efb926837efdc18726d54918Raph Levien            float x, float y);
852416a847633680d94efb926837efdc18726d54918Raph Levien
85354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
85454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Draws a path texture. Path textures are alpha8 bitmaps that need special
85554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * compositing to apply colors/filters/etc.
85654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
85754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param texture The texture to render
85854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param x The x coordinate where the texture will be drawn
85954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param y The y coordinate where the texture will be drawn
86054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param paint The paint to draw the texture with
86154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
862416a847633680d94efb926837efdc18726d54918Raph Levien     void drawPathTexture(const PathTexture* texture, float x, float y, SkPaint* paint);
86301d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy
8641e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    /**
865ac670c0433d19397d4e36ced2110475b6f54fe26Romain Guy     * Resets the texture coordinates stored in mMeshVertices. Setting the values
866026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * back to default is achieved by calling:
867026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     *
8688ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy     * resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f);
869026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     *
870026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param u1 The left coordinate of the texture
871026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param v1 The bottom coordinate of the texture
872026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param u2 The right coordinate of the texture
873026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param v2 The top coordinate of the texture
874026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     */
875026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    void resetDrawTextureTexCoords(float u1, float v1, float u2, float v2);
876026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy
8778ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy    /**
878768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy     * Returns true if the specified paint will draw invisible text.
879768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy     */
880768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy    bool canSkipText(const SkPaint* paint) const;
881768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy
882768bffc9b814f6a1f7d9ff59d91285895c23bbe9Romain Guy    /**
883746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * Binds the specified texture. The texture unit must have been selected
884746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * prior to calling this method.
885a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy     */
886746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    inline void bindTexture(GLuint texture) {
887746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy        glBindTexture(GL_TEXTURE_2D, texture);
888746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    }
889746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
890746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    /**
891aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy     * Binds the specified EGLImage texture. The texture unit must have been selected
892aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy     * prior to calling this method.
893aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy     */
894aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    inline void bindExternalTexture(GLuint texture) {
895aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy        glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);
896aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    }
897aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy
898aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    /**
89982ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * Enable or disable blending as necessary. This function sets the appropriate
90082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * blend function based on the specified xfermode.
90182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     */
902f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy    inline void chooseBlending(bool blend, SkXfermode::Mode mode, ProgramDescription& description,
903f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy            bool swapSrcDst = false);
904a5aed0d58962a24c44728ffc46dc9e1ba2f9fda5Romain Guy
905f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy    /**
906d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * Use the specified program with the current GL context. If the program is already
907d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * in use, it will not be bound again. If it is not in use, the current program is
908d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * marked unused and the specified program becomes used and becomes the new
909d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * current program.
9106926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy     *
911d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * @param program The program to use
912d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     *
913d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * @return true If the specified program was already in use, false otherwise.
914260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy     */
915889f8d1403761d5668115ced6cbb3f767cfe966dRomain Guy    inline bool useProgram(Program* program);
916260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy
917746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    /**
918746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * Invoked before any drawing operation. This sets required state.
919746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     */
92054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    void setupDraw(bool clear = true);
92117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
92270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    /**
92370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy     * Various methods to setup OpenGL rendering.
92470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy     */
92570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawWithTexture(bool isAlpha8 = false);
926ff316ec7a76e52572a2e89b691e6b3bba0cafba3Romain Guy    void setupDrawWithTextureAndColor(bool isAlpha8 = false);
927aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    void setupDrawWithExternalTexture();
92815bc6437f8b4cf10dba55c7638d349e7b9563f4fRomain Guy    void setupDrawNoTexture();
929710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik    void setupDrawAA();
930ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy    void setupDrawPoint(float pointSize);
9318d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy    void setupDrawColor(int color, int alpha);
93270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColor(float r, float g, float b, float a);
93386568198f2c83d4ce5c4cd692eda074ba9de9ed2Romain Guy    void setupDrawAlpha8Color(int color, int alpha);
9344121063313ac0d6f69f6253cac821d0c1c122086Romain Guy    void setupDrawTextGamma(const SkPaint* paint);
93570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawShader();
93670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColorFilter();
93770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawBlending(SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
93870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool swapSrcDst = false);
93970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawBlending(bool blend = true, SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
94070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool swapSrcDst = false);
94170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawProgram();
94270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawDirtyRegionsDisabled();
9438a5cc92a150bae38ec43732d941b38bb381fe153Chet Haase    void setupDrawModelViewIdentity(bool offset = false);
94470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawModelView(float left, float top, float right, float bottom,
94570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool ignoreTransform = false, bool ignoreModelView = false);
94670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawModelViewTranslate(float left, float top, float right, float bottom,
94770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool ignoreTransform = false);
948ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy    void setupDrawPointUniforms();
94970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColorUniforms();
95086568198f2c83d4ce5c4cd692eda074ba9de9ed2Romain Guy    void setupDrawPureColorUniforms();
9518d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy    void setupDrawShaderIdentityUniforms();
95270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawShaderUniforms(bool ignoreTransform = false);
95370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColorFilterUniforms();
95470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawSimpleMesh();
95570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawTexture(GLuint texture);
956aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    void setupDrawExternalTexture(GLuint texture);
9578f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy    void setupDrawTextureTransform();
9588f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy    void setupDrawTextureTransformUniforms(mat4& transform);
9594121063313ac0d6f69f6253cac821d0c1c122086Romain Guy    void setupDrawTextGammaUniforms();
9608d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy    void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords = NULL, GLuint vbo = 0);
961ff316ec7a76e52572a2e89b691e6b3bba0cafba3Romain Guy    void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLvoid* colors);
9623b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    void setupDrawMeshIndices(GLvoid* vertices, GLvoid* texCoords, GLuint vbo = 0);
9635b0200bd47e8a9a4dc8d2e6c3a110d522b30bf82Chet Haase    void setupDrawVertices(GLvoid* vertices);
96470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void finishDrawTexture();
965f09ef51889f75289b041f9e9f949b7b82ed5b686Romain Guy    void accountForClear(SkXfermode::Mode mode);
966746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
96711cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    bool updateLayer(Layer* layer, bool inFrame);
96811cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    void updateLayers();
96996885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    void flushLayers();
97011cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy
97117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
97217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Renders the specified region as a series of rectangles. This method
97317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * is used for debugging only.
97417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
9753a3133d876caf60ebff2176ad75c3dcf0259148dRomain Guy    void drawRegionRects(const Region& region);
9763a3133d876caf60ebff2176ad75c3dcf0259148dRomain Guy
9778ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
9788ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Renders the specified region as a series of rectangles. The region
9798ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * must be in screen-space coordinates.
9808ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
9818ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void drawRegionRects(const SkRegion& region, int color, SkXfermode::Mode mode,
9828ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy            bool dirty = false);
9838ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
9848ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
9858ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Draws the current clip region if any. Only when DEBUG_CLIP_REGIONS
9868ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * is turned on.
9878ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
9888ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void debugClip();
9898ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
9907c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy    void debugOverdraw(bool enable, bool clear);
9917c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy    void renderOverdraw();
99278dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    void countOverdraw();
9937c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy
994746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    /**
995746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * Should be invoked every time the glScissor is modified.
996746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     */
997746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    inline void dirtyClip() {
998746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy        mDirtyClip = true;
999746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    }
1000746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
10013b753829ae858d424fe109f714745379a6daf455Romain Guy    inline mat4& currentTransform() const {
10023b753829ae858d424fe109f714745379a6daf455Romain Guy        return *mSnapshot->transform;
10033b753829ae858d424fe109f714745379a6daf455Romain Guy    }
10043b753829ae858d424fe109f714745379a6daf455Romain Guy
10053b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    inline const UvMapper& getMapper(const Texture* texture) {
10063b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy        return texture && texture->uvMapper ? *texture->uvMapper : mUvMapper;
10073b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    }
10083b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy
10093b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    /**
10103b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy     * Returns a texture object for the specified bitmap. The texture can
10113b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy     * come from the texture cache or an atlas. If this method returns
10123b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy     * NULL, the texture could not be found and/or allocated.
10133b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy     */
10143b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    Texture* getTexture(SkBitmap* bitmap);
10153b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy
1016bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    // Dimensions of the drawing surface
1017bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    int mWidth, mHeight;
1018bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
101985bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy    // Matrix used for ortho projection in shaders
1020260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy    mat4 mOrthoMatrix;
1021bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
1022c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy    // Model-view matrix used to position/size objects
1023c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy    mat4 mModelView;
1024c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy
1025bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    // Number of saved states
1026bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    int mSaveCount;
1027f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy    // Base state
1028ae5575b3421c8fbe590ab046d7d5f2b36ecfd821Romain Guy    sp<Snapshot> mFirstSnapshot;
1029bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    // Current state
1030bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    sp<Snapshot> mSnapshot;
10312b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    // State used to define the clipping region
10325f803623559aab395a29d575c37c4e39c23a4b4eChris Craik    Rect mTilingClip;
103396885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    // Is the target render surface opaque
103496885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    bool mOpaque;
103596885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    // Is a frame currently being rendered
103696885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    bool mFrameStarted;
10379d5316e3f56d138504565ff311145ac01621dff4Romain Guy
1038026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    // Used to draw textured quads
1039ac670c0433d19397d4e36ced2110475b6f54fe26Romain Guy    TextureVertex mMeshVertices[4];
1040ce0537b80087a6225273040a987414b1dd081aa0Romain Guy
10413b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    // Default UV mapper
10423b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy    const UvMapper mUvMapper;
10433b748a44c6bd2ea05fe16839caf73dbe50bd7ae9Romain Guy
1044c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    // shader, filters, and shadow
1045c3566d06421c8acc0aafb18f7e307e5725ce87e1Chris Craik    DrawModifiers mDrawModifiers;
10465ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    SkPaint mFilteredPaint;
10475ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy
104882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy    // Various caches
1049fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy    Caches& mCaches;
10503bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy    Extensions& mExtensions;
10518694230ff25fa0a60e480d424843e56b718f0516Romain Guy
10528f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    // List of rectangles to clear after saveLayer() is invoked
105354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    Vector<Rect*> mLayers;
10548f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    // List of functors to invoke after a frame is drawn
1055ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy    SortedVector<Functor*> mFunctors;
105611cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    // List of layers to update at the beginning of a frame
105711cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    Vector<Layer*> mLayerUpdates;
105854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy
1059746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    // Indicates whether the clip must be restored
1060746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    bool mDirtyClip;
1061746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
106270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // The following fields are used to setup drawing
106370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Used to describe the shaders to generate
106470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    ProgramDescription mDescription;
106570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Color description
106670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    bool mColorSet;
106770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    float mColorA, mColorR, mColorG, mColorB;
106870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Indicates that the shader should get a color
106970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    bool mSetShaderColor;
107070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Current texture unit
107170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    GLuint mTextureUnit;
107270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Track dirty regions, true by default
107370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    bool mTrackDirtyRegions;
10742b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    // Indicate whether we are drawing an opaque frame
10752b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    bool mOpaqueFrame;
107670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy
107787e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    // See PROPERTY_DISABLE_SCISSOR_OPTIMIZATION in
107887e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    // Properties.h
107987e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    bool mScissorOptimizationDisabled;
108087e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy
108154c1a64d5441a964890b44280e4457e11f4f924aRomain Guy    // No-ops start/endTiling when set
108254c1a64d5441a964890b44280e4457e11f4f924aRomain Guy    bool mSuppressTiling;
108354c1a64d5441a964890b44280e4457e11f4f924aRomain Guy
108478dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy
108578dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    // If true, this renderer will setup drawing to emulate
108678dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    // an increment stencil buffer in the color buffer
108778dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    bool mCountOverdraw;
108878dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy    float mOverdraw;
108978dd96d5af20f489f0e8b288617d57774ec284f7Romain Guy
1090ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    // Optional name of the renderer
1091ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    String8 mName;
1092ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy
1093b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    friend class DisplayListRenderer;
109496885eb480c5e0526fe2f77d30f6e551f3f3ceabRomain Guy    friend class Layer;
1095257ae3502cfad43df681b1783528d645bdabc63fRomain Guy    friend class TextSetupFunctor;
1096b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
1097bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy}; // class OpenGLRenderer
1098e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
10999d5316e3f56d138504565ff311145ac01621dff4Romain Guy}; // namespace uirenderer
1100e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy}; // namespace android
1101e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
11025b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#endif // ANDROID_HWUI_OPENGL_RENDERER_H
1103