14aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy/*
24aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * Copyright (C) 2010 The Android Open Source Project
34aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy *
44aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * Licensed under the Apache License, Version 2.0 (the "License");
54aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * you may not use this file except in compliance with the License.
64aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * You may obtain a copy of the License at
74aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy *
84aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy *      http://www.apache.org/licenses/LICENSE-2.0
94aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy *
104aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * Unless required by applicable law or agreed to in writing, software
114aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * distributed under the License is distributed on an "AS IS" BASIS,
124aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * See the License for the specific language governing permissions and
144aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy * limitations under the License.
154aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy */
164aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#ifndef ANDROID_HWUI_DISPLAY_LIST_RENDERER_H
185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#define ANDROID_HWUI_DISPLAY_LIST_RENDERER_H
194aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
204aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkChunkAlloc.h>
214aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkFlattenable.h>
224aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkMatrix.h>
23a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase#include <SkCamera.h>
244aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkPaint.h>
254aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkPath.h>
264aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkRefCnt.h>
274aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkTDArray.h>
284aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include <SkTSearch.h>
294aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
307953745dd565167113f8cbfc461bc0521d32d870Romain Guy#include <cutils/compiler.h>
317953745dd565167113f8cbfc461bc0521d32d870Romain Guy
329c1e23baf5bfbebd1aebbd6d9a18c225325567ceChet Haase#include "DisplayListLogBuffer.h"
334aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy#include "OpenGLRenderer.h"
344aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
354aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guynamespace android {
364aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guynamespace uirenderer {
374aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
384aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy///////////////////////////////////////////////////////////////////////////////
394aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy// Defines
404aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy///////////////////////////////////////////////////////////////////////////////
414aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
426d7475d666baefaa3ba9f0dcee25238739454241Romain Guy#define MIN_WRITER_SIZE 4096
4333f6beb10f98e8ba96250e284876d607055d278dRomain Guy#define OP_MAY_BE_SKIPPED_MASK 0xff000000
444aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
45ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy// Debug
46ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy#if DEBUG_DISPLAY_LIST
475baa3a62a97544669fba6d65a11c07f252e654ddSteve Block    #define DISPLAY_LIST_LOGD(...) ALOGD(__VA_ARGS__)
48ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy#else
49ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy    #define DISPLAY_LIST_LOGD(...)
50ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy#endif
51ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy
52a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase#define TRANSLATION 0x0001
53a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase#define ROTATION    0x0002
54a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase#define ROTATION_3D 0x0004
55a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase#define SCALE       0x0008
56a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase#define PIVOT       0x0010
57a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
584aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy///////////////////////////////////////////////////////////////////////////////
59b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy// Display list
604aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy///////////////////////////////////////////////////////////////////////////////
614aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
62b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guyclass DisplayListRenderer;
63b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
644aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy/**
65b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy * Replays recorded drawing commands.
664aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy */
67b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guyclass DisplayList {
684aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guypublic:
69b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    DisplayList(const DisplayListRenderer& recorder);
707953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API ~DisplayList();
714aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
72ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy    // IMPORTANT: Update the intialization of OP_NAMES in the .cpp file
73ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy    //            when modifying this file
744aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    enum Op {
7504c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy        // Non-drawing operations
762b1847ea60650a9f68372abe860415f18b55081dRomain Guy        Save = 0,
774aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        Restore,
784aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        RestoreToCount,
794aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        SaveLayer,
805b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy        SaveLayerAlpha,
814aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        Translate,
824aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        Rotate,
834aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        Scale,
84807daf7df615b60ce6fc41355aabe3aa353cebabRomain Guy        Skew,
854aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        SetMatrix,
864aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        ConcatMatrix,
874aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        ClipRect,
8804c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy        // Drawing operations
890fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guy        DrawDisplayList,
906c319ca1275c8db892c39b48fc54864c949f9171Romain Guy        DrawLayer,
914aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawBitmap,
924aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawBitmapMatrix,
934aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawBitmapRect,
94e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy        DrawBitmapData,
955a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy        DrawBitmapMesh,
964aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawPatch,
974aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawColor,
984aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawRect,
9901d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy        DrawRoundRect,
10001d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy        DrawCircle,
101c1cd9ba335b293f11e1082447ef08e474710a05fRomain Guy        DrawOval,
1028b2f5267f16c295f12faab810527cd6311997e34Romain Guy        DrawArc,
1034aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawPath,
1044aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        DrawLines,
105ed6fcb034b44d9a6ac2fc72fee6030417811f234Romain Guy        DrawPoints,
106325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy        DrawTextOnPath,
107eb9a5367e8f0e970db8509ffb2584f5376bc62edRomain Guy        DrawPosText,
108c25259519f1b74bb62a2b051b74537f073436b5cRomain Guy        DrawText,
1094aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        ResetShader,
1104aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        SetupShader,
1114aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        ResetColorFilter,
1124aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        SetupColorFilter,
1134aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        ResetShadow,
114ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy        SetupShadow,
1155ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy        ResetPaintFilter,
1165ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy        SetupPaintFilter,
117daf98e941e140e8739458126640183b9f296a2abChet Haase        DrawGLFunction,
1184aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    };
1194aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
12033f6beb10f98e8ba96250e284876d607055d278dRomain Guy    // See flags defined in DisplayList.java
12133f6beb10f98e8ba96250e284876d607055d278dRomain Guy    enum ReplayFlag {
12233f6beb10f98e8ba96250e284876d607055d278dRomain Guy        kReplayFlag_ClipChildren = 0x1
12333f6beb10f98e8ba96250e284876d607055d278dRomain Guy    };
12433f6beb10f98e8ba96250e284876d607055d278dRomain Guy
125ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy    static const char* OP_NAMES[];
126ffac7fc5042296a459d0f5a450dbfe20917093dcRomain Guy
1271271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    void setViewProperties(OpenGLRenderer& renderer, uint32_t level);
128a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void outputViewProperties(OpenGLRenderer& renderer, char* indent);
129a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
1307953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API size_t getSize();
131bb0acdf9e1d862a7cf0e2533321fc1105c29b5e3Romain Guy    ANDROID_API static void destroyDisplayListDeferred(DisplayList* displayList);
132bb0acdf9e1d862a7cf0e2533321fc1105c29b5e3Romain Guy    ANDROID_API static void outputLogBuffer(int fd);
133bb0acdf9e1d862a7cf0e2533321fc1105c29b5e3Romain Guy
134bb0acdf9e1d862a7cf0e2533321fc1105c29b5e3Romain Guy    void initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing = false);
13565b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy
1361271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    status_t replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level = 0);
137b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
138ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase    void output(OpenGLRenderer& renderer, uint32_t level = 0);
139ed30fd8e9a2d65ee5c8520de55b0089c219f390cChet Haase
1406a2d17f71342f981c9df1dc5beff33e30eb3ae2bChet Haase    ANDROID_API void reset();
1416a2d17f71342f981c9df1dc5beff33e30eb3ae2bChet Haase
14204c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy    void setRenderable(bool renderable) {
14304c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy        mIsRenderable = renderable;
14404c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy    }
14504c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy
14604c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy    bool isRenderable() const {
14704c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy        return mIsRenderable;
14804c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy    }
14904c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy
15013631f3da855f200a151e7837ed9f6b079622b58Romain Guy    void setName(const char* name) {
15113631f3da855f200a151e7837ed9f6b079622b58Romain Guy        if (name) {
15213631f3da855f200a151e7837ed9f6b079622b58Romain Guy            mName.setTo(name);
15313631f3da855f200a151e7837ed9f6b079622b58Romain Guy        }
15413631f3da855f200a151e7837ed9f6b079622b58Romain Guy    }
15513631f3da855f200a151e7837ed9f6b079622b58Romain Guy
156a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setClipChildren(bool clipChildren) {
157a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mClipChildren = clipChildren;
158a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
159a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
1609420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase    void setStaticMatrix(SkMatrix* matrix) {
1619420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase        delete mStaticMatrix;
1629420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase        mStaticMatrix = new SkMatrix(*matrix);
1639420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase    }
1649420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase
1659420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase    void setAnimationMatrix(SkMatrix* matrix) {
1669420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase        delete mAnimationMatrix;
1679420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase        if (matrix) {
1689420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase            mAnimationMatrix = new SkMatrix(*matrix);
1699420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase        } else {
1709420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase            mAnimationMatrix = NULL;
1719420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase        }
1729420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase    }
1739420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase
174a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setAlpha(float alpha) {
175f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy        alpha = fminf(1.0f, fmaxf(0.0f, alpha));
176a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (alpha != mAlpha) {
177a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mAlpha = alpha;
178f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy            mMultipliedAlpha = (int) (255 * alpha);
179a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
180a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
181a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
182db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase    void setHasOverlappingRendering(bool hasOverlappingRendering) {
183db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase        mHasOverlappingRendering = hasOverlappingRendering;
184db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase    }
185db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase
186a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setTranslationX(float translationX) {
187a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (translationX != mTranslationX) {
188a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mTranslationX = translationX;
189a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
190f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy            if (mTranslationX == 0.0f && mTranslationY == 0.0f) {
191a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags &= ~TRANSLATION;
192a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            } else {
193a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags |= TRANSLATION;
194a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
195a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
196a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
197a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
198a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setTranslationY(float translationY) {
199a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (translationY != mTranslationY) {
200a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mTranslationY = translationY;
201a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
202f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy            if (mTranslationX == 0.0f && mTranslationY == 0.0f) {
203a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags &= ~TRANSLATION;
204a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            } else {
205a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags |= TRANSLATION;
206a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
207a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
208a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
209a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
210a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setRotation(float rotation) {
211a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (rotation != mRotation) {
212a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mRotation = rotation;
213a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
214f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy            if (mRotation == 0.0f) {
215a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags &= ~ROTATION;
216a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            } else {
217a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags |= ROTATION;
218a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
219a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
220a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
221a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
222a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setRotationX(float rotationX) {
223a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (rotationX != mRotationX) {
224a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mRotationX = rotationX;
225a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
226f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy            if (mRotationX == 0.0f && mRotationY == 0.0f) {
227a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags &= ~ROTATION_3D;
228a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            } else {
229a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags |= ROTATION_3D;
230a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
231a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
232a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
233a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
234a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setRotationY(float rotationY) {
235a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (rotationY != mRotationY) {
236a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mRotationY = rotationY;
237a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
238f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy            if (mRotationX == 0.0f && mRotationY == 0.0f) {
239a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags &= ~ROTATION_3D;
240a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            } else {
241a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags |= ROTATION_3D;
242a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
243a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
244a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
245a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
246a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setScaleX(float scaleX) {
247a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (scaleX != mScaleX) {
248a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mScaleX = scaleX;
249a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
250f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy            if (mScaleX == 1.0f && mScaleY == 1.0f) {
251a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags &= ~SCALE;
252a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            } else {
253a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags |= SCALE;
254a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
255a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
256a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
257a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
258a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setScaleY(float scaleY) {
259a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (scaleY != mScaleY) {
260a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mScaleY = scaleY;
261a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
262d3efd6920e64d0207a0655640297d87d4937ee27Chet Haase            if (mScaleX == 1.0f && mScaleY == 1.0f) {
263a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags &= ~SCALE;
264a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            } else {
265a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixFlags |= SCALE;
266a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
267a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
268a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
269a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
270a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setPivotX(float pivotX) {
271a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mPivotX = pivotX;
272a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mMatrixDirty = true;
273f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy        if (mPivotX == 0.0f && mPivotY == 0.0f) {
274a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixFlags &= ~PIVOT;
275a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        } else {
276a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixFlags |= PIVOT;
277a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
278a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mPivotExplicitlySet = true;
279a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
280a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
281a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setPivotY(float pivotY) {
282a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mPivotY = pivotY;
283a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mMatrixDirty = true;
284f26c8be01bb218619e073a209c9d57fe9d26c517Romain Guy        if (mPivotX == 0.0f && mPivotY == 0.0f) {
285a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixFlags &= ~PIVOT;
286a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        } else {
287a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixFlags |= PIVOT;
288a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
289a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mPivotExplicitlySet = true;
290a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
291a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
292a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setCameraDistance(float distance) {
293a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (distance != mCameraDistance) {
294a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mCameraDistance = distance;
295a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mMatrixDirty = true;
296a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (!mTransformCamera) {
297a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mTransformCamera = new Sk3DView();
298a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mTransformMatrix3D = new SkMatrix();
299a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
300a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mTransformCamera->setCameraLocation(0, 0, distance);
301a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
302a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
303a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
304a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setLeft(int left) {
305a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (left != mLeft) {
306a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mLeft = left;
307a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mWidth = mRight - mLeft;
308a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
309a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
310a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
311a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
312a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
313a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
314a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setTop(int top) {
315a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (top != mTop) {
316a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mTop = top;
317a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mHeight = mBottom - mTop;
318a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
319a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
320a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
321a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
322a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
323a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
324a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setRight(int right) {
325a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (right != mRight) {
326a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mRight = right;
327a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mWidth = mRight - mLeft;
328a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
329a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
330a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
331a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
332a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
333a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
334a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setBottom(int bottom) {
335a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (bottom != mBottom) {
336a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mBottom = bottom;
337a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mHeight = mBottom - mTop;
338a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
339a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
340a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
341a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
342a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
343a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
344a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setLeftTop(int left, int top) {
345a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (left != mLeft || top != mTop) {
346a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mLeft = left;
347a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mTop = top;
348a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mWidth = mRight - mLeft;
349a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mHeight = mBottom - mTop;
350a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
351a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
352a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
353a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
354a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
355a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
356a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setLeftTopRightBottom(int left, int top, int right, int bottom) {
357a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (left != mLeft || top != mTop || right != mRight || bottom != mBottom) {
358a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mLeft = left;
359a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mTop = top;
360a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mRight = right;
361a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mBottom = bottom;
362a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mWidth = mRight - mLeft;
363a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mHeight = mBottom - mTop;
364a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
365a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
366a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
367a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
368a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
369a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
370a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void offsetLeftRight(int offset) {
371a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (offset != 0) {
372a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mLeft += offset;
373a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mRight += offset;
374a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
375a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
376a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
377a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
378a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
379a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
380a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void offsetTopBottom(int offset) {
381a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        if (offset != 0) {
382a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mTop += offset;
383a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            mBottom += offset;
384a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            if (mMatrixFlags > TRANSLATION && !mPivotExplicitlySet) {
385a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase                mMatrixDirty = true;
386a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase            }
387a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        }
388a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
389a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
390a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void setCaching(bool caching) {
391a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase        mCaching = caching;
392a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    }
393a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
3941271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    int getWidth() {
3951271e2cc80b01d577e9db339459ef0222bb9320dChet Haase        return mWidth;
3961271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    }
3971271e2cc80b01d577e9db339459ef0222bb9320dChet Haase
3981271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    int getHeight() {
3991271e2cc80b01d577e9db339459ef0222bb9320dChet Haase        return mHeight;
4001271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    }
4011271e2cc80b01d577e9db339459ef0222bb9320dChet Haase
402b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guyprivate:
403b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    void init();
404a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
405d63cbd10765e8f48e39b07b15f0a4b70bf853ec8Chet Haase    void clearResources();
406d63cbd10765e8f48e39b07b15f0a4b70bf853ec8Chet Haase
407a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    void updateMatrix();
408a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
409b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    class TextContainer {
410b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    public:
411b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        size_t length() const {
412b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy            return mByteLength;
413b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        }
414b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
415b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        const char* text() const {
416b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy            return (const char*) mText;
417b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        }
418b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
419b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        size_t mByteLength;
420b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        const char* mText;
421b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    };
422b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
423b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    SkBitmap* getBitmap() {
4245c13d89c1332fcc499379b9064b891187b75ca32Chet Haase        return (SkBitmap*) getInt();
4255c13d89c1332fcc499379b9064b891187b75ca32Chet Haase    }
4265c13d89c1332fcc499379b9064b891187b75ca32Chet Haase
427e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy    SkBitmap* getBitmapData() {
42849c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy        return (SkBitmap*) getInt();
429e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy    }
430e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy
4315c13d89c1332fcc499379b9064b891187b75ca32Chet Haase    SkiaShader* getShader() {
4325c13d89c1332fcc499379b9064b891187b75ca32Chet Haase        return (SkiaShader*) getInt();
433b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
434b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
435ad93c2bb63dfc813b2eefa1043aa63afbddce655Chet Haase    SkiaColorFilter* getColorFilter() {
436ad93c2bb63dfc813b2eefa1043aa63afbddce655Chet Haase        return (SkiaColorFilter*) getInt();
437ad93c2bb63dfc813b2eefa1043aa63afbddce655Chet Haase    }
438ad93c2bb63dfc813b2eefa1043aa63afbddce655Chet Haase
43933f6beb10f98e8ba96250e284876d607055d278dRomain Guy    inline int32_t getIndex() {
440b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        return mReader.readInt();
441b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
442b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
44333f6beb10f98e8ba96250e284876d607055d278dRomain Guy    inline int32_t getInt() {
444b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        return mReader.readInt();
445b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
446b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
4477b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy    inline uint32_t getUInt() {
4487b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy        return mReader.readU32();
4497b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy    }
4507b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy
451b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    SkMatrix* getMatrix() {
4525c13d89c1332fcc499379b9064b891187b75ca32Chet Haase        return (SkMatrix*) getInt();
453b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
454b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
455b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    SkPath* getPath() {
4562fc941e4650d618ff6e122f28b616d9032ffa134Romain Guy        return (SkPath*) getInt();
457b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
458b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
4595ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    SkPaint* getPaint(OpenGLRenderer& renderer) {
4605ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy        return renderer.filterPaint((SkPaint*) getInt());
461b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
462b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
4630fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guy    DisplayList* getDisplayList() {
4640fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guy        return (DisplayList*) getInt();
4650fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guy    }
4660fe478ea04720a57ef3919dbc23711bc7eba517fRomain Guy
467b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    inline float getFloat() {
468b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        return mReader.readScalar();
469b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
470b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
471b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    int32_t* getInts(uint32_t& count) {
472b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        count = getInt();
473b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        return (int32_t*) mReader.skip(count * sizeof(int32_t));
474b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
475b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
4764bb942083a0d4db746adf95349108dd8ef842e32Romain Guy    uint32_t* getUInts(int8_t& count) {
4774bb942083a0d4db746adf95349108dd8ef842e32Romain Guy        count = getInt();
4784bb942083a0d4db746adf95349108dd8ef842e32Romain Guy        return (uint32_t*) mReader.skip(count * sizeof(uint32_t));
4794bb942083a0d4db746adf95349108dd8ef842e32Romain Guy    }
4804bb942083a0d4db746adf95349108dd8ef842e32Romain Guy
48133f6beb10f98e8ba96250e284876d607055d278dRomain Guy    float* getFloats(int32_t& count) {
482b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        count = getInt();
483b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        return (float*) mReader.skip(count * sizeof(float));
484b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
485b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
486b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    void getText(TextContainer* text) {
487b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        size_t length = text->mByteLength = getInt();
488b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        text->mText = (const char*) mReader.skip(length);
489b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
490b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
4915c13d89c1332fcc499379b9064b891187b75ca32Chet Haase    Vector<SkBitmap*> mBitmapResources;
49249c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy    Vector<SkBitmap*> mOwnedBitmapResources;
493ad93c2bb63dfc813b2eefa1043aa63afbddce655Chet Haase    Vector<SkiaColorFilter*> mFilterResources;
494b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
495d98aa2de9ab18e09c2be1997f41212740f51f6e6Chet Haase    Vector<SkPaint*> mPaints;
4962fc941e4650d618ff6e122f28b616d9032ffa134Romain Guy    Vector<SkPath*> mPaths;
497d34dd71800d9a1077e58c3b7f2511c46848da417Chet Haase    SortedVector<SkPath*> mSourcePaths;
498d98aa2de9ab18e09c2be1997f41212740f51f6e6Chet Haase    Vector<SkMatrix*> mMatrices;
49924c00216687ac87fe531dc4d4168ac0c0ca04ea6Romain Guy    Vector<SkiaShader*> mShaders;
500603f6de35f21d74ae242d52d501f4f5c25ff4f4cChet Haase    Vector<Layer*> mLayers;
501d98aa2de9ab18e09c2be1997f41212740f51f6e6Chet Haase
502b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    mutable SkFlattenableReadBuffer mReader;
50365b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy
50465b345fa22b878e141b8fd8ece9c208df00fa40fRomain Guy    size_t mSize;
50504c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy
50604c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy    bool mIsRenderable;
50754c1a64d5441a964890b44280e4457e11f4f924aRomain Guy    uint32_t mFunctorCount;
50813631f3da855f200a151e7837ed9f6b079622b58Romain Guy
50913631f3da855f200a151e7837ed9f6b079622b58Romain Guy    String8 mName;
510a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase
511a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    // View properties
512a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    bool mClipChildren;
513a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    float mAlpha;
514a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    int mMultipliedAlpha;
515db8c9a6a4d9bf8c39f834b25611926caf21380f6Chet Haase    bool mHasOverlappingRendering;
516a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    float mTranslationX, mTranslationY;
517a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    float mRotation, mRotationX, mRotationY;
518a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    float mScaleX, mScaleY;
519a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    float mPivotX, mPivotY;
520a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    float mCameraDistance;
521a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    int mLeft, mTop, mRight, mBottom;
522a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    int mWidth, mHeight;
523a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    int mPrevWidth, mPrevHeight;
524a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    bool mPivotExplicitlySet;
525a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    bool mMatrixDirty;
526a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    bool mMatrixIsIdentity;
527a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    uint32_t mMatrixFlags;
528a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    SkMatrix* mTransformMatrix;
529a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    Sk3DView* mTransformCamera;
530a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    SkMatrix* mTransformMatrix3D;
5319420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase    SkMatrix* mStaticMatrix;
5329420abd56a2af7ddbeb70562b79d61b2dca8c5a1Chet Haase    SkMatrix* mAnimationMatrix;
533a1cff5043d0fbd78fcf9c48e7658e56a5b0c2de3Chet Haase    bool mCaching;
534b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy};
535b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
536b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy///////////////////////////////////////////////////////////////////////////////
537b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy// Renderer
538b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy///////////////////////////////////////////////////////////////////////////////
539b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
540b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy/**
541b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy * Records drawing commands in a display list for latter playback.
542b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy */
543b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guyclass DisplayListRenderer: public OpenGLRenderer {
544b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guypublic:
5457953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API DisplayListRenderer();
5467953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual ~DisplayListRenderer();
547b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
5487953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API DisplayList* getDisplayList(DisplayList* displayList);
5495977baa1fa24125c148a72699b53e62abaf08960Chet Haase
55049c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy    virtual bool isDeferred();
55149c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy
5527953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void setViewport(int width, int height);
5537c25aab491707f7324f9941b8cfa9bd2b4b97e76Romain Guy    virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
5547953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void finish();
555b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
5566554943a1dd6854c0f4976900956e556767b49e1Romain Guy    virtual status_t callDrawGLFunction(Functor *functor, Rect& dirty);
5574aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
5587953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void interrupt();
5597953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void resume();
560daf98e941e140e8739458126640183b9f296a2abChet Haase
5617953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual int save(int flags);
5627953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void restore();
5637953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void restoreToCount(int saveCount);
5644aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
5657953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual int saveLayer(float left, float top, float right, float bottom,
5665c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            SkPaint* p, int flags);
5677953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual int saveLayerAlpha(float left, float top, float right, float bottom,
5685b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy                int alpha, int flags);
5694aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
5707953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void translate(float dx, float dy);
5717953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void rotate(float degrees);
5727953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void scale(float sx, float sy);
5737953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void skew(float sx, float sy);
5744aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
5757953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void setMatrix(SkMatrix* matrix);
5767953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void concatMatrix(SkMatrix* matrix);
5774aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
5787953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
5794aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
5801271e2cc80b01d577e9db339459ef0222bb9320dChet Haase    virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t flags,
5811271e2cc80b01d577e9db339459ef0222bb9320dChet Haase            uint32_t level = 0);
582486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawLayer(Layer* layer, float x, float y, SkPaint* paint);
583486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
584486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
585486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
5864aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy            float srcRight, float srcBottom, float dstLeft, float dstTop,
5875c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            float dstRight, float dstBottom, SkPaint* paint);
588486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmapData(SkBitmap* bitmap, float left, float top, SkPaint* paint);
589486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
5905a7b466a2b4b7ced739bd5c31e022de61650545aRomain Guy            float* vertices, int* colors, SkPaint* paint);
591486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
5924bb942083a0d4db746adf95349108dd8ef842e32Romain Guy            const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
5935c13d89c1332fcc499379b9064b891187b75ca32Chet Haase            float left, float top, float right, float bottom, SkPaint* paint);
594486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawColor(int color, SkXfermode::Mode mode);
595486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawRect(float left, float top, float right, float bottom, SkPaint* paint);
596486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawRoundRect(float left, float top, float right, float bottom,
59701d58e43ede5ca98cbebdd166f9b0c545032c01bRomain Guy            float rx, float ry, SkPaint* paint);
598486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawCircle(float x, float y, float radius, SkPaint* paint);
599486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawOval(float left, float top, float right, float bottom, SkPaint* paint);
600486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawArc(float left, float top, float right, float bottom,
6018b2f5267f16c295f12faab810527cd6311997e34Romain Guy            float startAngle, float sweepAngle, bool useCenter, SkPaint* paint);
602486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPath(SkPath* path, SkPaint* paint);
603486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawLines(float* points, int count, SkPaint* paint);
604486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPoints(float* points, int count, SkPaint* paint);
605486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, SkPath* path,
606325740fb444af8fc7fb0119b2e30ce322c2ae134Romain Guy            float hOffset, float vOffset, SkPaint* paint);
607486590963e2207d68eebd6944fec70d50d41116aChet Haase    virtual status_t drawPosText(const char* text, int bytesCount, int count,
608486590963e2207d68eebd6944fec70d50d41116aChet Haase            const float* positions, SkPaint* paint);
609c25259519f1b74bb62a2b051b74537f073436b5cRomain Guy    virtual status_t drawText(const char* text, int bytesCount, int count,
610996e57c84368058be793897ebc355b917a59abc2Raph Levien            float x, float y, const float* positions, SkPaint* paint, float length);
6114aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
6127953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void resetShader();
6137953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void setupShader(SkiaShader* shader);
6144aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
6157953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void resetColorFilter();
6167953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void setupColorFilter(SkiaColorFilter* filter);
6174aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
6187953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void resetShadow();
6197953745dd565167113f8cbfc461bc0521d32d870Romain Guy    virtual void setupShadow(float radius, float dx, float dy, int color);
6204aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
6215ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    virtual void resetPaintFilter();
6225ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy    virtual void setupPaintFilter(int clearBits, int setBits);
6235ff9df658230d49e42c43586997a02d8e4dd417eRomain Guy
6247953745dd565167113f8cbfc461bc0521d32d870Romain Guy    ANDROID_API void reset();
6254aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
626b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    const SkWriter32& writeStream() const {
627b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        return mWriter;
628b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
629b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
6305c13d89c1332fcc499379b9064b891187b75ca32Chet Haase    const Vector<SkBitmap*>& getBitmapResources() const {
6315c13d89c1332fcc499379b9064b891187b75ca32Chet Haase        return mBitmapResources;
632b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
633b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
63449c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy    const Vector<SkBitmap*>& getOwnedBitmapResources() const {
63549c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy        return mOwnedBitmapResources;
63649c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy    }
63749c5fc0b9e850497233e189ff9dcc71a78ebe6e7Romain Guy
638d586ad9c9fec80aa1d24d6b53cd2c8d5b47fe868Romain Guy    const Vector<SkiaColorFilter*>& getFilterResources() const {
639d586ad9c9fec80aa1d24d6b53cd2c8d5b47fe868Romain Guy        return mFilterResources;
640d586ad9c9fec80aa1d24d6b53cd2c8d5b47fe868Romain Guy    }
641d586ad9c9fec80aa1d24d6b53cd2c8d5b47fe868Romain Guy
64224c00216687ac87fe531dc4d4168ac0c0ca04ea6Romain Guy    const Vector<SkiaShader*>& getShaders() const {
64324c00216687ac87fe531dc4d4168ac0c0ca04ea6Romain Guy        return mShaders;
644b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
645b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
646d98aa2de9ab18e09c2be1997f41212740f51f6e6Chet Haase    const Vector<SkPaint*>& getPaints() const {
647d98aa2de9ab18e09c2be1997f41212740f51f6e6Chet Haase        return mPaints;
6485c13d89c1332fcc499379b9064b891187b75ca32Chet Haase    }
6495c13d89c1332fcc499379b9064b891187b75ca32Chet Haase
6502fc941e4650d618ff6e122f28b616d9032ffa134Romain Guy    const Vector<SkPath*>& getPaths() const {
6512fc941e4650d618ff6e122f28b616d9032ffa134Romain Guy        return mPaths;
6522fc941e4650d618ff6e122f28b616d9032ffa134Romain Guy    }
6532fc941e4650d618ff6e122f28b616d9032ffa134Romain Guy
654d34dd71800d9a1077e58c3b7f2511c46848da417Chet Haase    const SortedVector<SkPath*>& getSourcePaths() const {
655d34dd71800d9a1077e58c3b7f2511c46848da417Chet Haase        return mSourcePaths;
656d34dd71800d9a1077e58c3b7f2511c46848da417Chet Haase    }
657d34dd71800d9a1077e58c3b7f2511c46848da417Chet Haase
658603f6de35f21d74ae242d52d501f4f5c25ff4f4cChet Haase    const Vector<Layer*>& getLayers() const {
659603f6de35f21d74ae242d52d501f4f5c25ff4f4cChet Haase        return mLayers;
660603f6de35f21d74ae242d52d501f4f5c25ff4f4cChet Haase    }
661603f6de35f21d74ae242d52d501f4f5c25ff4f4cChet Haase
662d98aa2de9ab18e09c2be1997f41212740f51f6e6Chet Haase    const Vector<SkMatrix*>& getMatrices() const {
663d98aa2de9ab18e09c2be1997f41212740f51f6e6Chet Haase        return mMatrices;
664b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy    }
665b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy
66654c1a64d5441a964890b44280e4457e11f4f924aRomain Guy    uint32_t getFunctorCount() const {
66754c1a64d5441a964890b44280e4457e11f4f924aRomain Guy        return mFunctorCount;
66854c1a64d5441a964890b44280e4457e11f4f924aRomain Guy    }
66954c1a64d5441a964890b44280e4457e11f4f924aRomain Guy
6704aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guyprivate:
67127454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy    void insertRestoreToCount() {
67227454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy        if (mRestoreSaveCount >= 0) {
67327454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy            mWriter.writeInt(DisplayList::RestoreToCount);
67427454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy            addInt(mRestoreSaveCount);
67527454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy            mRestoreSaveCount = -1;
67627454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy        }
67727454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy    }
67827454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy
67933f6beb10f98e8ba96250e284876d607055d278dRomain Guy    void insertTranlate() {
68033f6beb10f98e8ba96250e284876d607055d278dRomain Guy        if (mHasTranslate) {
68133f6beb10f98e8ba96250e284876d607055d278dRomain Guy            if (mTranslateX != 0.0f || mTranslateY != 0.0f) {
68233f6beb10f98e8ba96250e284876d607055d278dRomain Guy                mWriter.writeInt(DisplayList::Translate);
68333f6beb10f98e8ba96250e284876d607055d278dRomain Guy                addPoint(mTranslateX, mTranslateY);
68433f6beb10f98e8ba96250e284876d607055d278dRomain Guy                mTranslateX = mTranslateY = 0.0f;
68533f6beb10f98e8ba96250e284876d607055d278dRomain Guy            }
68633f6beb10f98e8ba96250e284876d607055d278dRomain Guy            mHasTranslate = false;
68733f6beb10f98e8ba96250e284876d607055d278dRomain Guy        }
68833f6beb10f98e8ba96250e284876d607055d278dRomain Guy    }
68933f6beb10f98e8ba96250e284876d607055d278dRomain Guy
69033f6beb10f98e8ba96250e284876d607055d278dRomain Guy    inline void addOp(const DisplayList::Op drawOp) {
69127454a42de8b3c54cdd3b2b2a12446c2c10c8cb9Romain Guy        insertRestoreToCount();
69233f6beb10f98e8ba96250e284876d607055d278dRomain Guy        insertTranlate();
6934aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeInt(drawOp);
69404c9d8c2ffd028c35c750bac0a4a7b79e48059b5Romain Guy        mHasDrawOps = mHasDrawOps || drawOp >= DisplayList::DrawDisplayList;
6954aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
6964aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
69733f6beb10f98e8ba96250e284876d607055d278dRomain Guy    uint32_t* addOp(const DisplayList::Op drawOp, const bool reject) {
69833f6beb10f98e8ba96250e284876d607055d278dRomain Guy        insertRestoreToCount();
69933f6beb10f98e8ba96250e284876d607055d278dRomain Guy        insertTranlate();
70033f6beb10f98e8ba96250e284876d607055d278dRomain Guy        mHasDrawOps = mHasDrawOps || drawOp >= DisplayList::DrawDisplayList;
70133f6beb10f98e8ba96250e284876d607055d278dRomain Guy        if (reject) {
70233f6beb10f98e8ba96250e284876d607055d278dRomain Guy            mWriter.writeInt(OP_MAY_BE_SKIPPED_MASK | drawOp);
703ad1daaa87b793af30f3dd67a0f3cd5c0fd6ac0c1Romain Guy            mWriter.writeInt(0xdeaddead);
704390f882f8905e8d1ac0d4b7f2e01aa04dccc3c16Romain Guy            mBufferSize = mWriter.size();
705390f882f8905e8d1ac0d4b7f2e01aa04dccc3c16Romain Guy            return mWriter.peek32(mBufferSize - sizeof(int32_t));
70633f6beb10f98e8ba96250e284876d607055d278dRomain Guy        }
70733f6beb10f98e8ba96250e284876d607055d278dRomain Guy        mWriter.writeInt(drawOp);
70833f6beb10f98e8ba96250e284876d607055d278dRomain Guy        return NULL;
70933f6beb10f98e8ba96250e284876d607055d278dRomain Guy    }
71033f6beb10f98e8ba96250e284876d607055d278dRomain Guy
71133f6beb10f98e8ba96250e284876d607055d278dRomain Guy    inline void addSkip(uint32_t* location) {
71233f6beb10f98e8ba96250e284876d607055d278dRomain Guy        if (location) {
713390f882f8905e8d1ac0d4b7f2e01aa04dccc3c16Romain Guy            *location = (int32_t) (mWriter.size() - mBufferSize);
71433f6beb10f98e8ba96250e284876d607055d278dRomain Guy        }
71533f6beb10f98e8ba96250e284876d607055d278dRomain Guy    }
71633f6beb10f98e8ba96250e284876d607055d278dRomain Guy
71733f6beb10f98e8ba96250e284876d607055d278dRomain Guy    inline void addInt(int32_t value) {
7184aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeInt(value);
7194aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
7204aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
7217b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy    inline void addSize(uint32_t w, uint32_t h) {
7227b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy        mWriter.writeInt(w);
7237b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy        mWriter.writeInt(h);
7247b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy    }
7257b5b6abf852c039983eded25ebe43a70fef5a4abRomain Guy
7264aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    void addInts(const int32_t* values, uint32_t count) {
727b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        mWriter.writeInt(count);
728e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy        mWriter.write(values, count * sizeof(int32_t));
729e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy    }
730e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy
7314bb942083a0d4db746adf95349108dd8ef842e32Romain Guy    void addUInts(const uint32_t* values, int8_t count) {
7324bb942083a0d4db746adf95349108dd8ef842e32Romain Guy        mWriter.writeInt(count);
733e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy        mWriter.write(values, count * sizeof(uint32_t));
7344aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
7354aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
7364aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    inline void addFloat(float value) {
7374aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeScalar(value);
7384aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
7394aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
74033f6beb10f98e8ba96250e284876d607055d278dRomain Guy    void addFloats(const float* values, int32_t count) {
741b051e895ccb696604349c6c5efe7c4747e1d1ab6Romain Guy        mWriter.writeInt(count);
742e651cc6239616a202f6e96ebc2ed93b4b8b3627cRomain Guy        mWriter.write(values, count * sizeof(float));
7434aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
7444aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
7454aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    inline void addPoint(float x, float y) {
7464aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeScalar(x);
7474aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeScalar(y);
7484aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
7494aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
7504aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    inline void addBounds(float left, float top, float right, float bottom) {
7514aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeScalar(left);
7524aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeScalar(top);
7534aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeScalar(right);
7544aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeScalar(bottom);
7554aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
7564aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
7574aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    inline void addText(const void* text, size_t byteLength) {
7584aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writeInt(byteLength);
7594aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy        mWriter.writePad(text, byteLength);
7604aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy    }
7614aa90573bbf86db0d33a3a790c5dbd0d93b95cfeRomain Guy
7622fc941e4650d618ff6e122f28b616d9032ffa134Romain Guy    inline void addPath(SkPath* path) {
763