OpenGLRenderer.h revision 3bbacf27c0be1bae4e4483577fc89ae3113abe5d
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
37c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy#include "Debug.h"
3851769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#include "Extensions.h"
39f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy#include "Matrix.h"
405cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Program.h"
41bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy#include "Rect.h"
425cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Snapshot.h"
43f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy#include "Vertex.h"
4406f96e2652e4855b6520ad9dd70583677605b79aRomain Guy#include "SkiaShader.h"
45db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy#include "SkiaColorFilter.h"
46fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy#include "Caches.h"
47bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
48e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guynamespace android {
499d5316e3f56d138504565ff311145ac01621dff4Romain Guynamespace uirenderer {
50e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
51f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy///////////////////////////////////////////////////////////////////////////////
52f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy// Renderer
53f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy///////////////////////////////////////////////////////////////////////////////
54f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy
550fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guyclass DisplayList;
56b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
575cbbce535744b89df5ecea95de21ee3733298260Romain Guy/**
585cbbce535744b89df5ecea95de21ee3733298260Romain Guy * OpenGL renderer used to draw accelerated 2D graphics. The API is a
595cbbce535744b89df5ecea95de21ee3733298260Romain Guy * simplified version of Skia's Canvas API.
605cbbce535744b89df5ecea95de21ee3733298260Romain Guy */
6185bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guyclass OpenGLRenderer {
62e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guypublic:
637953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API OpenGLRenderer();
64e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    virtual ~OpenGLRenderer();
65e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
6617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
67ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * Sets the name of this renderer. The name is optional and
68ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * empty by default. If the pointer is null the name is set
69ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * to the empty string.
70ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     */
71ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    ANDROID_API void setName(const char* name);
72ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy
73ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    /**
74ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * Returns the name of this renderer as UTF8 string.
75ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     * The returned pointer is never null.
76ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy     */
77ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    ANDROID_API const char* getName() const;
78ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy
79ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    /**
8087e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy     * Read externally defined properties to control the behavior
8187e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy     * of the renderer.
8287e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy     */
8387e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    ANDROID_API void initProperties();
8487e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy
8587e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    /**
8617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Indicates whether this renderer executes drawing commands immediately.
8717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * If this method returns true, the drawing commands will be executed
8817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * later.
8917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
9049c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy    virtual bool isDeferred();
9149c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy
9217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
9317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Sets the dimension of the underlying drawing surface. This method must
9417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * be called at least once every time the drawing surface changes size.
9517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *
9617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param width The width in pixels of the underlysing surface
9717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param height The height in pixels of the underlysing surface
9817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
99b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    virtual void setViewport(int width, int height);
100e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy
10117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
10217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Prepares the renderer to draw a frame. This method must be invoked
10317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * at the beginning of each frame. When this method is invoked, the
10417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * entire drawing surface is assumed to be redrawn.
10517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *
10617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param opaque If true, the target surface is considered opaque
10717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               and will not be cleared. If false, the target surface
10817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               will be cleared
10917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
1107c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    ANDROID_API status_t prepare(bool opaque);
11117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
11217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
11317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Prepares the renderer to draw a frame. This method must be invoked
11417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * at the beginning of each frame. Only the specified rectangle of the
11517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * frame is assumed to be dirty. A clip will automatically be set to
11617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * the specified rectangle.
11717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *
11817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param left The left coordinate of the dirty rectangle
11917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param top The top coordinate of the dirty rectangle
12017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param right The right coordinate of the dirty rectangle
12117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param bottom The bottom coordinate of the dirty rectangle
12217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * @param opaque If true, the target surface is considered opaque
12317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               and will not be cleared. If false, the target surface
12417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     *               will be cleared in the specified dirty rectangle
12517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
1267c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
127e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy
12817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
12917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Indicates the end of a frame. This method must be invoked whenever
13017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * the caller is done rendering a frame.
13117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
13217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    virtual void finish();
1336c319ca1275c8db892c39b48fc54864c949f9171Romain Guy
134c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    /**
135c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This method must be invoked before handing control over to a draw functor.
136c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * See callDrawGLFunction() for instance.
137c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     *
138c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This command must not be recorded inside display lists.
139c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     */
140c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    virtual void interrupt();
141c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy
142c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    /**
143c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This method must be invoked after getting control back from a draw functor.
144c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     *
145c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     * This command must not be recorded inside display lists.
146c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy     */
147c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy    virtual void resume();
148c89b14bba0f6cc2c91629080617f7ed215f697f3Romain Guy
1498f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    ANDROID_API status_t invokeFunctors(Rect& dirty);
150ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy    ANDROID_API void detachFunctor(Functor* functor);
151ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy    ANDROID_API void attachFunctor(Functor* functor);
1528f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty);
15308ae317c21ec3086b5017672bba87420cc38a407Romain Guy
15411cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    ANDROID_API void pushLayerUpdate(Layer* layer);
15511cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    ANDROID_API void clearLayerUpdates();
15611cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy
1577953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API int getSaveCount() const;
1584aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual int save(int flags);
1594aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void restore();
1604aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void restoreToCount(int saveCount);
161bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
162e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    virtual int saveLayer(float left, float top, float right, float bottom,
1635c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            SkPaint* p, int flags);
164e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    virtual int saveLayerAlpha(float left, float top, float right, float bottom,
165e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy            int alpha, int flags);
166bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy
1674aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void translate(float dx, float dy);
1684aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void rotate(float degrees);
1694aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void scale(float sx, float sy);
170807daf7df615b60ce6fc41355aabe3aa353cebabRomain Guy    virtual void skew(float sx, float sy);
171f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy
1727953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API void getMatrix(SkMatrix* matrix);
1734aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setMatrix(SkMatrix* matrix);
1744aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void concatMatrix(SkMatrix* matrix);
175f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy
1767953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API const Rect& getClipBounds();
1777953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API bool quickReject(float left, float top, float right, float bottom);
1788a4ac610e1aaf04931ac1af54b146a7fc8e66114Romain Guy    bool quickRejectNoScissor(float left, float top, float right, float bottom);
1794aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
180735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    virtual bool clipPath(SkPath* path, SkRegion::Op op);
181735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    virtual bool clipRegion(SkRegion* region, SkRegion::Op op);
182a23eed808a1ae4ec0d818c0a9238385e797fd056Chet Haase    virtual Rect* getClipRect();
183bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
1841271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags,
1851271e2cc80b01d577e9db339459ef0222bb9320dChet Haase            uint32_t level = 0);
186ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase    virtual void outputDisplayList(DisplayList* displayList, uint32_t level = 0);
187486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawLayer(Layer* layer, float x, float y, SkPaint* paint);
188486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
189486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
190486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
191e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy            float srcRight, float srcBottom, float dstLeft, float dstTop,
1925c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            float dstRight, float dstBottom, SkPaint* paint);
193486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint);
194486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
1955a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy            float* vertices, int* colors, SkPaint* paint);
196486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
1974bb942083a0d4db746adf95349108dd8ef842e32Romain Guy            const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
1985c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            float left, float top, float right, float bottom, SkPaint* paint);
199be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    status_t drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
200be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy            const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
201be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy            float left, float top, float right, float bottom, int alpha, SkXfermode::Mode mode);
202486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawColor(int color, SkXfermode::Mode mode);
203486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint);
204486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawRoundRect(float left, float top, float right, float bottom,
20501d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy            float rx, float ry, SkPaint* paint);
206486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint);
207486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint);
208486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawArc(float left, float top, float right, float bottom,
2098b2f5267f16c295f12faab810527cd6311997e34Romain Guy            float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
210486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPath(SkPath* path, SkPaint* paint);
211486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawLines(float* points, int count, SkPaint* paint);
212486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPoints(float* points, int count, SkPaint* paint);
213486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
214325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy            float hOffset, float vOffset, SkPaint* paint);
215486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPosText(const char* text, int bytesCount, int count,
216325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy            const float* positions, SkPaint* paint);
217c25259519f1b74bb62a2b051b74537f073436b5cRomain Guy    virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
218996e57c84368058be793897ebc355b917a59abc2Raph Levien            const float* positions, SkPaint* paint, float length = -1.0f);
219672433d90fab7383cd28beac9d4485b566a90940Romain Guy    virtual status_t drawRects(const float* rects, int count, SkPaint* paint);
22085bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy
2214aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void resetShader();
2224aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setupShader(SkiaShader* shader);
223d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy
2244aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void resetColorFilter();
2254aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setupColorFilter(SkiaColorFilter* filter);
226db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy
2274aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void resetShadow();
2284aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    virtual void setupShadow(float radius, float dx, float dy, int color);
2291e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy
2305ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    virtual void resetPaintFilter();
2315ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    virtual void setupPaintFilter(int clearBits, int setBits);
2325ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy
2335ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    SkPaint* filterPaint(SkPaint* paint);
2345ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy
235672433d90fab7383cd28beac9d4485b566a90940Romain Guy    ANDROID_API bool isCurrentTransformSimple() {
236672433d90fab7383cd28beac9d4485b566a90940Romain Guy        return mSnapshot->transform->isSimple();
237672433d90fab7383cd28beac9d4485b566a90940Romain Guy    }
238672433d90fab7383cd28beac9d4485b566a90940Romain Guy
23917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
24017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Sets the alpha on the current snapshot. This alpha value will be modulated
24117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * with other alpha values when drawing primitives.
24217112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
24317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    void setAlpha(float alpha) {
24417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy        mSnapshot->alpha = alpha;
24517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    }
24617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
24717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
24817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Inserts a named group marker in the stream of GL commands. This marker
24917112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * can be used by tools to group commands into logical groups. A call to
25017112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * this method must always be followed later on by a call to endMark().
25117112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
25213631f3da855f200a151e7837ed9f6b079622b58Romain Guy    void startMark(const char* name) const;
25317112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
25417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
25517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Closes the last group marker opened by startMark().
25617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
25713631f3da855f200a151e7837ed9f6b079622b58Romain Guy    void endMark() const;
25813631f3da855f200a151e7837ed9f6b079622b58Romain Guy
259d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase    /**
260d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * Gets the alpha and xfermode out of a paint object. If the paint is null
261d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * alpha will be 255 and the xfermode will be SRC_OVER. This method does
262d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * not multiply the paint's alpha by the current snapshot's alpha.
263d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     *
264d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * @param paint The paint to extract values from
265d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * @param alpha Where to store the resulting alpha
266d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     * @param mode Where to store the resulting xfermode
267d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase     */
268d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase    static inline void getAlphaAndModeDirect(SkPaint* paint, int* alpha, SkXfermode::Mode* mode) {
269d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase        if (paint) {
270d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            *mode = getXfermode(paint->getXfermode());
271d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase
272d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            // Skia draws using the color's alpha channel if < 255
273d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            // Otherwise, it uses the paint's alpha
274d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            int color = paint->getColor();
275d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            *alpha = (color >> 24) & 0xFF;
276d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            if (*alpha == 255) {
277d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase                *alpha = paint->getAlpha();
278d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            }
279d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase        } else {
280d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            *mode = SkXfermode::kSrcOver_Mode;
281d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase            *alpha = 255;
282d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase        }
283d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase    }
284d15ebf25c595b855f6978d0600218e3ea5f31e92Chet Haase
285e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guyprotected:
286e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    /**
28735643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * Computes the projection matrix, initialize the first snapshot
28835643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * and stores the dimensions of the render target.
28935643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     */
29035643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    void initViewport(int width, int height);
29135643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy
29235643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    /**
2937c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy     * Clears the underlying surface if needed.
2947c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy     */
2957c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    virtual status_t clear(float left, float top, float right, float bottom, bool opaque);
2967c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy
2977c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    /**
29835643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * Call this method after updating a layer during a drawing pass.
29935643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     */
30035643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    void resumeAfterLayer();
30135643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy
30235643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    /**
3038ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * This method is called whenever a stencil buffer is required. Subclasses
3048ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * should override this method and call attachStencilBufferToLayer() on the
3058ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * appropriate layer(s).
3068ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
3078ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    virtual void ensureStencilBuffer();
3088ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
3098ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
3108ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Obtains a stencil render buffer (allocating it if necessary) and
3118ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * attaches it to the specified layer.
3128ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
3138ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void attachStencilBufferToLayer(Layer* layer);
3148ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
3158ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
316e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * Compose the layer defined in the current snapshot with the layer
317e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * defined by the previous snapshot.
318e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     *
319e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * The current snapshot *must* be a layer (flag kFlagIsLayer set.)
320e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     *
321e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * @param curent The current snapshot containing the layer to compose
322e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     * @param previous The previous snapshot to compose the current layer with
323e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy     */
324e2d345ea67e2960b37bfdc0fc8626d1bfa747404Romain Guy    virtual void composeLayer(sp<Snapshot> current, sp<Snapshot> previous);
325694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy
326ada830f639591b99c3e40de22b07296c7932a33fRomain Guy    /**
327f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Marks the specified region as dirty at the specified bounds.
328ada830f639591b99c3e40de22b07296c7932a33fRomain Guy     */
329f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    void dirtyLayerUnchecked(Rect& bounds, Region* region);
330ada830f639591b99c3e40de22b07296c7932a33fRomain Guy
331ada830f639591b99c3e40de22b07296c7932a33fRomain Guy    /**
332f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Returns the current snapshot.
333ada830f639591b99c3e40de22b07296c7932a33fRomain Guy     */
334f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    sp<Snapshot> getSnapshot() {
335f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy        return mSnapshot;
336f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    }
337ada830f639591b99c3e40de22b07296c7932a33fRomain Guy
33842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    /**
33942f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     * Returns the region of the current layer.
34042f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     */
341f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    virtual Region* getRegion() {
342f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy        return mSnapshot->region;
343f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    }
344f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy
34542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    /**
34642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     * Indicates whether rendering is currently targeted at a layer.
34742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     */
348f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    virtual bool hasLayer() {
349f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy        return (mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region;
350f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    }
3511bd1bad0b4a75e633c5edbe802bf6fb4dd765161Romain Guy
35242f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    /**
35342f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     * Returns the name of the FBO this renderer is rendering into.
35442f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy     */
35542f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    virtual GLint getTargetFbo() {
35642f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy        return 0;
35742f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy    }
35842f3a4b7c35dd1ea1922356eb3611af8cde05179Romain Guy
35977a811610f99e21da7f88dafef60d09f345d0506Romain Guy    /**
36077a811610f99e21da7f88dafef60d09f345d0506Romain Guy     * Renders the specified layer as a textured quad.
36177a811610f99e21da7f88dafef60d09f345d0506Romain Guy     *
36277a811610f99e21da7f88dafef60d09f345d0506Romain Guy     * @param layer The layer to render
36377a811610f99e21da7f88dafef60d09f345d0506Romain Guy     * @param rect The bounds of the layer
36477a811610f99e21da7f88dafef60d09f345d0506Romain Guy     */
36577a811610f99e21da7f88dafef60d09f345d0506Romain Guy    void drawTextureLayer(Layer* layer, const Rect& rect);
36677a811610f99e21da7f88dafef60d09f345d0506Romain Guy
367be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    /**
368be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * Gets the alpha and xfermode out of a paint object. If the paint is null
369be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * alpha will be 255 and the xfermode will be SRC_OVER.
370be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     *
371be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * @param paint The paint to extract values from
372be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * @param alpha Where to store the resulting alpha
373be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * @param mode Where to store the resulting xfermode
374be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     */
375be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    inline void getAlphaAndMode(SkPaint* paint, int* alpha, SkXfermode::Mode* mode);
376be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy
377be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    /**
378be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * Safely retrieves the mode from the specified xfermode. If the specified
379be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     * xfermode is null, the mode is assumed to be SkXfermode::kSrcOver_Mode.
380be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy     */
381be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    static inline SkXfermode::Mode getXfermode(SkXfermode* mode) {
382be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        SkXfermode::Mode resultMode;
383be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        if (!SkXfermode::AsMode(mode, &resultMode)) {
384be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy            resultMode = SkXfermode::kSrcOver_Mode;
385be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        }
386be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy        return resultMode;
387be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy    }
388be6f9dc1e71b425b7ac1c40c0a2c72d03eb9fbeeRomain Guy
38911cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    /**
39011cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy     * Set to true to suppress error checks at the end of a frame.
39111cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy     */
39211cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    virtual bool suppressErrorChecks() {
39311cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy        return false;
39411cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    }
39511cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy
3967c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    Caches& getCaches() {
3977c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy        return mCaches;
3987c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    }
3997c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy
40008ae317c21ec3086b5017672bba87420cc38a407Romain Guyprivate:
4015cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
402dcfc836b457a87881da409e1acf251515f121446Romain Guy     * Discards the content of the framebuffer if supported by the driver.
403dcfc836b457a87881da409e1acf251515f121446Romain Guy     * This method should be called at the beginning of a frame to optimize
404dcfc836b457a87881da409e1acf251515f121446Romain Guy     * rendering on some tiler architectures.
405dcfc836b457a87881da409e1acf251515f121446Romain Guy     */
406dcfc836b457a87881da409e1acf251515f121446Romain Guy    void discardFramebuffer(float left, float top, float right, float bottom);
407dcfc836b457a87881da409e1acf251515f121446Romain Guy
408dcfc836b457a87881da409e1acf251515f121446Romain Guy    /**
409ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy     * Ensures the state of the renderer is the same as the state of
410ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy     * the GL context.
411ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy     */
412ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy    void syncState();
413ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy
414ddf74373616c89e0880a28a2185fd7ce3db91de6Romain Guy    /**
4152b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * Tells the GPU what part of the screen is about to be redrawn.
416c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * This method will use the clip rect that we started drawing the
417c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * frame with.
4182b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * This method needs to be invoked every time getTargetFbo() is
4192b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * bound again.
4202b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     */
42157b5268708c3b974296c7d4e58a02a957979224aRomain Guy    void startTiling(const sp<Snapshot>& snapshot, bool opaque = false);
4222b7028eabac80cec170572bc0e945a1d4224e595Romain Guy
4232b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    /**
424c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * Tells the GPU what part of the screen is about to be redrawn.
425c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * This method needs to be invoked every time getTargetFbo() is
426c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     * bound again.
427c3fedafc5f50100219449125a000e3138f6fb987Romain Guy     */
428c3fedafc5f50100219449125a000e3138f6fb987Romain Guy    void startTiling(const Rect& clip, int windowHeight, bool opaque = false);
429c3fedafc5f50100219449125a000e3138f6fb987Romain Guy
430c3fedafc5f50100219449125a000e3138f6fb987Romain Guy    /**
4312b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * Tells the GPU that we are done drawing the frame or that we
4322b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     * are switching to another render target.
4332b7028eabac80cec170572bc0e945a1d4224e595Romain Guy     */
4342b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    void endTiling();
4352b7028eabac80cec170572bc0e945a1d4224e595Romain Guy
4362b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    /**
4375cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Saves the current state of the renderer as a new snapshot.
4385cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * The new snapshot is saved in mSnapshot and the previous snapshot
4395cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * is linked from mSnapshot->previous.
4405cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
4418aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy     * @param flags The save flags; see SkCanvas for more information
4428aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy     *
4435cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @return The new save count. This value can be passed to #restoreToCount()
4445cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
4458aef54fa17f2a3753d9a8f2027629bc480088f69Romain Guy    int saveSnapshot(int flags);
4465cbbce535744b89df5ecea95de21ee3733298260Romain Guy
4475cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
4485cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Restores the current snapshot; mSnapshot becomes mSnapshot->previous.
4495cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
4502542d199745cdf3ec910b8e3e4cff5851ed24e9bRomain Guy     * @return True if the clip was modified.
4515cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
452bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    bool restoreSnapshot();
453bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
4545cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
4555cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Sets the clipping rectangle using glScissor. The clip is defined by
4565cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * the current snapshot's clipRect member.
4575cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
458bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    void setScissorFromClip();
459bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
4605cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
4618ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Sets the clipping region using the stencil buffer. The clip region
4628ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * is defined by the current snapshot's clipRegion member.
4638ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
4648ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void setStencilFromClip();
4658ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
4668ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
46735643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * Performs a quick reject but does not affect the scissor. Returns
46835643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     * the transformed rect to test and the current clip.
46935643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy     */
47035643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    bool quickRejectNoScissor(float left, float top, float right, float bottom,
47135643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy            Rect& transformed, Rect& clip);
47235643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy
47335643ddc689913f5b5f80ceed864470d987bd6cdRomain Guy    /**
474cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik     * Performs a quick reject but adjust the bounds to account for stroke width if necessary
475cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik     */
476cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik    bool quickRejectPreStroke(float left, float top, float right, float bottom, SkPaint* paint);
477cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik
478cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik    /**
479d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * Creates a new layer stored in the specified snapshot.
480d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     *
481d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param snapshot The snapshot associated with the new layer
482d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param left The left coordinate of the layer
483d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param top The top coordinate of the layer
484d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param right The right coordinate of the layer
485d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param bottom The bottom coordinate of the layer
486d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param alpha The translucency of the layer
487d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param mode The blending mode of the layer
488d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param flags The layer save flags
489eb99356a0548684a501766e6a524529ab93304c8Romain Guy     * @param previousFbo The name of the current framebuffer
490d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     *
491d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @return True if the layer was successfully created, false otherwise
492d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     */
493d48885a6c8cd27a8a62552c33b5282e9882e19f6Chet Haase    bool createLayer(float left, float top, float right, float bottom,
494eb99356a0548684a501766e6a524529ab93304c8Romain Guy            int alpha, SkXfermode::Mode mode, int flags, GLuint previousFbo);
495d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy
496d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy    /**
4975b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * Creates a new layer stored in the specified snapshot as an FBO.
4985b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     *
4995b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param layer The layer to store as an FBO
5005b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param snapshot The snapshot associated with the new layer
5015b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param bounds The bounds of the layer
5025b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param previousFbo The name of the current framebuffer
5035b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     */
504d48885a6c8cd27a8a62552c33b5282e9882e19f6Chet Haase    bool createFboLayer(Layer* layer, Rect& bounds, Rect& clip, GLuint previousFbo);
5055b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy
5065b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    /**
5075b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * Compose the specified layer as a region.
5085b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     *
5095b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param layer The layer to compose
5105b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param rect The layer's bounds
5115b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     */
5125b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    void composeLayerRegion(Layer* layer, const Rect& rect);
5135b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy
5145b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    /**
5155b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * Compose the specified layer as a simple rectangle.
5165b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     *
5175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param layer The layer to compose
5185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param rect The layer's bounds
5195b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param swap If true, the source and destination are swapped
5205b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     */
5215b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy    void composeLayerRect(Layer* layer, const Rect& rect, bool swap = false);
5225b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy
52354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
52454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Clears all the regions corresponding to the current list of layers.
52554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * This method MUST be invoked before any drawing operation.
52654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
52754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    void clearLayerRegions();
52854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy
52954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
530f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Mark the layer as dirty at the specified coordinates. The coordinates
531f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * are transformed with the supplied matrix.
532f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     */
533f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    void dirtyLayer(const float left, const float top,
534f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy            const float right, const float bottom, const mat4 transform);
535f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy
536f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    /**
537f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     * Mark the layer as dirty at the specified coordinates.
538f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy     */
539f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    void dirtyLayer(const float left, const float top,
540f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy            const float right, const float bottom);
541f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy
542f219da5e32e85deb442468ee9a63bb28eb198557Romain Guy    /**
5435cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Draws a colored rectangle with the specified color. The specified coordinates
544735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * are transformed by the current snapshot's transform matrix unless specified
545735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * otherwise.
5465cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
5475cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param left The left coordinate of the rectangle
5485cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param top The top coordinate of the rectangle
5495cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param right The right coordinate of the rectangle
5505cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param bottom The bottom coordinate of the rectangle
5515cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param color The rectangle's ARGB color, defined as a packed 32 bits word
552026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param mode The Skia xfermode to use
5533d58c03de0d8877b36cdb78b0ca8b5cac7f600e2Romain Guy     * @param ignoreTransform True if the current transform should be ignored
5545cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
555026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    void drawColorRect(float left, float top, float right, float bottom,
5561c740bce8a762f02b5283045a0e2de7c8fb41277Romain Guy            int color, SkXfermode::Mode mode, bool ignoreTransform = false);
5575cbbce535744b89df5ecea95de21ee3733298260Romain Guy
55854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
559735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * Draws a series of colored rectangles with the specified color. The specified
560735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * coordinates are transformed by the current snapshot's transform matrix unless
561735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * specified otherwise.
562735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     *
563735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param rects A list of rectangles, 4 floats (left, top, right, bottom)
564735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     *              per rectangle
565735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param color The rectangles' ARGB color, defined as a packed 32 bits word
566735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param mode The Skia xfermode to use
567735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     * @param ignoreTransform True if the current transform should be ignored
5688ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * @param dirty True if calling this method should dirty the current layer
5693bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy     * @param clip True if the rects should be clipped, false otherwise
570735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy     */
571735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    status_t drawColorRects(const float* rects, int count, int color,
5723bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy            SkXfermode::Mode mode, bool ignoreTransform = false,
5733bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy            bool dirty = true, bool clip = true);
574735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy
575735738c4ddf3229caa5f6e634bf591953ac29944Romain Guy    /**
57654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Draws the shape represented by the specified path texture.
57754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * This method invokes drawPathTexture() but takes into account
57854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * the extra left/top offset and the texture offset to correctly
57954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * position the final shape.
58054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
58154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param left The left coordinate of the shape to render
58254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param top The top coordinate of the shape to render
58354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param texture The texture reprsenting the shape
58454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param paint The paint to draw the shape with
58554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
586486590963e2207d68eebd6944fec70d50d41116aChet Haase    status_t drawShape(float left, float top, const PathTexture* texture, SkPaint* paint);
58754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy
58854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
58954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Draws the specified texture as an alpha bitmap. Alpha bitmaps obey
59054be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * different compositing rules.
59154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
59254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param texture The texture to draw with
59354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param left The x coordinate of the bitmap
59454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param top The y coordinate of the bitmap
59554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param paint The paint to render with
59654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
597a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy    void drawAlphaBitmap(Texture* texture, float left, float top, SkPaint* paint);
598a168d7372132d6c87835878794b6ed43d0d282fdRomain Guy
59954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
600710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik     * Renders the convex hull defined by the specified path as a strip of polygons.
60154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
602710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik     * @param path The hull of the path to draw
603cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik     * @param paint The paint to render with
60454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
605cb4d6009576cf08195dc23f341a3f4939c0878bbChris Craik    void drawConvexPath(const SkPath& path, SkPaint* paint);
606858aa93ddb6e69e0503382af63bb681b6728aef1Chet Haase
6075cbbce535744b89df5ecea95de21ee3733298260Romain Guy    /**
6085cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * Draws a textured rectangle with the specified texture. The specified coordinates
6095cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * are transformed by the current snapshot's transform matrix.
6105cbbce535744b89df5ecea95de21ee3733298260Romain Guy     *
6115cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param left The left coordinate of the rectangle
6125cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param top The top coordinate of the rectangle
6135cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param right The right coordinate of the rectangle
6145cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param bottom The bottom coordinate of the rectangle
6155cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param texture The texture name to map onto the rectangle
6165cbbce535744b89df5ecea95de21ee3733298260Romain Guy     * @param alpha An additional translucency parameter, between 0.0f and 1.0f
617d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy     * @param mode The blending mode
618c1396e93b6a5286a5183c00c781b62e940a12c1fRomain Guy     * @param blend True if the texture contains an alpha channel
6195cbbce535744b89df5ecea95de21ee3733298260Romain Guy     */
620bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy    void drawTextureRect(float left, float top, float right, float bottom, GLuint texture,
621a979474f15b454c8e2963f239a3770e200bb227cRomain Guy            float alpha, SkXfermode::Mode mode, bool blend);
622c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy
623026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    /**
62482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * Draws a textured rectangle with the specified texture. The specified coordinates
62582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * are transformed by the current snapshot's transform matrix.
62682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     *
62782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param left The left coordinate of the rectangle
62882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param top The top coordinate of the rectangle
62982ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param right The right coordinate of the rectangle
63082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param bottom The bottom coordinate of the rectangle
63182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param texture The texture to use
63282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param paint The paint containing the alpha, blending mode, etc.
63382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     */
634a979474f15b454c8e2963f239a3770e200bb227cRomain Guy    void drawTextureRect(float left, float top, float right, float bottom,
6358164c2d338781c3a3c4a443941070dca5d88f2a7Romain Guy            Texture* texture, SkPaint* paint);
63682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy
63782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy    /**
63803750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * Draws a textured mesh with the specified texture. If the indices are omitted,
63903750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * the mesh is drawn as a simple quad. The mesh pointers become offsets when a
64003750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * VBO is bound.
64182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     *
64282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param left The left coordinate of the rectangle
64382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param top The top coordinate of the rectangle
64482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param right The right coordinate of the rectangle
64582ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param bottom The bottom coordinate of the rectangle
64682ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param texture The texture name to map onto the rectangle
64782ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param alpha An additional translucency parameter, between 0.0f and 1.0f
64882ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param mode The blending mode
64982ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param blend True if the texture contains an alpha channel
65082ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param vertices The vertices that define the mesh
65182ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param texCoords The texture coordinates of each vertex
65282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * @param elementsCount The number of elements in the mesh, required by indices
653f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy     * @param swapSrcDst Whether or not the src and dst blending operations should be swapped
654f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy     * @param ignoreTransform True if the current transform should be ignored
65503750a067e818ca7fbd0f590e2ff6a8fded21e6cRomain Guy     * @param vbo The VBO used to draw the mesh
6565b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param ignoreScale True if the model view matrix should not be scaled
6575b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy     * @param dirty True if calling this method should dirty the current layer
658f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy     */
659f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy    void drawTextureMesh(float left, float top, float right, float bottom, GLuint texture,
660a979474f15b454c8e2963f239a3770e200bb227cRomain Guy            float alpha, SkXfermode::Mode mode, bool blend,
6616820ac8b14b4558f5d8b833dde80895306a3e137Romain Guy            GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
6625b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy            bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0,
6635b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy            bool ignoreScale = false, bool dirty = true);
664f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy
665886b275e529e44a59c54b933453d9bc902973178Romain Guy    void drawAlpha8TextureMesh(float left, float top, float right, float bottom,
666886b275e529e44a59c54b933453d9bc902973178Romain Guy            GLuint texture, bool hasColor, int color, int alpha, SkXfermode::Mode mode,
667886b275e529e44a59c54b933453d9bc902973178Romain Guy            GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
668886b275e529e44a59c54b933453d9bc902973178Romain Guy            bool ignoreTransform, bool dirty = true);
669886b275e529e44a59c54b933453d9bc902973178Romain Guy
670f7f93556c8fcc640ab5adef79d021a80a72a645aRomain Guy    /**
6710a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * Draws text underline and strike-through if needed.
6720a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     *
6730a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param text The text to decor
6740a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param bytesCount The number of bytes in the text
6750a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param length The length in pixels of the text, can be <= 0.0f to force a measurement
6760a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param x The x coordinate where the text will be drawn
6770a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param y The y coordinate where the text will be drawn
6780a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     * @param paint The paint to draw the text with
6790a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy     */
6800a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy    void drawTextDecorations(const char* text, int bytesCount, float length,
6810a41749953f35d33f61b3119e3161a82bb5fa59eRomain Guy            float x, float y, SkPaint* paint);
6821e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy
683416a847633680d94efb926837efdc18726d54918Raph Levien   /**
684416a847633680d94efb926837efdc18726d54918Raph Levien     * Draws shadow layer on text (with optional positions).
685416a847633680d94efb926837efdc18726d54918Raph Levien     *
686416a847633680d94efb926837efdc18726d54918Raph Levien     * @param paint The paint to draw the shadow with
687416a847633680d94efb926837efdc18726d54918Raph Levien     * @param text The text to draw
688416a847633680d94efb926837efdc18726d54918Raph Levien     * @param bytesCount The number of bytes in the text
689416a847633680d94efb926837efdc18726d54918Raph Levien     * @param count The number of glyphs in the text
690416a847633680d94efb926837efdc18726d54918Raph Levien     * @param positions The x, y positions of individual glyphs (or NULL)
691416a847633680d94efb926837efdc18726d54918Raph Levien     * @param fontRenderer The font renderer object
692416a847633680d94efb926837efdc18726d54918Raph Levien     * @param alpha The alpha value for drawing the shadow
693416a847633680d94efb926837efdc18726d54918Raph Levien     * @param mode The xfermode for drawing the shadow
694416a847633680d94efb926837efdc18726d54918Raph Levien     * @param x The x coordinate where the shadow will be drawn
695416a847633680d94efb926837efdc18726d54918Raph Levien     * @param y The y coordinate where the shadow will be drawn
696416a847633680d94efb926837efdc18726d54918Raph Levien     */
697416a847633680d94efb926837efdc18726d54918Raph Levien    void drawTextShadow(SkPaint* paint, const char* text, int bytesCount, int count,
698416a847633680d94efb926837efdc18726d54918Raph Levien            const float* positions, FontRenderer& fontRenderer, int alpha, SkXfermode::Mode mode,
699416a847633680d94efb926837efdc18726d54918Raph Levien            float x, float y);
700416a847633680d94efb926837efdc18726d54918Raph Levien
70154be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    /**
70254be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * Draws a path texture. Path textures are alpha8 bitmaps that need special
70354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * compositing to apply colors/filters/etc.
70454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     *
70554be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param texture The texture to render
70654be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param x The x coordinate where the texture will be drawn
70754be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param y The y coordinate where the texture will be drawn
70854be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     * @param paint The paint to draw the texture with
70954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy     */
710416a847633680d94efb926837efdc18726d54918Raph Levien     void drawPathTexture(const PathTexture* texture, float x, float y, SkPaint* paint);
71101d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy
7121e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    /**
713ac670c0433d19397d4e36ced2110475b6f54fe26Romain Guy     * Resets the texture coordinates stored in mMeshVertices. Setting the values
714026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * back to default is achieved by calling:
715026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     *
7168ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy     * resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f);
717026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     *
718026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param u1 The left coordinate of the texture
719026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param v1 The bottom coordinate of the texture
720026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param u2 The right coordinate of the texture
721026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     * @param v2 The top coordinate of the texture
722026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy     */
723026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    void resetDrawTextureTexCoords(float u1, float v1, float u2, float v2);
724026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy
7258ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy    /**
726746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * Binds the specified texture. The texture unit must have been selected
727746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * prior to calling this method.
728a1db574036c9bc2d397b69f8200594027e1fff16Romain Guy     */
729746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    inline void bindTexture(GLuint texture) {
730746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy        glBindTexture(GL_TEXTURE_2D, texture);
731746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    }
732746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
733746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    /**
734aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy     * Binds the specified EGLImage texture. The texture unit must have been selected
735aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy     * prior to calling this method.
736aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy     */
737aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    inline void bindExternalTexture(GLuint texture) {
738aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy        glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);
739aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    }
740aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy
741aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    /**
74282ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * Enable or disable blending as necessary. This function sets the appropriate
74382ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     * blend function based on the specified xfermode.
74482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy     */
745f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy    inline void chooseBlending(bool blend, SkXfermode::Mode mode, ProgramDescription& description,
746f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy            bool swapSrcDst = false);
747a5aed0d58962a24c44728ffc46dc9e1ba2f9fda5Romain Guy
748f607bdc167f66b3e7003acaa4736ae46d78c1492Romain Guy    /**
749d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * Use the specified program with the current GL context. If the program is already
750d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * in use, it will not be bound again. If it is not in use, the current program is
751d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * marked unused and the specified program becomes used and becomes the new
752d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * current program.
7536926c72e25b8dec3dd4b84af0819fa1937ae7296Romain Guy     *
754d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * @param program The program to use
755d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     *
756d27977d1a91d5a6b3cc9fa7664ac7e835e7bd895Romain Guy     * @return true If the specified program was already in use, false otherwise.
757260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy     */
758889f8d1403761d5668115ced6cbb3f767cfe966dRomain Guy    inline bool useProgram(Program* program);
759260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy
760746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    /**
761746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * Invoked before any drawing operation. This sets required state.
762746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     */
76354be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    void setupDraw(bool clear = true);
76417112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy
76570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    /**
76670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy     * Various methods to setup OpenGL rendering.
76770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy     */
76870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawWithTexture(bool isAlpha8 = false);
769aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    void setupDrawWithExternalTexture();
77015bc6437f8b4cf10dba55c7638d349e7b9563f4fRomain Guy    void setupDrawNoTexture();
771710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik    void setupDrawAA();
772710f46d9d6a5bf9ea1c1833384caf61e1934124fChris Craik    void setupDrawVertexShape();
773ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy    void setupDrawPoint(float pointSize);
7748d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy    void setupDrawColor(int color, int alpha);
77570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColor(float r, float g, float b, float a);
77686568198f2c83d4ce5c4cd692eda074ba9de9ed2Romain Guy    void setupDrawAlpha8Color(int color, int alpha);
7774121063313ac0d6f69f6253cac821d0c1c122086Romain Guy    void setupDrawTextGamma(const SkPaint* paint);
77870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawShader();
77970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColorFilter();
78070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawBlending(SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
78170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool swapSrcDst = false);
78270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawBlending(bool blend = true, SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
78370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool swapSrcDst = false);
78470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawProgram();
78570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawDirtyRegionsDisabled();
7868a5cc92a150bae38ec43732d941b38bb381fe153Chet Haase    void setupDrawModelViewIdentity(bool offset = false);
78770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawModelView(float left, float top, float right, float bottom,
78870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool ignoreTransform = false, bool ignoreModelView = false);
78970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawModelViewTranslate(float left, float top, float right, float bottom,
79070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy            bool ignoreTransform = false);
791ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy    void setupDrawPointUniforms();
79270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColorUniforms();
79386568198f2c83d4ce5c4cd692eda074ba9de9ed2Romain Guy    void setupDrawPureColorUniforms();
7948d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy    void setupDrawShaderIdentityUniforms();
79570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawShaderUniforms(bool ignoreTransform = false);
79670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawColorFilterUniforms();
79770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawSimpleMesh();
79870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void setupDrawTexture(GLuint texture);
799aa6c24c21c727a196451332448d4e3b11a80be69Romain Guy    void setupDrawExternalTexture(GLuint texture);
8008f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy    void setupDrawTextureTransform();
8018f0095cd33558e9cc8a440047908e53b68906f5fRomain Guy    void setupDrawTextureTransformUniforms(mat4& transform);
8024121063313ac0d6f69f6253cac821d0c1c122086Romain Guy    void setupDrawTextGammaUniforms();
8038d0d4783a0206c5884bf0b958d181f450ba5207dRomain Guy    void setupDrawMesh(GLvoid* vertices, GLvoid* texCoords = NULL, GLuint vbo = 0);
80415bc6437f8b4cf10dba55c7638d349e7b9563f4fRomain Guy    void setupDrawMeshIndices(GLvoid* vertices, GLvoid* texCoords);
8055b0200bd47e8a9a4dc8d2e6c3a110d522b30bf82Chet Haase    void setupDrawVertices(GLvoid* vertices);
80699585adeb4167ca357a72eb866f34c1af944f4b9Chet Haase    void setupDrawAALine(GLvoid* vertices, GLvoid* distanceCoords, GLvoid* lengthCoords,
8077b63142d2f4bc32beacedcc761453b8aea1f3a86Romain Guy            float strokeWidth, int& widthSlot, int& lengthSlot);
8087b63142d2f4bc32beacedcc761453b8aea1f3a86Romain Guy    void finishDrawAALine(const int widthSlot, const int lengthSlot);
80970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    void finishDrawTexture();
810f09ef51889f75289b041f9e9f949b7b82ed5b686Romain Guy    void accountForClear(SkXfermode::Mode mode);
811746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
81211cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    bool updateLayer(Layer* layer, bool inFrame);
81311cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    void updateLayers();
81411cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy
81517112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy    /**
81617112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * Renders the specified region as a series of rectangles. This method
81717112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     * is used for debugging only.
81817112ad8a21a77620eb1ff14dcf8bdd6b7859712Romain Guy     */
8193a3133d876caf60ebff2176ad75c3dcf0259148dRomain Guy    void drawRegionRects(const Region& region);
8203a3133d876caf60ebff2176ad75c3dcf0259148dRomain Guy
8218ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
8228ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Renders the specified region as a series of rectangles. The region
8238ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * must be in screen-space coordinates.
8248ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
8258ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void drawRegionRects(const SkRegion& region, int color, SkXfermode::Mode mode,
8268ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy            bool dirty = false);
8278ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
8288ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    /**
8298ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * Draws the current clip region if any. Only when DEBUG_CLIP_REGIONS
8308ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     * is turned on.
8318ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy     */
8328ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy    void debugClip();
8338ce00301a023eecaeb8891ce906f67b513ebb42aRomain Guy
8347c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy    void debugOverdraw(bool enable, bool clear);
8357c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy    void renderOverdraw();
8367c450aaa3caac2a05fcb20a177483d0e92378426Romain Guy
837746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    /**
838746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     * Should be invoked every time the glScissor is modified.
839746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy     */
840746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    inline void dirtyClip() {
841746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy        mDirtyClip = true;
842746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    }
843746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
844bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    // Dimensions of the drawing surface
845bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    int mWidth, mHeight;
846bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
84785bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy    // Matrix used for ortho projection in shaders
848260e102162322958cf17dbd895cd6bd30dc87e32Romain Guy    mat4 mOrthoMatrix;
849bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy
850c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy    // Model-view matrix used to position/size objects
851c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy    mat4 mModelView;
852c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy
853bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    // Number of saved states
854bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    int mSaveCount;
855f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy    // Base state
856ae5575b3421c8fbe590ab046d7d5f2b36ecfd821Romain Guy    sp<Snapshot> mFirstSnapshot;
857bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    // Current state
858bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy    sp<Snapshot> mSnapshot;
8592b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    // State used to define the clipping region
8602b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    sp<Snapshot> mTilingSnapshot;
8619d5316e3f56d138504565ff311145ac01621dff4Romain Guy
8629d5316e3f56d138504565ff311145ac01621dff4Romain Guy    // Shaders
86306f96e2652e4855b6520ad9dd70583677605b79aRomain Guy    SkiaShader* mShader;
864026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy
865db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy    // Color filters
866db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy    SkiaColorFilter* mColorFilter;
867db1938e0e6ef816e228c815adccebd5cb05f2aa8Romain Guy
868026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy    // Used to draw textured quads
869ac670c0433d19397d4e36ced2110475b6f54fe26Romain Guy    TextureVertex mMeshVertices[4];
870ce0537b80087a6225273040a987414b1dd081aa0Romain Guy
8711e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    // Drop shadow
8721e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    bool mHasShadow;
8731e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    float mShadowRadius;
8741e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    float mShadowDx;
8751e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    float mShadowDy;
8761e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy    int mShadowColor;
8771e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy
8785ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    // Draw filters
8795ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    bool mHasDrawFilter;
8805ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    int mPaintFilterClearBits;
8815ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    int mPaintFilterSetBits;
8825ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    SkPaint mFilteredPaint;
8835ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy
88482ba814ca0dea659be2cc6523bc0137679d961ceRomain Guy    // Various caches
885fb8b763f762ae21923c58d64caa729b012f40e05Romain Guy    Caches& mCaches;
8863bbacf27c0be1bae4e4483577fc89ae3113abe5dRomain Guy    Extensions& mExtensions;
8878694230ff25fa0a60e480d424843e56b718f0516Romain Guy
8888f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    // List of rectangles to clear after saveLayer() is invoked
88954be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy    Vector<Rect*> mLayers;
8908f3b8e32993d190a26c70c839a63d8ce4c3b16d9Romain Guy    // List of functors to invoke after a frame is drawn
891ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47Romain Guy    SortedVector<Functor*> mFunctors;
89211cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    // List of layers to update at the beginning of a frame
89311cb642756093a4af901b1525375b1eb2b5c3e2bRomain Guy    Vector<Layer*> mLayerUpdates;
89454be1cdf3d63095512120fa7ced5c16e462abffaRomain Guy
89599bcdc52dcb365ed7d8cfa13540fb33fbcbbac9dRomain Guy    // Indentity matrix
89699bcdc52dcb365ed7d8cfa13540fb33fbcbbac9dRomain Guy    const mat4 mIdentity;
89799bcdc52dcb365ed7d8cfa13540fb33fbcbbac9dRomain Guy
898746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    // Indicates whether the clip must be restored
899746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy    bool mDirtyClip;
900746b7401ceb86b5f2805f8c0d3b39ac739152015Romain Guy
90170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // The following fields are used to setup drawing
90270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Used to describe the shaders to generate
90370ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    ProgramDescription mDescription;
90470ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Color description
90570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    bool mColorSet;
90670ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    float mColorA, mColorR, mColorG, mColorB;
90770ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Indicates that the shader should get a color
90870ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    bool mSetShaderColor;
90970ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Current texture unit
91070ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    GLuint mTextureUnit;
91170ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    // Track dirty regions, true by default
91270ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy    bool mTrackDirtyRegions;
9132b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    // Indicate whether we are drawing an opaque frame
9142b7028eabac80cec170572bc0e945a1d4224e595Romain Guy    bool mOpaqueFrame;
91570ca14e08ae197547ac412e8a1210e1ebdfb2eb1Romain Guy
91687e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    // See PROPERTY_DISABLE_SCISSOR_OPTIMIZATION in
91787e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    // Properties.h
91887e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy    bool mScissorOptimizationDisabled;
91987e2f757be9b24d369bab354e37c276e851b1fc7Romain Guy
92054c1a64d5441a964890b44280e4457e11f4f924aRomain Guy    // No-ops start/endTiling when set
92154c1a64d5441a964890b44280e4457e11f4f924aRomain Guy    bool mSuppressTiling;
92254c1a64d5441a964890b44280e4457e11f4f924aRomain Guy
923ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    // Optional name of the renderer
924ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy    String8 mName;
925ef35927abcd089652f87a985dd6dde7afde58b92Romain Guy
926b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    friend class DisplayListRenderer;
927b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
928bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy}; // class OpenGLRenderer
929e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
9309d5316e3f56d138504565ff311145ac01621dff4Romain Guy}; // namespace uirenderer
931e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy}; // namespace android
932e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy
9335b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#endif // ANDROID_HWUI_OPENGL_RENDERER_H
934