blob: 6ca70a4872485a1912e0d6ac9e94ede0c82ff208 [file] [log] [blame]
Romain Guy4aa90572010-09-26 18:40:37 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "OpenGLRenderer"
18
Romain Guyd5a85fb2012-03-13 11:18:20 -070019#include <SkCamera.h>
Chet Haase9c1e23b2011-03-24 10:51:31 -070020
Romain Guy65549432012-03-26 16:45:05 -070021#include <private/hwui/DrawGlInfo.h>
22
Chet Haase9c1e23b2011-03-24 10:51:31 -070023#include "DisplayListLogBuffer.h"
Romain Guy4aa90572010-09-26 18:40:37 -070024#include "DisplayListRenderer.h"
Chet Haase9c1e23b2011-03-24 10:51:31 -070025#include "Caches.h"
Romain Guy13631f32012-01-30 17:41:55 -080026
Romain Guy4aa90572010-09-26 18:40:37 -070027namespace android {
28namespace uirenderer {
29
30///////////////////////////////////////////////////////////////////////////////
Romain Guyb051e892010-09-28 19:09:36 -070031// Display list
32///////////////////////////////////////////////////////////////////////////////
33
Romain Guyffac7fc2011-01-13 17:21:49 -080034const char* DisplayList::OP_NAMES[] = {
Romain Guyffac7fc2011-01-13 17:21:49 -080035 "Save",
36 "Restore",
37 "RestoreToCount",
38 "SaveLayer",
39 "SaveLayerAlpha",
40 "Translate",
41 "Rotate",
42 "Scale",
Romain Guy4cf6e2f2011-01-23 11:35:13 -080043 "Skew",
Romain Guyffac7fc2011-01-13 17:21:49 -080044 "SetMatrix",
45 "ConcatMatrix",
46 "ClipRect",
47 "DrawDisplayList",
48 "DrawLayer",
49 "DrawBitmap",
50 "DrawBitmapMatrix",
51 "DrawBitmapRect",
Romain Guye651cc62012-05-14 19:44:40 -070052 "DrawBitmapData",
Romain Guy5a7b4662011-01-20 19:09:30 -080053 "DrawBitmapMesh",
Romain Guyffac7fc2011-01-13 17:21:49 -080054 "DrawPatch",
55 "DrawColor",
56 "DrawRect",
Romain Guy01d58e42011-01-19 21:54:02 -080057 "DrawRoundRect",
58 "DrawCircle",
Romain Guyc1cd9ba32011-01-23 14:18:41 -080059 "DrawOval",
Romain Guy8b2f5262011-01-23 16:15:02 -080060 "DrawArc",
Romain Guyffac7fc2011-01-13 17:21:49 -080061 "DrawPath",
62 "DrawLines",
Romain Guyed6fcb02011-03-21 13:11:28 -070063 "DrawPoints",
Romain Guy325740f2012-02-24 16:48:34 -080064 "DrawTextOnPath",
Romain Guyeb9a5362012-01-17 17:39:26 -080065 "DrawPosText",
Romain Guyc2525952012-07-27 16:41:22 -070066 "DrawText",
Romain Guyffac7fc2011-01-13 17:21:49 -080067 "ResetShader",
68 "SetupShader",
69 "ResetColorFilter",
70 "SetupColorFilter",
71 "ResetShadow",
Chet Haasedaf98e92011-01-10 14:10:36 -080072 "SetupShadow",
Romain Guy5ff9df62012-01-23 17:09:05 -080073 "ResetPaintFilter",
74 "SetupPaintFilter",
Chet Haasedaf98e92011-01-10 14:10:36 -080075 "DrawGLFunction"
Romain Guyffac7fc2011-01-13 17:21:49 -080076};
77
Chet Haase9c1e23b2011-03-24 10:51:31 -070078void DisplayList::outputLogBuffer(int fd) {
79 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
80 if (logBuffer.isEmpty()) {
81 return;
82 }
Romain Guy65b345f2011-07-27 18:51:50 -070083
Chet Haase9c1e23b2011-03-24 10:51:31 -070084 FILE *file = fdopen(fd, "a");
Romain Guy65b345f2011-07-27 18:51:50 -070085
Chet Haase9c1e23b2011-03-24 10:51:31 -070086 fprintf(file, "\nRecent DisplayList operations\n");
87 logBuffer.outputCommands(file, OP_NAMES);
Romain Guy65b345f2011-07-27 18:51:50 -070088
89 String8 cachesLog;
90 Caches::getInstance().dumpMemoryUsage(cachesLog);
91 fprintf(file, "\nCaches:\n%s", cachesLog.string());
92 fprintf(file, "\n");
93
Chet Haase9c1e23b2011-03-24 10:51:31 -070094 fflush(file);
95}
96
Chet Haase491189f2012-03-13 11:42:34 -070097DisplayList::DisplayList(const DisplayListRenderer& recorder) :
Chet Haase9420abd2012-03-29 16:28:32 -070098 mTransformMatrix(NULL), mTransformCamera(NULL), mTransformMatrix3D(NULL),
99 mStaticMatrix(NULL), mAnimationMatrix(NULL) {
Chet Haase491189f2012-03-13 11:42:34 -0700100
Chet Haase5977baa2011-01-05 18:01:22 -0800101 initFromDisplayListRenderer(recorder);
102}
103
104DisplayList::~DisplayList() {
Chet Haased63cbd12011-02-03 16:32:46 -0800105 clearResources();
106}
107
Chet Haasea1cff502012-02-21 13:43:44 -0800108void DisplayList::initProperties() {
109 mLeft = 0;
110 mTop = 0;
Chet Haaseb85967b2012-03-26 14:37:51 -0700111 mRight = 0;
Chet Haasea1cff502012-02-21 13:43:44 -0800112 mBottom = 0;
Chet Haasea1cff502012-02-21 13:43:44 -0800113 mClipChildren = true;
114 mAlpha = 1;
115 mMultipliedAlpha = 255;
Chet Haasedb8c9a62012-03-21 18:54:18 -0700116 mHasOverlappingRendering = true;
Chet Haasea1cff502012-02-21 13:43:44 -0800117 mTranslationX = 0;
118 mTranslationY = 0;
119 mRotation = 0;
120 mRotationX = 0;
121 mRotationY= 0;
122 mScaleX = 1;
123 mScaleY = 1;
124 mPivotX = 0;
125 mPivotY = 0;
Chet Haaseb85967b2012-03-26 14:37:51 -0700126 mCameraDistance = 0;
Chet Haasea1cff502012-02-21 13:43:44 -0800127 mMatrixDirty = false;
128 mMatrixFlags = 0;
129 mPrevWidth = -1;
130 mPrevHeight = -1;
131 mWidth = 0;
132 mHeight = 0;
133 mPivotExplicitlySet = false;
Chet Haasea1cff502012-02-21 13:43:44 -0800134 mCaching = false;
135}
136
Romain Guybb0acdf2012-03-05 13:44:35 -0800137void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) {
138 if (displayList) {
139 DISPLAY_LIST_LOGD("Deferring display list destruction");
140 Caches::getInstance().deleteDisplayListDeferred(displayList);
141 }
142}
143
Chet Haased63cbd12011-02-03 16:32:46 -0800144void DisplayList::clearResources() {
Chet Haase5977baa2011-01-05 18:01:22 -0800145 sk_free((void*) mReader.base());
Romain Guy034de6b2012-09-27 19:01:55 -0700146 mReader.setMemory(NULL, 0);
Chet Haase5977baa2011-01-05 18:01:22 -0800147
Chet Haase1271e2c2012-04-20 09:54:27 -0700148 delete mTransformMatrix;
149 delete mTransformCamera;
150 delete mTransformMatrix3D;
151 delete mStaticMatrix;
152 delete mAnimationMatrix;
Romain Guy58ecc202012-09-07 11:58:36 -0700153
Chet Haase1271e2c2012-04-20 09:54:27 -0700154 mTransformMatrix = NULL;
155 mTransformCamera = NULL;
156 mTransformMatrix3D = NULL;
157 mStaticMatrix = NULL;
158 mAnimationMatrix = NULL;
Chet Haasea1cff502012-02-21 13:43:44 -0800159
Chet Haase5977baa2011-01-05 18:01:22 -0800160 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700161 caches.unregisterFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700162 caches.resourceCache.lock();
Chet Haase5977baa2011-01-05 18:01:22 -0800163
164 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700165 caches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800166 }
Chet Haase5977baa2011-01-05 18:01:22 -0800167
Romain Guy49c5fc02012-05-15 11:10:01 -0700168 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
169 SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
Romain Guy58ecc202012-09-07 11:58:36 -0700170 caches.resourceCache.decrementRefcountLocked(bitmap);
171 caches.resourceCache.destructorLocked(bitmap);
Romain Guy49c5fc02012-05-15 11:10:01 -0700172 }
Romain Guy49c5fc02012-05-15 11:10:01 -0700173
Romain Guyd586ad92011-06-22 16:14:36 -0700174 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700175 caches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -0700176 }
Romain Guyd586ad92011-06-22 16:14:36 -0700177
Romain Guy24c00212011-01-14 15:31:00 -0800178 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700179 caches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
180 caches.resourceCache.destructorLocked(mShaders.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800181 }
Romain Guy58ecc202012-09-07 11:58:36 -0700182
183 for (size_t i = 0; i < mSourcePaths.size(); i++) {
184 caches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
185 }
186
Chet Haase603f6de2012-09-14 15:31:25 -0700187 for (size_t i = 0; i < mLayers.size(); i++) {
188 caches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
189 }
190
Romain Guy58ecc202012-09-07 11:58:36 -0700191 caches.resourceCache.unlock();
Chet Haase5977baa2011-01-05 18:01:22 -0800192
193 for (size_t i = 0; i < mPaints.size(); i++) {
194 delete mPaints.itemAt(i);
195 }
Chet Haase5977baa2011-01-05 18:01:22 -0800196
Romain Guy2fc941e2011-02-03 15:06:05 -0800197 for (size_t i = 0; i < mPaths.size(); i++) {
Romain Guy1af23a32011-03-24 16:03:55 -0700198 SkPath* path = mPaths.itemAt(i);
199 caches.pathCache.remove(path);
200 delete path;
Romain Guy2fc941e2011-02-03 15:06:05 -0800201 }
Chet Haased34dd712012-05-02 18:50:34 -0700202
Chet Haase5977baa2011-01-05 18:01:22 -0800203 for (size_t i = 0; i < mMatrices.size(); i++) {
204 delete mMatrices.itemAt(i);
205 }
Romain Guy58ecc202012-09-07 11:58:36 -0700206
207 mBitmapResources.clear();
208 mOwnedBitmapResources.clear();
209 mFilterResources.clear();
210 mShaders.clear();
211 mSourcePaths.clear();
212 mPaints.clear();
213 mPaths.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800214 mMatrices.clear();
Chet Haase603f6de2012-09-14 15:31:25 -0700215 mLayers.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800216}
217
Chet Haased63cbd12011-02-03 16:32:46 -0800218void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
Romain Guyb051e892010-09-28 19:09:36 -0700219 const SkWriter32& writer = recorder.writeStream();
Romain Guyb051e892010-09-28 19:09:36 -0700220
Chet Haased63cbd12011-02-03 16:32:46 -0800221 if (reusing) {
222 // re-using display list - clear out previous allocations
223 clearResources();
224 }
Romain Guy034de6b2012-09-27 19:01:55 -0700225
226 init();
Chet Haasea1cff502012-02-21 13:43:44 -0800227 initProperties();
Chet Haased63cbd12011-02-03 16:32:46 -0800228
Romain Guy034de6b2012-09-27 19:01:55 -0700229 if (writer.size() == 0) {
230 return;
231 }
232
Romain Guy65b345f2011-07-27 18:51:50 -0700233 mSize = writer.size();
234 void* buffer = sk_malloc_throw(mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700235 writer.flatten(buffer);
Romain Guy65b345f2011-07-27 18:51:50 -0700236 mReader.setMemory(buffer, mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700237
Romain Guy54c1a642012-09-27 17:55:46 -0700238 mFunctorCount = recorder.getFunctorCount();
239
Chet Haase5c13d892010-10-08 08:37:55 -0700240 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700241 caches.registerFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700242 caches.resourceCache.lock();
Romain Guyb051e892010-09-28 19:09:36 -0700243
Romain Guy49c5fc02012-05-15 11:10:01 -0700244 const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
Chet Haase5c13d892010-10-08 08:37:55 -0700245 for (size_t i = 0; i < bitmapResources.size(); i++) {
246 SkBitmap* resource = bitmapResources.itemAt(i);
247 mBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700248 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700249 }
Chet Haased98aa2d2010-10-25 15:47:32 -0700250
Romain Guy49c5fc02012-05-15 11:10:01 -0700251 const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources();
252 for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
253 SkBitmap* resource = ownedBitmapResources.itemAt(i);
254 mOwnedBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700255 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guy49c5fc02012-05-15 11:10:01 -0700256 }
257
258 const Vector<SkiaColorFilter*>& filterResources = recorder.getFilterResources();
Romain Guyd586ad92011-06-22 16:14:36 -0700259 for (size_t i = 0; i < filterResources.size(); i++) {
260 SkiaColorFilter* resource = filterResources.itemAt(i);
261 mFilterResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700262 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyd586ad92011-06-22 16:14:36 -0700263 }
264
Romain Guy49c5fc02012-05-15 11:10:01 -0700265 const Vector<SkiaShader*>& shaders = recorder.getShaders();
Romain Guy24c00212011-01-14 15:31:00 -0800266 for (size_t i = 0; i < shaders.size(); i++) {
Romain Guyd586ad92011-06-22 16:14:36 -0700267 SkiaShader* resource = shaders.itemAt(i);
268 mShaders.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700269 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700270 }
271
Romain Guy58ecc202012-09-07 11:58:36 -0700272 const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths();
273 for (size_t i = 0; i < sourcePaths.size(); i++) {
274 mSourcePaths.add(sourcePaths.itemAt(i));
275 caches.resourceCache.incrementRefcountLocked(sourcePaths.itemAt(i));
276 }
277
Chet Haase603f6de2012-09-14 15:31:25 -0700278 const Vector<Layer*>& layers = recorder.getLayers();
279 for (size_t i = 0; i < layers.size(); i++) {
280 mLayers.add(layers.itemAt(i));
281 caches.resourceCache.incrementRefcountLocked(layers.itemAt(i));
282 }
283
Romain Guy58ecc202012-09-07 11:58:36 -0700284 caches.resourceCache.unlock();
285
Romain Guy49c5fc02012-05-15 11:10:01 -0700286 const Vector<SkPaint*>& paints = recorder.getPaints();
Chet Haased98aa2d2010-10-25 15:47:32 -0700287 for (size_t i = 0; i < paints.size(); i++) {
288 mPaints.add(paints.itemAt(i));
289 }
290
Romain Guy49c5fc02012-05-15 11:10:01 -0700291 const Vector<SkPath*>& paths = recorder.getPaths();
Romain Guy2fc941e2011-02-03 15:06:05 -0800292 for (size_t i = 0; i < paths.size(); i++) {
293 mPaths.add(paths.itemAt(i));
294 }
295
Romain Guy49c5fc02012-05-15 11:10:01 -0700296 const Vector<SkMatrix*>& matrices = recorder.getMatrices();
Chet Haased98aa2d2010-10-25 15:47:32 -0700297 for (size_t i = 0; i < matrices.size(); i++) {
298 mMatrices.add(matrices.itemAt(i));
299 }
Romain Guyb051e892010-09-28 19:09:36 -0700300}
301
Romain Guyb051e892010-09-28 19:09:36 -0700302void DisplayList::init() {
Romain Guy65b345f2011-07-27 18:51:50 -0700303 mSize = 0;
Romain Guy04c9d8c2011-08-25 14:01:48 -0700304 mIsRenderable = true;
Romain Guy034de6b2012-09-27 19:01:55 -0700305 mFunctorCount = 0;
Romain Guy65b345f2011-07-27 18:51:50 -0700306}
307
308size_t DisplayList::getSize() {
309 return mSize;
Romain Guyb051e892010-09-28 19:09:36 -0700310}
311
Chet Haaseed30fd82011-04-22 16:18:45 -0700312/**
313 * This function is a simplified version of replay(), where we simply retrieve and log the
314 * display list. This function should remain in sync with the replay() function.
315 */
316void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
317 TextContainer text;
318
319 uint32_t count = (level + 1) * 2;
320 char indent[count + 1];
321 for (uint32_t i = 0; i < count; i++) {
322 indent[i] = ' ';
323 }
324 indent[count] = '\0';
Romain Guyddf74372012-05-22 14:07:07 -0700325 ALOGD("%sStart display list (%p, %s, render=%d)", (char*) indent + 2, this,
326 mName.string(), isRenderable());
Chet Haaseed30fd82011-04-22 16:18:45 -0700327
Chet Haase1271e2c2012-04-20 09:54:27 -0700328 ALOGD("%s%s %d", indent, "Save", SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
Chet Haaseed30fd82011-04-22 16:18:45 -0700329 int saveCount = renderer.getSaveCount() - 1;
330
Chet Haasea1cff502012-02-21 13:43:44 -0800331 outputViewProperties(renderer, (char*) indent);
Chet Haaseed30fd82011-04-22 16:18:45 -0700332 mReader.rewind();
333
334 while (!mReader.eof()) {
335 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800336 if (op & OP_MAY_BE_SKIPPED_MASK) {
337 int skip = mReader.readInt();
338 ALOGD("%sSkip %d", (char*) indent, skip);
339 op &= ~OP_MAY_BE_SKIPPED_MASK;
Chet Haasea1cff502012-02-21 13:43:44 -0800340 }
Chet Haaseed30fd82011-04-22 16:18:45 -0700341
342 switch (op) {
343 case DrawGLFunction: {
344 Functor *functor = (Functor *) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000345 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Chet Haaseed30fd82011-04-22 16:18:45 -0700346 }
347 break;
348 case Save: {
349 int rendererNum = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000350 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
Chet Haaseed30fd82011-04-22 16:18:45 -0700351 }
352 break;
353 case Restore: {
Steve Block5baa3a62011-12-20 16:23:08 +0000354 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700355 }
356 break;
357 case RestoreToCount: {
358 int restoreCount = saveCount + getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000359 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
Chet Haaseed30fd82011-04-22 16:18:45 -0700360 }
361 break;
362 case SaveLayer: {
363 float f1 = getFloat();
364 float f2 = getFloat();
365 float f3 = getFloat();
366 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800367 SkPaint* paint = getPaint(renderer);
Chet Haaseed30fd82011-04-22 16:18:45 -0700368 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000369 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800370 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700371 }
372 break;
373 case SaveLayerAlpha: {
374 float f1 = getFloat();
375 float f2 = getFloat();
376 float f3 = getFloat();
377 float f4 = getFloat();
378 int alpha = getInt();
379 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000380 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800381 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700382 }
383 break;
384 case Translate: {
385 float f1 = getFloat();
386 float f2 = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000387 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
Chet Haaseed30fd82011-04-22 16:18:45 -0700388 }
389 break;
390 case Rotate: {
391 float rotation = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000392 ALOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
Chet Haaseed30fd82011-04-22 16:18:45 -0700393 }
394 break;
395 case Scale: {
396 float sx = getFloat();
397 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000398 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700399 }
400 break;
401 case Skew: {
402 float sx = getFloat();
403 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000404 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700405 }
406 break;
407 case SetMatrix: {
408 SkMatrix* matrix = getMatrix();
Steve Block5baa3a62011-12-20 16:23:08 +0000409 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
Chet Haaseed30fd82011-04-22 16:18:45 -0700410 }
411 break;
412 case ConcatMatrix: {
413 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -0800414 ALOGD("%s%s new concat %p: [%f, %f, %f] [%f, %f, %f] [%f, %f, %f]",
415 (char*) indent, OP_NAMES[op], matrix, matrix->get(0), matrix->get(1),
416 matrix->get(2), matrix->get(3), matrix->get(4), matrix->get(5),
417 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haaseed30fd82011-04-22 16:18:45 -0700418 }
419 break;
420 case ClipRect: {
421 float f1 = getFloat();
422 float f2 = getFloat();
423 float f3 = getFloat();
424 float f4 = getFloat();
425 int regionOp = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000426 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800427 f1, f2, f3, f4, regionOp);
Chet Haaseed30fd82011-04-22 16:18:45 -0700428 }
429 break;
430 case DrawDisplayList: {
431 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -0800432 int32_t flags = getInt();
433 ALOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -0700434 displayList, mWidth, mHeight, flags, level + 1);
Chet Haaseed30fd82011-04-22 16:18:45 -0700435 renderer.outputDisplayList(displayList, level + 1);
436 }
437 break;
438 case DrawLayer: {
439 Layer* layer = (Layer*) getInt();
440 float x = getFloat();
441 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800442 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000443 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800444 layer, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700445 }
446 break;
447 case DrawBitmap: {
448 SkBitmap* bitmap = getBitmap();
449 float x = getFloat();
450 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800451 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000452 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800453 bitmap, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700454 }
455 break;
456 case DrawBitmapMatrix: {
457 SkBitmap* bitmap = getBitmap();
458 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -0800459 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000460 ALOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800461 bitmap, matrix, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700462 }
463 break;
464 case DrawBitmapRect: {
465 SkBitmap* bitmap = getBitmap();
466 float f1 = getFloat();
467 float f2 = getFloat();
468 float f3 = getFloat();
469 float f4 = getFloat();
470 float f5 = getFloat();
471 float f6 = getFloat();
472 float f7 = getFloat();
473 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800474 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000475 ALOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800476 (char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700477 }
478 break;
Romain Guye651cc62012-05-14 19:44:40 -0700479 case DrawBitmapData: {
480 SkBitmap* bitmap = getBitmapData();
481 float x = getFloat();
482 float y = getFloat();
483 SkPaint* paint = getPaint(renderer);
484 ALOGD("%s%s %.2f, %.2f, %p", (char*) indent, OP_NAMES[op], x, y, paint);
485 }
486 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700487 case DrawBitmapMesh: {
488 int verticesCount = 0;
489 uint32_t colorsCount = 0;
490 SkBitmap* bitmap = getBitmap();
491 uint32_t meshWidth = getInt();
492 uint32_t meshHeight = getInt();
493 float* vertices = getFloats(verticesCount);
494 bool hasColors = getInt();
495 int* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -0800496 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000497 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700498 }
499 break;
500 case DrawPatch: {
501 int32_t* xDivs = NULL;
502 int32_t* yDivs = NULL;
503 uint32_t* colors = NULL;
504 uint32_t xDivsCount = 0;
505 uint32_t yDivsCount = 0;
506 int8_t numColors = 0;
507 SkBitmap* bitmap = getBitmap();
508 xDivs = getInts(xDivsCount);
509 yDivs = getInts(yDivsCount);
510 colors = getUInts(numColors);
Romain Guya62f1722011-10-19 17:06:19 -0700511 float left = getFloat();
512 float top = getFloat();
513 float right = getFloat();
514 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -0700515 int alpha = getInt();
516 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000517 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", (char*) indent, OP_NAMES[op],
Romain Guya62f1722011-10-19 17:06:19 -0700518 left, top, right, bottom);
Chet Haaseed30fd82011-04-22 16:18:45 -0700519 }
520 break;
521 case DrawColor: {
522 int color = getInt();
523 int xferMode = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000524 ALOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haaseed30fd82011-04-22 16:18:45 -0700525 }
526 break;
527 case DrawRect: {
528 float f1 = getFloat();
529 float f2 = getFloat();
530 float f3 = getFloat();
531 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800532 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000533 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800534 f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700535 }
536 break;
537 case DrawRoundRect: {
538 float f1 = getFloat();
539 float f2 = getFloat();
540 float f3 = getFloat();
541 float f4 = getFloat();
542 float f5 = getFloat();
543 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800544 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000545 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800546 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700547 }
548 break;
549 case DrawCircle: {
550 float f1 = getFloat();
551 float f2 = getFloat();
552 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800553 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000554 ALOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800555 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700556 }
557 break;
558 case DrawOval: {
559 float f1 = getFloat();
560 float f2 = getFloat();
561 float f3 = getFloat();
562 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800563 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000564 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800565 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700566 }
567 break;
568 case DrawArc: {
569 float f1 = getFloat();
570 float f2 = getFloat();
571 float f3 = getFloat();
572 float f4 = getFloat();
573 float f5 = getFloat();
574 float f6 = getFloat();
575 int i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -0800576 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000577 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800578 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700579 }
580 break;
581 case DrawPath: {
582 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -0800583 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000584 ALOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700585 }
586 break;
587 case DrawLines: {
588 int count = 0;
589 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800590 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000591 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700592 }
593 break;
594 case DrawPoints: {
595 int count = 0;
596 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800597 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000598 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700599 }
600 break;
Romain Guy325740f2012-02-24 16:48:34 -0800601 case DrawTextOnPath: {
602 getText(&text);
603 int32_t count = getInt();
604 SkPath* path = getPath();
605 float hOffset = getFloat();
606 float vOffset = getFloat();
607 SkPaint* paint = getPaint(renderer);
608 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
609 text.text(), text.length(), count, paint);
610 }
611 break;
Romain Guyeb9a5362012-01-17 17:39:26 -0800612 case DrawPosText: {
613 getText(&text);
614 int count = getInt();
615 int positionsCount = 0;
616 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -0800617 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -0800618 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800619 text.text(), text.length(), count, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -0800620 }
Raph Levien996e57c2012-07-23 15:22:52 -0700621 break;
Romain Guyc2525952012-07-27 16:41:22 -0700622 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -0700623 getText(&text);
Romain Guy18edb812012-08-03 16:06:55 -0700624 int32_t count = getInt();
625 float x = getFloat();
626 float y = getFloat();
627 int32_t positionsCount = 0;
Raph Levien996e57c2012-07-23 15:22:52 -0700628 float* positions = getFloats(positionsCount);
629 SkPaint* paint = getPaint(renderer);
Romain Guy18edb812012-08-03 16:06:55 -0700630 float length = getFloat();
Raph Levien996e57c2012-07-23 15:22:52 -0700631 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
632 text.text(), text.length(), count, paint);
633 }
634 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700635 case ResetShader: {
Steve Block5baa3a62011-12-20 16:23:08 +0000636 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700637 }
638 break;
639 case SetupShader: {
640 SkiaShader* shader = getShader();
Steve Block5baa3a62011-12-20 16:23:08 +0000641 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
Chet Haaseed30fd82011-04-22 16:18:45 -0700642 }
643 break;
644 case ResetColorFilter: {
Steve Block5baa3a62011-12-20 16:23:08 +0000645 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700646 }
647 break;
648 case SetupColorFilter: {
649 SkiaColorFilter *colorFilter = getColorFilter();
Steve Block5baa3a62011-12-20 16:23:08 +0000650 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
Chet Haaseed30fd82011-04-22 16:18:45 -0700651 }
652 break;
653 case ResetShadow: {
Steve Block5baa3a62011-12-20 16:23:08 +0000654 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700655 }
656 break;
657 case SetupShadow: {
658 float radius = getFloat();
659 float dx = getFloat();
660 float dy = getFloat();
661 int color = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000662 ALOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800663 radius, dx, dy, color);
Chet Haaseed30fd82011-04-22 16:18:45 -0700664 }
665 break;
Romain Guy5ff9df62012-01-23 17:09:05 -0800666 case ResetPaintFilter: {
667 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
668 }
669 break;
670 case SetupPaintFilter: {
671 int clearBits = getInt();
672 int setBits = getInt();
673 ALOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op], clearBits, setBits);
674 }
675 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700676 default:
Steve Block5baa3a62011-12-20 16:23:08 +0000677 ALOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -0800678 (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700679 break;
680 }
681 }
Chet Haasea1cff502012-02-21 13:43:44 -0800682 ALOGD("%sDone (%p, %s)", (char*) indent + 2, this, mName.string());
Chet Haaseed30fd82011-04-22 16:18:45 -0700683}
684
Chet Haasea1cff502012-02-21 13:43:44 -0800685void DisplayList::updateMatrix() {
686 if (mMatrixDirty) {
687 if (!mTransformMatrix) {
688 mTransformMatrix = new SkMatrix();
689 }
690 if (mMatrixFlags == 0 || mMatrixFlags == TRANSLATION) {
691 mTransformMatrix->reset();
692 } else {
693 if (!mPivotExplicitlySet) {
694 if (mWidth != mPrevWidth || mHeight != mPrevHeight) {
695 mPrevWidth = mWidth;
696 mPrevHeight = mHeight;
697 mPivotX = mPrevWidth / 2;
698 mPivotY = mPrevHeight / 2;
699 }
700 }
701 if ((mMatrixFlags & ROTATION_3D) == 0) {
702 mTransformMatrix->setTranslate(mTranslationX, mTranslationY);
703 mTransformMatrix->preRotate(mRotation, mPivotX, mPivotY);
704 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
705 } else {
706 if (!mTransformCamera) {
707 mTransformCamera = new Sk3DView();
708 mTransformMatrix3D = new SkMatrix();
709 }
710 mTransformMatrix->reset();
711 mTransformCamera->save();
712 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
713 mTransformCamera->rotateX(mRotationX);
714 mTransformCamera->rotateY(mRotationY);
715 mTransformCamera->rotateZ(-mRotation);
716 mTransformCamera->getMatrix(mTransformMatrix3D);
717 mTransformMatrix3D->preTranslate(-mPivotX, -mPivotY);
718 mTransformMatrix3D->postTranslate(mPivotX + mTranslationX,
719 mPivotY + mTranslationY);
720 mTransformMatrix->postConcat(*mTransformMatrix3D);
721 mTransformCamera->restore();
722 }
723 }
724 mMatrixDirty = false;
725 }
726}
727
728void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
Chet Haase1271e2c2012-04-20 09:54:27 -0700729 updateMatrix();
730 if (mLeft != 0 || mTop != 0) {
731 ALOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
732 }
733 if (mStaticMatrix) {
734 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
735 indent, "ConcatMatrix (static)", mStaticMatrix,
736 mStaticMatrix->get(0), mStaticMatrix->get(1),
737 mStaticMatrix->get(2), mStaticMatrix->get(3),
738 mStaticMatrix->get(4), mStaticMatrix->get(5),
739 mStaticMatrix->get(6), mStaticMatrix->get(7),
740 mStaticMatrix->get(8));
741 }
742 if (mAnimationMatrix) {
743 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
744 indent, "ConcatMatrix (animation)", mAnimationMatrix,
745 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
746 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
747 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
748 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
749 mAnimationMatrix->get(8));
750 }
751 if (mMatrixFlags != 0) {
752 if (mMatrixFlags == TRANSLATION) {
753 ALOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
754 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700755 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700756 indent, "ConcatMatrix", mTransformMatrix,
757 mTransformMatrix->get(0), mTransformMatrix->get(1),
758 mTransformMatrix->get(2), mTransformMatrix->get(3),
759 mTransformMatrix->get(4), mTransformMatrix->get(5),
760 mTransformMatrix->get(6), mTransformMatrix->get(7),
761 mTransformMatrix->get(8));
Chet Haase9420abd2012-03-29 16:28:32 -0700762 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700763 }
764 if (mAlpha < 1 && !mCaching) {
765 // TODO: should be able to store the size of a DL at record time and not
766 // have to pass it into this call. In fact, this information might be in the
767 // location/size info that we store with the new native transform data.
768 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800769 if (mClipChildren) {
Chet Haase1271e2c2012-04-20 09:54:27 -0700770 flags |= SkCanvas::kClipToLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800771 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700772 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
773 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
774 mMultipliedAlpha, flags);
775 }
776 if (mClipChildren) {
777 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
778 (float) mRight - mLeft, (float) mBottom - mTop);
Chet Haasea1cff502012-02-21 13:43:44 -0800779 }
780}
781
Chet Haase1271e2c2012-04-20 09:54:27 -0700782void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t level) {
Chet Haasea1cff502012-02-21 13:43:44 -0800783#if DEBUG_DISPLAY_LIST
784 uint32_t count = (level + 1) * 2;
785 char indent[count + 1];
786 for (uint32_t i = 0; i < count; i++) {
787 indent[i] = ' ';
788 }
789 indent[count] = '\0';
790#endif
Chet Haase1271e2c2012-04-20 09:54:27 -0700791 updateMatrix();
792 if (mLeft != 0 || mTop != 0) {
793 DISPLAY_LIST_LOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
794 renderer.translate(mLeft, mTop);
795 }
796 if (mStaticMatrix) {
797 DISPLAY_LIST_LOGD(
798 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
799 indent, "ConcatMatrix (static)", mStaticMatrix,
800 mStaticMatrix->get(0), mStaticMatrix->get(1),
801 mStaticMatrix->get(2), mStaticMatrix->get(3),
802 mStaticMatrix->get(4), mStaticMatrix->get(5),
803 mStaticMatrix->get(6), mStaticMatrix->get(7),
804 mStaticMatrix->get(8));
805 renderer.concatMatrix(mStaticMatrix);
806 } else if (mAnimationMatrix) {
807 DISPLAY_LIST_LOGD(
808 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
809 indent, "ConcatMatrix (animation)", mAnimationMatrix,
810 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
811 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
812 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
813 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
814 mAnimationMatrix->get(8));
815 renderer.concatMatrix(mAnimationMatrix);
816 }
817 if (mMatrixFlags != 0) {
818 if (mMatrixFlags == TRANSLATION) {
819 DISPLAY_LIST_LOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
820 renderer.translate(mTranslationX, mTranslationY);
821 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700822 DISPLAY_LIST_LOGD(
823 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700824 indent, "ConcatMatrix", mTransformMatrix,
825 mTransformMatrix->get(0), mTransformMatrix->get(1),
826 mTransformMatrix->get(2), mTransformMatrix->get(3),
827 mTransformMatrix->get(4), mTransformMatrix->get(5),
828 mTransformMatrix->get(6), mTransformMatrix->get(7),
829 mTransformMatrix->get(8));
830 renderer.concatMatrix(mTransformMatrix);
Chet Haasea1cff502012-02-21 13:43:44 -0800831 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700832 }
833 if (mAlpha < 1 && !mCaching) {
834 if (!mHasOverlappingRendering) {
835 DISPLAY_LIST_LOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
836 renderer.setAlpha(mAlpha);
837 } else {
838 // TODO: should be able to store the size of a DL at record time and not
839 // have to pass it into this call. In fact, this information might be in the
840 // location/size info that we store with the new native transform data.
841 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
842 if (mClipChildren) {
843 flags |= SkCanvas::kClipToLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800844 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700845 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
846 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
847 mMultipliedAlpha, flags);
848 renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
849 mMultipliedAlpha, flags);
Chet Haasea1cff502012-02-21 13:43:44 -0800850 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700851 }
852 if (mClipChildren) {
853 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
854 (float) mRight - mLeft, (float) mBottom - mTop);
855 renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
856 SkRegion::kIntersect_Op);
Chet Haasea1cff502012-02-21 13:43:44 -0800857 }
858}
859
Chet Haaseed30fd82011-04-22 16:18:45 -0700860/**
861 * Changes to replay(), specifically those involving opcode or parameter changes, should be mimicked
862 * in the output() function, since that function processes the same list of opcodes for the
863 * purposes of logging display list info for a given view.
864 */
Chet Haase1271e2c2012-04-20 09:54:27 -0700865status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level) {
Chet Haase48659092012-05-31 15:21:51 -0700866 status_t drawGlStatus = DrawGlInfo::kStatusDone;
Romain Guyb051e892010-09-28 19:09:36 -0700867 TextContainer text;
868 mReader.rewind();
869
Romain Guyffac7fc2011-01-13 17:21:49 -0800870#if DEBUG_DISPLAY_LIST
871 uint32_t count = (level + 1) * 2;
872 char indent[count + 1];
873 for (uint32_t i = 0; i < count; i++) {
874 indent[i] = ' ';
875 }
876 indent[count] = '\0';
Chet Haasea23eed82012-04-12 15:19:04 -0700877 Rect* clipRect = renderer.getClipRect();
878 DISPLAY_LIST_LOGD("%sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
879 (char*) indent + 2, this, mName.string(), clipRect->left, clipRect->top,
880 clipRect->right, clipRect->bottom);
Romain Guyffac7fc2011-01-13 17:21:49 -0800881#endif
Romain Guyb051e892010-09-28 19:09:36 -0700882
Romain Guy13631f32012-01-30 17:41:55 -0800883 renderer.startMark(mName.string());
Romain Guy8a4ac612012-07-17 17:32:48 -0700884
Chet Haase1271e2c2012-04-20 09:54:27 -0700885 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
886 DISPLAY_LIST_LOGD("%s%s %d %d", indent, "Save",
887 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
888 setViewProperties(renderer, level);
Romain Guy8a4ac612012-07-17 17:32:48 -0700889
890 if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
Chet Haaseb85967b2012-03-26 14:37:51 -0700891 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
892 renderer.restoreToCount(restoreTo);
893 renderer.endMark();
Chet Haase48659092012-05-31 15:21:51 -0700894 return drawGlStatus;
Chet Haaseb85967b2012-03-26 14:37:51 -0700895 }
Romain Guy13631f32012-01-30 17:41:55 -0800896
Chet Haase9c1e23b2011-03-24 10:51:31 -0700897 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
Romain Guyffac7fc2011-01-13 17:21:49 -0800898 int saveCount = renderer.getSaveCount() - 1;
Romain Guy8a4ac612012-07-17 17:32:48 -0700899
Romain Guyb051e892010-09-28 19:09:36 -0700900 while (!mReader.eof()) {
Romain Guy5b3b3522010-10-27 18:57:51 -0700901 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800902 if (op & OP_MAY_BE_SKIPPED_MASK) {
Romain Guy390f8822012-03-13 18:00:10 -0700903 int32_t skip = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800904 if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
905 mReader.skip(skip);
906 DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,
907 OP_NAMES[op & ~OP_MAY_BE_SKIPPED_MASK], skip);
908 continue;
909 } else {
910 op &= ~OP_MAY_BE_SKIPPED_MASK;
Romain Guy33f6beb2012-02-16 19:24:51 -0800911 }
912 }
Chet Haase9c1e23b2011-03-24 10:51:31 -0700913 logBuffer.writeCommand(level, op);
Romain Guyffac7fc2011-01-13 17:21:49 -0800914
Romain Guy8a4ac612012-07-17 17:32:48 -0700915#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
916 Caches::getInstance().eventMark(strlen(OP_NAMES[op]), OP_NAMES[op]);
917#endif
918
Romain Guy5b3b3522010-10-27 18:57:51 -0700919 switch (op) {
Chet Haasedaf98e92011-01-10 14:10:36 -0800920 case DrawGLFunction: {
921 Functor *functor = (Functor *) getInt();
922 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Romain Guy13631f32012-01-30 17:41:55 -0800923 renderer.startMark("GL functor");
Romain Guy65549432012-03-26 16:45:05 -0700924 drawGlStatus |= renderer.callDrawGLFunction(functor, dirty);
Romain Guy13631f32012-01-30 17:41:55 -0800925 renderer.endMark();
Chet Haasedaf98e92011-01-10 14:10:36 -0800926 }
927 break;
Romain Guyb051e892010-09-28 19:09:36 -0700928 case Save: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800929 int32_t rendererNum = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800930 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
931 renderer.save(rendererNum);
Romain Guyb051e892010-09-28 19:09:36 -0700932 }
933 break;
934 case Restore: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800935 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700936 renderer.restore();
937 }
938 break;
939 case RestoreToCount: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800940 int32_t restoreCount = saveCount + getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800941 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
942 renderer.restoreToCount(restoreCount);
Romain Guyb051e892010-09-28 19:09:36 -0700943 }
944 break;
945 case SaveLayer: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800946 float f1 = getFloat();
947 float f2 = getFloat();
948 float f3 = getFloat();
949 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800950 SkPaint* paint = getPaint(renderer);
Romain Guy33f6beb2012-02-16 19:24:51 -0800951 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800952 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800953 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800954 renderer.saveLayer(f1, f2, f3, f4, paint, flags);
Romain Guyb051e892010-09-28 19:09:36 -0700955 }
956 break;
Romain Guy5b3b3522010-10-27 18:57:51 -0700957 case SaveLayerAlpha: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800958 float f1 = getFloat();
959 float f2 = getFloat();
960 float f3 = getFloat();
961 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -0800962 int32_t alpha = getInt();
963 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800964 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800965 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800966 renderer.saveLayerAlpha(f1, f2, f3, f4, alpha, flags);
Romain Guy5b3b3522010-10-27 18:57:51 -0700967 }
968 break;
Romain Guyb051e892010-09-28 19:09:36 -0700969 case Translate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800970 float f1 = getFloat();
971 float f2 = getFloat();
972 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
973 renderer.translate(f1, f2);
Romain Guyb051e892010-09-28 19:09:36 -0700974 }
975 break;
976 case Rotate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800977 float rotation = getFloat();
978 DISPLAY_LIST_LOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
979 renderer.rotate(rotation);
Romain Guyb051e892010-09-28 19:09:36 -0700980 }
981 break;
982 case Scale: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800983 float sx = getFloat();
984 float sy = getFloat();
985 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
986 renderer.scale(sx, sy);
Romain Guyb051e892010-09-28 19:09:36 -0700987 }
988 break;
Romain Guy807daf72011-01-18 11:19:19 -0800989 case Skew: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800990 float sx = getFloat();
991 float sy = getFloat();
992 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
993 renderer.skew(sx, sy);
Romain Guy807daf72011-01-18 11:19:19 -0800994 }
995 break;
Romain Guyb051e892010-09-28 19:09:36 -0700996 case SetMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800997 SkMatrix* matrix = getMatrix();
998 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
999 renderer.setMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -07001000 }
1001 break;
1002 case ConcatMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001003 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -08001004 DISPLAY_LIST_LOGD(
1005 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
1006 (char*) indent, OP_NAMES[op], matrix,
1007 matrix->get(0), matrix->get(1), matrix->get(2),
1008 matrix->get(3), matrix->get(4), matrix->get(5),
1009 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haasedaf98e92011-01-10 14:10:36 -08001010 renderer.concatMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -07001011 }
1012 break;
1013 case ClipRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001014 float f1 = getFloat();
1015 float f2 = getFloat();
1016 float f3 = getFloat();
1017 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001018 int32_t regionOp = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001019 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001020 f1, f2, f3, f4, regionOp);
Chet Haasedaf98e92011-01-10 14:10:36 -08001021 renderer.clipRect(f1, f2, f3, f4, (SkRegion::Op) regionOp);
Romain Guyb051e892010-09-28 19:09:36 -07001022 }
1023 break;
Romain Guy0fe478e2010-11-08 12:08:41 -08001024 case DrawDisplayList: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001025 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -08001026 int32_t flags = getInt();
1027 DISPLAY_LIST_LOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -07001028 displayList, mWidth, mHeight, flags, level + 1);
1029 drawGlStatus |= renderer.drawDisplayList(displayList, dirty, flags, level + 1);
Romain Guy0fe478e2010-11-08 12:08:41 -08001030 }
1031 break;
Romain Guy6c319ca2011-01-11 14:29:25 -08001032 case DrawLayer: {
Chet Haased15ebf22012-09-05 11:40:29 -07001033 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001034 Layer* layer = (Layer*) getInt();
1035 float x = getFloat();
1036 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001037 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001038 if (mCaching && mMultipliedAlpha < 255) {
1039 oldAlpha = layer->getAlpha();
1040 layer->setAlpha(mMultipliedAlpha);
Chet Haasea1cff502012-02-21 13:43:44 -08001041 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001042 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001043 layer, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001044 drawGlStatus |= renderer.drawLayer(layer, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001045 if (oldAlpha >= 0) {
1046 layer->setAlpha(oldAlpha);
1047 }
Romain Guy6c319ca2011-01-11 14:29:25 -08001048 }
1049 break;
Romain Guyb051e892010-09-28 19:09:36 -07001050 case DrawBitmap: {
Chet Haased15ebf22012-09-05 11:40:29 -07001051 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001052 SkBitmap* bitmap = getBitmap();
1053 float x = getFloat();
1054 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001055 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001056 if (mCaching && mMultipliedAlpha < 255) {
1057 oldAlpha = paint->getAlpha();
Chet Haaseb85967b2012-03-26 14:37:51 -07001058 paint->setAlpha(mMultipliedAlpha);
1059 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001060 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001061 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001062 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001063 if (oldAlpha >= 0) {
1064 paint->setAlpha(oldAlpha);
1065 }
Romain Guyb051e892010-09-28 19:09:36 -07001066 }
1067 break;
1068 case DrawBitmapMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001069 SkBitmap* bitmap = getBitmap();
1070 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -08001071 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001072 DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001073 bitmap, matrix, paint);
Chet Haase48659092012-05-31 15:21:51 -07001074 drawGlStatus |= renderer.drawBitmap(bitmap, matrix, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001075 }
1076 break;
1077 case DrawBitmapRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001078 SkBitmap* bitmap = getBitmap();
1079 float f1 = getFloat();
1080 float f2 = getFloat();
1081 float f3 = getFloat();
1082 float f4 = getFloat();
1083 float f5 = getFloat();
1084 float f6 = getFloat();
1085 float f7 = getFloat();
1086 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001087 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001088 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001089 (char*) indent, OP_NAMES[op], bitmap,
1090 f1, f2, f3, f4, f5, f6, f7, f8,paint);
Chet Haase48659092012-05-31 15:21:51 -07001091 drawGlStatus |= renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001092 }
1093 break;
Romain Guye651cc62012-05-14 19:44:40 -07001094 case DrawBitmapData: {
1095 SkBitmap* bitmap = getBitmapData();
1096 float x = getFloat();
1097 float y = getFloat();
1098 SkPaint* paint = getPaint(renderer);
1099 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
1100 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001101 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Romain Guye651cc62012-05-14 19:44:40 -07001102 }
1103 break;
Romain Guy5a7b4662011-01-20 19:09:30 -08001104 case DrawBitmapMesh: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001105 int32_t verticesCount = 0;
Romain Guy5a7b4662011-01-20 19:09:30 -08001106 uint32_t colorsCount = 0;
1107
1108 SkBitmap* bitmap = getBitmap();
1109 uint32_t meshWidth = getInt();
1110 uint32_t meshHeight = getInt();
1111 float* vertices = getFloats(verticesCount);
1112 bool hasColors = getInt();
Romain Guy33f6beb2012-02-16 19:24:51 -08001113 int32_t* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -08001114 SkPaint* paint = getPaint(renderer);
Romain Guy5a7b4662011-01-20 19:09:30 -08001115
Chet Haasedaf98e92011-01-10 14:10:36 -08001116 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001117 drawGlStatus |= renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices,
1118 colors, paint);
Romain Guy5a7b4662011-01-20 19:09:30 -08001119 }
Romain Guya566b7c2011-01-23 16:36:11 -08001120 break;
Romain Guyb051e892010-09-28 19:09:36 -07001121 case DrawPatch: {
1122 int32_t* xDivs = NULL;
1123 int32_t* yDivs = NULL;
Romain Guy4bb94202010-10-12 15:59:26 -07001124 uint32_t* colors = NULL;
Romain Guyb051e892010-09-28 19:09:36 -07001125 uint32_t xDivsCount = 0;
1126 uint32_t yDivsCount = 0;
Romain Guy4bb94202010-10-12 15:59:26 -07001127 int8_t numColors = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001128
1129 SkBitmap* bitmap = getBitmap();
1130
1131 xDivs = getInts(xDivsCount);
1132 yDivs = getInts(yDivsCount);
Romain Guy4bb94202010-10-12 15:59:26 -07001133 colors = getUInts(numColors);
Romain Guyb051e892010-09-28 19:09:36 -07001134
Romain Guy9ff3cb52011-06-28 14:02:11 -07001135 float left = getFloat();
1136 float top = getFloat();
1137 float right = getFloat();
1138 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -07001139
1140 int alpha = getInt();
1141 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Romain Guy9ff3cb52011-06-28 14:02:11 -07001142
Chet Haasedaf98e92011-01-10 14:10:36 -08001143 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001144 drawGlStatus |= renderer.drawPatch(bitmap, xDivs, yDivs, colors,
Romain Guybe6f9dc2012-07-16 12:41:17 -07001145 xDivsCount, yDivsCount, numColors, left, top, right, bottom,
1146 alpha, mode);
Romain Guyb051e892010-09-28 19:09:36 -07001147 }
1148 break;
1149 case DrawColor: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001150 int32_t color = getInt();
1151 int32_t xferMode = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001152 DISPLAY_LIST_LOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haase48659092012-05-31 15:21:51 -07001153 drawGlStatus |= renderer.drawColor(color, (SkXfermode::Mode) xferMode);
Romain Guyb051e892010-09-28 19:09:36 -07001154 }
1155 break;
1156 case DrawRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001157 float f1 = getFloat();
1158 float f2 = getFloat();
1159 float f3 = getFloat();
1160 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001161 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001162 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001163 f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001164 drawGlStatus |= renderer.drawRect(f1, f2, f3, f4, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001165 }
1166 break;
Romain Guy01d58e42011-01-19 21:54:02 -08001167 case DrawRoundRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001168 float f1 = getFloat();
1169 float f2 = getFloat();
1170 float f3 = getFloat();
1171 float f4 = getFloat();
1172 float f5 = getFloat();
1173 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001174 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001175 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001176 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haase48659092012-05-31 15:21:51 -07001177 drawGlStatus |= renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001178 }
1179 break;
1180 case DrawCircle: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001181 float f1 = getFloat();
1182 float f2 = getFloat();
1183 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001184 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001185 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001186 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haase48659092012-05-31 15:21:51 -07001187 drawGlStatus |= renderer.drawCircle(f1, f2, f3, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001188 }
1189 break;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001190 case DrawOval: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001191 float f1 = getFloat();
1192 float f2 = getFloat();
1193 float f3 = getFloat();
1194 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001195 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001196 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001197 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001198 drawGlStatus |= renderer.drawOval(f1, f2, f3, f4, paint);
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001199 }
1200 break;
Romain Guy8b2f5262011-01-23 16:15:02 -08001201 case DrawArc: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001202 float f1 = getFloat();
1203 float f2 = getFloat();
1204 float f3 = getFloat();
1205 float f4 = getFloat();
1206 float f5 = getFloat();
1207 float f6 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001208 int32_t i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001209 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001210 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001211 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haase48659092012-05-31 15:21:51 -07001212 drawGlStatus |= renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
Romain Guy8b2f5262011-01-23 16:15:02 -08001213 }
1214 break;
Romain Guyb051e892010-09-28 19:09:36 -07001215 case DrawPath: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001216 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -08001217 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001218 DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haase48659092012-05-31 15:21:51 -07001219 drawGlStatus |= renderer.drawPath(path, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001220 }
1221 break;
1222 case DrawLines: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001223 int32_t count = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001224 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001225 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001226 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001227 drawGlStatus |= renderer.drawLines(points, count, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001228 }
1229 break;
Romain Guyed6fcb02011-03-21 13:11:28 -07001230 case DrawPoints: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001231 int32_t count = 0;
Romain Guyed6fcb02011-03-21 13:11:28 -07001232 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001233 SkPaint* paint = getPaint(renderer);
Romain Guyed6fcb02011-03-21 13:11:28 -07001234 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001235 drawGlStatus |= renderer.drawPoints(points, count, paint);
Romain Guyed6fcb02011-03-21 13:11:28 -07001236 }
1237 break;
Romain Guy325740f2012-02-24 16:48:34 -08001238 case DrawTextOnPath: {
1239 getText(&text);
1240 int32_t count = getInt();
1241 SkPath* path = getPath();
1242 float hOffset = getFloat();
1243 float vOffset = getFloat();
1244 SkPaint* paint = getPaint(renderer);
1245 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
1246 text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001247 drawGlStatus |= renderer.drawTextOnPath(text.text(), text.length(), count, path,
Romain Guy325740f2012-02-24 16:48:34 -08001248 hOffset, vOffset, paint);
1249 }
1250 break;
Romain Guyeb9a5362012-01-17 17:39:26 -08001251 case DrawPosText: {
1252 getText(&text);
Romain Guy33f6beb2012-02-16 19:24:51 -08001253 int32_t count = getInt();
1254 int32_t positionsCount = 0;
Romain Guyeb9a5362012-01-17 17:39:26 -08001255 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -08001256 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -08001257 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent,
1258 OP_NAMES[op], text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001259 drawGlStatus |= renderer.drawPosText(text.text(), text.length(), count,
1260 positions, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -08001261 }
1262 break;
Romain Guyc2525952012-07-27 16:41:22 -07001263 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -07001264 getText(&text);
1265 int32_t count = getInt();
1266 float x = getFloat();
1267 float y = getFloat();
1268 int32_t positionsCount = 0;
1269 float* positions = getFloats(positionsCount);
1270 SkPaint* paint = getPaint(renderer);
1271 float length = getFloat();
1272 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent,
1273 OP_NAMES[op], text.text(), text.length(), count, x, y, paint, length);
Romain Guyc2525952012-07-27 16:41:22 -07001274 drawGlStatus |= renderer.drawText(text.text(), text.length(), count,
Raph Levien996e57c2012-07-23 15:22:52 -07001275 x, y, positions, paint, length);
1276 }
1277 break;
Romain Guyb051e892010-09-28 19:09:36 -07001278 case ResetShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001279 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001280 renderer.resetShader();
1281 }
1282 break;
1283 case SetupShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001284 SkiaShader* shader = getShader();
1285 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
1286 renderer.setupShader(shader);
Romain Guyb051e892010-09-28 19:09:36 -07001287 }
1288 break;
1289 case ResetColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001290 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001291 renderer.resetColorFilter();
1292 }
1293 break;
1294 case SetupColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001295 SkiaColorFilter *colorFilter = getColorFilter();
1296 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
1297 renderer.setupColorFilter(colorFilter);
Romain Guyb051e892010-09-28 19:09:36 -07001298 }
1299 break;
1300 case ResetShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001301 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001302 renderer.resetShadow();
1303 }
1304 break;
1305 case SetupShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001306 float radius = getFloat();
1307 float dx = getFloat();
1308 float dy = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001309 int32_t color = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001310 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001311 radius, dx, dy, color);
Chet Haasedaf98e92011-01-10 14:10:36 -08001312 renderer.setupShadow(radius, dx, dy, color);
Romain Guyb051e892010-09-28 19:09:36 -07001313 }
1314 break;
Romain Guy5ff9df62012-01-23 17:09:05 -08001315 case ResetPaintFilter: {
1316 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
1317 renderer.resetPaintFilter();
1318 }
1319 break;
1320 case SetupPaintFilter: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001321 int32_t clearBits = getInt();
1322 int32_t setBits = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001323 DISPLAY_LIST_LOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op],
1324 clearBits, setBits);
1325 renderer.setupPaintFilter(clearBits, setBits);
1326 }
1327 break;
Chet Haasedaf98e92011-01-10 14:10:36 -08001328 default:
1329 DISPLAY_LIST_LOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -08001330 (char*) indent, OP_NAMES[op]);
Chet Haasedaf98e92011-01-10 14:10:36 -08001331 break;
Romain Guyb051e892010-09-28 19:09:36 -07001332 }
1333 }
Romain Guyffac7fc2011-01-13 17:21:49 -08001334
Chet Haase1271e2c2012-04-20 09:54:27 -07001335 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
1336 renderer.restoreToCount(restoreTo);
Romain Guy13631f32012-01-30 17:41:55 -08001337 renderer.endMark();
1338
Chet Haasea1cff502012-02-21 13:43:44 -08001339 DISPLAY_LIST_LOGD("%sDone (%p, %s), returning %d", (char*) indent + 2, this, mName.string(),
Romain Guy65549432012-03-26 16:45:05 -07001340 drawGlStatus);
1341 return drawGlStatus;
Romain Guyb051e892010-09-28 19:09:36 -07001342}
1343
1344///////////////////////////////////////////////////////////////////////////////
Romain Guy4aa90572010-09-26 18:40:37 -07001345// Base structure
1346///////////////////////////////////////////////////////////////////////////////
1347
Romain Guy58ecc202012-09-07 11:58:36 -07001348DisplayListRenderer::DisplayListRenderer():
1349 mCaches(Caches::getInstance()), mWriter(MIN_WRITER_SIZE),
Romain Guy54c1a642012-09-27 17:55:46 -07001350 mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false),
1351 mHasDrawOps(false), mFunctorCount(0) {
Romain Guy4aa90572010-09-26 18:40:37 -07001352}
1353
1354DisplayListRenderer::~DisplayListRenderer() {
1355 reset();
1356}
1357
1358void DisplayListRenderer::reset() {
Romain Guy4aa90572010-09-26 18:40:37 -07001359 mWriter.reset();
Chet Haase5c13d892010-10-08 08:37:55 -07001360
Romain Guy58ecc202012-09-07 11:58:36 -07001361 mCaches.resourceCache.lock();
1362
Chet Haase5c13d892010-10-08 08:37:55 -07001363 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001364 mCaches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5c13d892010-10-08 08:37:55 -07001365 }
Chet Haased98aa2d2010-10-25 15:47:32 -07001366
Romain Guy49c5fc02012-05-15 11:10:01 -07001367 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001368 mCaches.resourceCache.decrementRefcountLocked(mOwnedBitmapResources.itemAt(i));
Romain Guy49c5fc02012-05-15 11:10:01 -07001369 }
Romain Guy49c5fc02012-05-15 11:10:01 -07001370
Romain Guyd586ad92011-06-22 16:14:36 -07001371 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001372 mCaches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -07001373 }
Romain Guyd586ad92011-06-22 16:14:36 -07001374
Romain Guy43ccf462011-01-14 18:51:01 -08001375 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001376 mCaches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
Romain Guy43ccf462011-01-14 18:51:01 -08001377 }
Romain Guy43ccf462011-01-14 18:51:01 -08001378
Chet Haased34dd712012-05-02 18:50:34 -07001379 for (size_t i = 0; i < mSourcePaths.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001380 mCaches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
Chet Haased34dd712012-05-02 18:50:34 -07001381 }
Romain Guy58ecc202012-09-07 11:58:36 -07001382
Chet Haase603f6de2012-09-14 15:31:25 -07001383 for (size_t i = 0; i < mLayers.size(); i++) {
1384 mCaches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
1385 }
1386
Romain Guy58ecc202012-09-07 11:58:36 -07001387 mCaches.resourceCache.unlock();
1388
1389 mBitmapResources.clear();
1390 mOwnedBitmapResources.clear();
1391 mFilterResources.clear();
Chet Haased34dd712012-05-02 18:50:34 -07001392 mSourcePaths.clear();
1393
Romain Guy58ecc202012-09-07 11:58:36 -07001394 mShaders.clear();
1395 mShaderMap.clear();
1396
Romain Guy43ccf462011-01-14 18:51:01 -08001397 mPaints.clear();
1398 mPaintMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001399
Romain Guy2fc941e2011-02-03 15:06:05 -08001400 mPaths.clear();
1401 mPathMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001402
Chet Haased98aa2d2010-10-25 15:47:32 -07001403 mMatrices.clear();
Romain Guy04c9d8c2011-08-25 14:01:48 -07001404
Chet Haase603f6de2012-09-14 15:31:25 -07001405 mLayers.clear();
1406
Romain Guy04c9d8c2011-08-25 14:01:48 -07001407 mHasDrawOps = false;
Romain Guy54c1a642012-09-27 17:55:46 -07001408 mFunctorCount = 0;
Romain Guy4aa90572010-09-26 18:40:37 -07001409}
1410
1411///////////////////////////////////////////////////////////////////////////////
1412// Operations
1413///////////////////////////////////////////////////////////////////////////////
1414
Jeff Brown162a0212011-07-21 17:02:54 -07001415DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
1416 if (!displayList) {
1417 displayList = new DisplayList(*this);
Chet Haase5977baa2011-01-05 18:01:22 -08001418 } else {
Jeff Brown162a0212011-07-21 17:02:54 -07001419 displayList->initFromDisplayListRenderer(*this, true);
Chet Haase5977baa2011-01-05 18:01:22 -08001420 }
Romain Guy04c9d8c2011-08-25 14:01:48 -07001421 displayList->setRenderable(mHasDrawOps);
Jeff Brown162a0212011-07-21 17:02:54 -07001422 return displayList;
Chet Haase5977baa2011-01-05 18:01:22 -08001423}
1424
Romain Guy49c5fc02012-05-15 11:10:01 -07001425bool DisplayListRenderer::isDeferred() {
1426 return true;
1427}
1428
Romain Guyb051e892010-09-28 19:09:36 -07001429void DisplayListRenderer::setViewport(int width, int height) {
1430 mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
1431
1432 mWidth = width;
1433 mHeight = height;
1434}
1435
Chet Haase44b2fe32012-06-06 19:03:58 -07001436int DisplayListRenderer::prepareDirty(float left, float top,
Romain Guy7d7b5492011-01-24 16:33:45 -08001437 float right, float bottom, bool opaque) {
Romain Guyb051e892010-09-28 19:09:36 -07001438 mSnapshot = new Snapshot(mFirstSnapshot,
1439 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
1440 mSaveCount = 1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001441
Romain Guyb051e892010-09-28 19:09:36 -07001442 mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
Romain Guy45e4c3d2012-09-11 17:17:07 -07001443 mDirtyClip = opaque;
1444
Romain Guy27454a42011-01-23 12:01:41 -08001445 mRestoreSaveCount = -1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001446
Chet Haase44b2fe32012-06-06 19:03:58 -07001447 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Romain Guy27454a42011-01-23 12:01:41 -08001448}
1449
1450void DisplayListRenderer::finish() {
1451 insertRestoreToCount();
Romain Guy33f6beb2012-02-16 19:24:51 -08001452 insertTranlate();
Romain Guyb051e892010-09-28 19:09:36 -07001453}
1454
Chet Haasedaf98e92011-01-10 14:10:36 -08001455void DisplayListRenderer::interrupt() {
Chet Haasedaf98e92011-01-10 14:10:36 -08001456}
Romain Guy2b1847e2011-01-26 13:43:01 -08001457
Chet Haasedaf98e92011-01-10 14:10:36 -08001458void DisplayListRenderer::resume() {
Romain Guy4aa90572010-09-26 18:40:37 -07001459}
1460
Romain Guy65549432012-03-26 16:45:05 -07001461status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
Romain Guycabfcc12011-03-07 18:06:46 -08001462 // Ignore dirty during recording, it matters only when we replay
Chet Haasedaf98e92011-01-10 14:10:36 -08001463 addOp(DisplayList::DrawGLFunction);
1464 addInt((int) functor);
Romain Guy54c1a642012-09-27 17:55:46 -07001465 mFunctorCount++;
Romain Guy65549432012-03-26 16:45:05 -07001466 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Chet Haasedaf98e92011-01-10 14:10:36 -08001467}
1468
Romain Guy4aa90572010-09-26 18:40:37 -07001469int DisplayListRenderer::save(int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001470 addOp(DisplayList::Save);
Romain Guy4aa90572010-09-26 18:40:37 -07001471 addInt(flags);
1472 return OpenGLRenderer::save(flags);
1473}
1474
1475void DisplayListRenderer::restore() {
Romain Guy04c9d8c2011-08-25 14:01:48 -07001476 if (mRestoreSaveCount < 0) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001477 restoreToCount(getSaveCount() - 1);
1478 return;
Romain Guy04c9d8c2011-08-25 14:01:48 -07001479 }
Romain Guy33f6beb2012-02-16 19:24:51 -08001480
1481 mRestoreSaveCount--;
1482 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001483 OpenGLRenderer::restore();
1484}
1485
1486void DisplayListRenderer::restoreToCount(int saveCount) {
Romain Guy27454a42011-01-23 12:01:41 -08001487 mRestoreSaveCount = saveCount;
Romain Guy33f6beb2012-02-16 19:24:51 -08001488 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001489 OpenGLRenderer::restoreToCount(saveCount);
1490}
1491
1492int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001493 SkPaint* p, int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001494 addOp(DisplayList::SaveLayer);
Romain Guy4aa90572010-09-26 18:40:37 -07001495 addBounds(left, top, right, bottom);
1496 addPaint(p);
1497 addInt(flags);
Romain Guyb051e892010-09-28 19:09:36 -07001498 return OpenGLRenderer::save(flags);
Romain Guy4aa90572010-09-26 18:40:37 -07001499}
1500
Romain Guy5b3b3522010-10-27 18:57:51 -07001501int DisplayListRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
1502 int alpha, int flags) {
1503 addOp(DisplayList::SaveLayerAlpha);
1504 addBounds(left, top, right, bottom);
1505 addInt(alpha);
1506 addInt(flags);
1507 return OpenGLRenderer::save(flags);
1508}
1509
Romain Guy4aa90572010-09-26 18:40:37 -07001510void DisplayListRenderer::translate(float dx, float dy) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001511 mHasTranslate = true;
1512 mTranslateX += dx;
1513 mTranslateY += dy;
1514 insertRestoreToCount();
Romain Guy4aa90572010-09-26 18:40:37 -07001515 OpenGLRenderer::translate(dx, dy);
1516}
1517
1518void DisplayListRenderer::rotate(float degrees) {
Romain Guyb051e892010-09-28 19:09:36 -07001519 addOp(DisplayList::Rotate);
Romain Guy4aa90572010-09-26 18:40:37 -07001520 addFloat(degrees);
1521 OpenGLRenderer::rotate(degrees);
1522}
1523
1524void DisplayListRenderer::scale(float sx, float sy) {
Romain Guyb051e892010-09-28 19:09:36 -07001525 addOp(DisplayList::Scale);
Romain Guy4aa90572010-09-26 18:40:37 -07001526 addPoint(sx, sy);
1527 OpenGLRenderer::scale(sx, sy);
1528}
1529
Romain Guy807daf72011-01-18 11:19:19 -08001530void DisplayListRenderer::skew(float sx, float sy) {
1531 addOp(DisplayList::Skew);
1532 addPoint(sx, sy);
1533 OpenGLRenderer::skew(sx, sy);
1534}
1535
Romain Guy4aa90572010-09-26 18:40:37 -07001536void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001537 addOp(DisplayList::SetMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001538 addMatrix(matrix);
1539 OpenGLRenderer::setMatrix(matrix);
1540}
1541
1542void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001543 addOp(DisplayList::ConcatMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001544 addMatrix(matrix);
1545 OpenGLRenderer::concatMatrix(matrix);
1546}
1547
1548bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
1549 SkRegion::Op op) {
Romain Guyb051e892010-09-28 19:09:36 -07001550 addOp(DisplayList::ClipRect);
Romain Guy4aa90572010-09-26 18:40:37 -07001551 addBounds(left, top, right, bottom);
1552 addInt(op);
1553 return OpenGLRenderer::clipRect(left, top, right, bottom, op);
1554}
1555
Romain Guy65549432012-03-26 16:45:05 -07001556status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
Chet Haase1271e2c2012-04-20 09:54:27 -07001557 Rect& dirty, int32_t flags, uint32_t level) {
Romain Guycabfcc12011-03-07 18:06:46 -08001558 // dirty is an out parameter and should not be recorded,
1559 // it matters only when replaying the display list
Chet Haaseb85967b2012-03-26 14:37:51 -07001560
1561 addOp(DisplayList::DrawDisplayList);
Romain Guy0fe478e2010-11-08 12:08:41 -08001562 addDisplayList(displayList);
Romain Guy33f6beb2012-02-16 19:24:51 -08001563 addInt(flags);
Romain Guy65549432012-03-26 16:45:05 -07001564 return DrawGlInfo::kStatusDone;
Romain Guy0fe478e2010-11-08 12:08:41 -08001565}
1566
Chet Haase48659092012-05-31 15:21:51 -07001567status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
Romain Guy6c319ca2011-01-11 14:29:25 -08001568 addOp(DisplayList::DrawLayer);
Chet Haase603f6de2012-09-14 15:31:25 -07001569 addLayer(layer);
Romain Guyada830f2011-01-13 12:13:20 -08001570 addPoint(x, y);
Romain Guy6c319ca2011-01-11 14:29:25 -08001571 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001572 return DrawGlInfo::kStatusDone;
Romain Guy6c319ca2011-01-11 14:29:25 -08001573}
1574
Chet Haase48659092012-05-31 15:21:51 -07001575status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001576 const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
1577 uint32_t* location = addOp(DisplayList::DrawBitmap, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001578 addBitmap(bitmap);
1579 addPoint(left, top);
1580 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001581 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001582 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001583}
1584
Chet Haase48659092012-05-31 15:21:51 -07001585status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001586 Rect r(0.0f, 0.0f, bitmap->width(), bitmap->height());
1587 const mat4 transform(*matrix);
1588 transform.mapRect(r);
1589
1590 const bool reject = quickReject(r.left, r.top, r.right, r.bottom);
1591 uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001592 addBitmap(bitmap);
1593 addMatrix(matrix);
1594 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001595 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001596 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001597}
1598
Chet Haase48659092012-05-31 15:21:51 -07001599status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
Romain Guy4aa90572010-09-26 18:40:37 -07001600 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -07001601 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001602 const bool reject = quickReject(dstLeft, dstTop, dstRight, dstBottom);
1603 uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001604 addBitmap(bitmap);
1605 addBounds(srcLeft, srcTop, srcRight, srcBottom);
1606 addBounds(dstLeft, dstTop, dstRight, dstBottom);
1607 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001608 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001609 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001610}
1611
Chet Haase48659092012-05-31 15:21:51 -07001612status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
1613 SkPaint* paint) {
Romain Guy95c21d02012-07-17 17:46:03 -07001614 const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
Romain Guye651cc62012-05-14 19:44:40 -07001615 uint32_t* location = addOp(DisplayList::DrawBitmapData, reject);
1616 addBitmapData(bitmap);
1617 addPoint(left, top);
1618 addPaint(paint);
1619 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001620 return DrawGlInfo::kStatusDone;
Romain Guye651cc62012-05-14 19:44:40 -07001621}
1622
Chet Haase48659092012-05-31 15:21:51 -07001623status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
Romain Guy5a7b4662011-01-20 19:09:30 -08001624 float* vertices, int* colors, SkPaint* paint) {
1625 addOp(DisplayList::DrawBitmapMesh);
1626 addBitmap(bitmap);
1627 addInt(meshWidth);
1628 addInt(meshHeight);
1629 addFloats(vertices, (meshWidth + 1) * (meshHeight + 1) * 2);
1630 if (colors) {
1631 addInt(1);
1632 addInts(colors, (meshWidth + 1) * (meshHeight + 1));
1633 } else {
1634 addInt(0);
1635 }
1636 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001637 return DrawGlInfo::kStatusDone;
Romain Guy5a7b4662011-01-20 19:09:30 -08001638}
1639
Chet Haase48659092012-05-31 15:21:51 -07001640status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs,
1641 const int32_t* yDivs, const uint32_t* colors, uint32_t width, uint32_t height,
1642 int8_t numColors, float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guybe6f9dc2012-07-16 12:41:17 -07001643 int alpha;
1644 SkXfermode::Mode mode;
1645 OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
1646
Romain Guy33f6beb2012-02-16 19:24:51 -08001647 const bool reject = quickReject(left, top, right, bottom);
1648 uint32_t* location = addOp(DisplayList::DrawPatch, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001649 addBitmap(bitmap);
1650 addInts(xDivs, width);
1651 addInts(yDivs, height);
Romain Guy4bb94202010-10-12 15:59:26 -07001652 addUInts(colors, numColors);
Romain Guy4aa90572010-09-26 18:40:37 -07001653 addBounds(left, top, right, bottom);
Romain Guybe6f9dc2012-07-16 12:41:17 -07001654 addInt(alpha);
1655 addInt(mode);
Romain Guy33f6beb2012-02-16 19:24:51 -08001656 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001657 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001658}
1659
Chet Haase48659092012-05-31 15:21:51 -07001660status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
Romain Guyb051e892010-09-28 19:09:36 -07001661 addOp(DisplayList::DrawColor);
Romain Guy4aa90572010-09-26 18:40:37 -07001662 addInt(color);
1663 addInt(mode);
Chet Haase48659092012-05-31 15:21:51 -07001664 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001665}
1666
Chet Haase48659092012-05-31 15:21:51 -07001667status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001668 SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001669 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
1670 quickReject(left, top, right, bottom);
1671 uint32_t* location = addOp(DisplayList::DrawRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001672 addBounds(left, top, right, bottom);
1673 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001674 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001675 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001676}
1677
Chet Haase48659092012-05-31 15:21:51 -07001678status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
Chet Haasea1cff502012-02-21 13:43:44 -08001679 float rx, float ry, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001680 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
1681 quickReject(left, top, right, bottom);
1682 uint32_t* location = addOp(DisplayList::DrawRoundRect, reject);
Romain Guy01d58e42011-01-19 21:54:02 -08001683 addBounds(left, top, right, bottom);
1684 addPoint(rx, ry);
1685 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001686 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001687 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001688}
1689
Chet Haase48659092012-05-31 15:21:51 -07001690status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
Romain Guy01d58e42011-01-19 21:54:02 -08001691 addOp(DisplayList::DrawCircle);
1692 addPoint(x, y);
1693 addFloat(radius);
1694 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001695 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001696}
1697
Chet Haase48659092012-05-31 15:21:51 -07001698status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001699 SkPaint* paint) {
1700 addOp(DisplayList::DrawOval);
1701 addBounds(left, top, right, bottom);
1702 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001703 return DrawGlInfo::kStatusDone;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001704}
1705
Chet Haase48659092012-05-31 15:21:51 -07001706status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
Romain Guy8b2f5262011-01-23 16:15:02 -08001707 float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
Romain Guy82d41a52011-01-24 21:53:42 -08001708 addOp(DisplayList::DrawArc);
Romain Guy8b2f5262011-01-23 16:15:02 -08001709 addBounds(left, top, right, bottom);
1710 addPoint(startAngle, sweepAngle);
1711 addInt(useCenter ? 1 : 0);
1712 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001713 return DrawGlInfo::kStatusDone;
Romain Guy8b2f5262011-01-23 16:15:02 -08001714}
1715
Chet Haase48659092012-05-31 15:21:51 -07001716status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001717 float left, top, offset;
1718 uint32_t width, height;
1719 computePathBounds(path, paint, left, top, offset, width, height);
1720
Romain Guy95c21d02012-07-17 17:46:03 -07001721 left -= offset;
1722 top -= offset;
1723
1724 const bool reject = quickReject(left, top, left + width, top + height);
Romain Guy33f6beb2012-02-16 19:24:51 -08001725 uint32_t* location = addOp(DisplayList::DrawPath, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001726 addPath(path);
1727 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001728 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001729 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001730}
1731
Chet Haase48659092012-05-31 15:21:51 -07001732status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -07001733 addOp(DisplayList::DrawLines);
Romain Guy4aa90572010-09-26 18:40:37 -07001734 addFloats(points, count);
1735 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001736 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001737}
1738
Chet Haase48659092012-05-31 15:21:51 -07001739status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
Romain Guyed6fcb02011-03-21 13:11:28 -07001740 addOp(DisplayList::DrawPoints);
1741 addFloats(points, count);
1742 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001743 return DrawGlInfo::kStatusDone;
Romain Guyed6fcb02011-03-21 13:11:28 -07001744}
1745
Chet Haase48659092012-05-31 15:21:51 -07001746status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
Romain Guy325740f2012-02-24 16:48:34 -08001747 SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001748 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001749 addOp(DisplayList::DrawTextOnPath);
1750 addText(text, bytesCount);
1751 addInt(count);
1752 addPath(path);
1753 addFloat(hOffset);
1754 addFloat(vOffset);
1755 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001756 SkPaint* addedPaint = addPaint(paint);
1757 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1758 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001759 return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001760}
1761
Chet Haase48659092012-05-31 15:21:51 -07001762status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
Romain Guyeb9a5362012-01-17 17:39:26 -08001763 const float* positions, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001764 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001765 addOp(DisplayList::DrawPosText);
1766 addText(text, bytesCount);
1767 addInt(count);
1768 addFloats(positions, count * 2);
1769 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001770 SkPaint* addedPaint = addPaint(paint);
1771 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1772 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001773 return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001774}
1775
Romain Guyc2525952012-07-27 16:41:22 -07001776status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
Raph Levien996e57c2012-07-23 15:22:52 -07001777 float x, float y, const float* positions, SkPaint* paint, float length) {
1778 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
1779
1780 // TODO: We should probably make a copy of the paint instead of modifying
1781 // it; modifying the paint will change its generationID the first
1782 // time, which might impact caches. More investigation needed to
1783 // see if it matters.
1784 // If we make a copy, then drawTextDecorations() should *not* make
1785 // its own copy as it does right now.
1786 // Beware: this needs Glyph encoding (already done on the Paint constructor)
1787 paint->setAntiAlias(true);
1788 if (length < 0.0f) length = paint->measureText(text, bytesCount);
1789
1790 bool reject = false;
1791 if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) {
1792 SkPaint::FontMetrics metrics;
1793 paint->getFontMetrics(&metrics, 0.0f);
1794 reject = quickReject(x, y + metrics.fTop, x + length, y + metrics.fBottom);
1795 }
1796
Romain Guyc2525952012-07-27 16:41:22 -07001797 uint32_t* location = addOp(DisplayList::DrawText, reject);
Raph Levien996e57c2012-07-23 15:22:52 -07001798 addText(text, bytesCount);
1799 addInt(count);
1800 addFloat(x);
1801 addFloat(y);
1802 addFloats(positions, count * 2);
Chet Haasee816bae2012-08-09 13:39:02 -07001803 SkPaint* addedPaint = addPaint(paint);
1804 if (!reject) {
1805 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1806 fontRenderer.precache(addedPaint, text, count);
1807 }
Raph Levien996e57c2012-07-23 15:22:52 -07001808 addFloat(length);
1809 addSkip(location);
1810 return DrawGlInfo::kStatusDone;
1811}
1812
Romain Guy4aa90572010-09-26 18:40:37 -07001813void DisplayListRenderer::resetShader() {
Romain Guyb051e892010-09-28 19:09:36 -07001814 addOp(DisplayList::ResetShader);
Romain Guy4aa90572010-09-26 18:40:37 -07001815}
1816
1817void DisplayListRenderer::setupShader(SkiaShader* shader) {
Chet Haase5c13d892010-10-08 08:37:55 -07001818 addOp(DisplayList::SetupShader);
1819 addShader(shader);
Romain Guy4aa90572010-09-26 18:40:37 -07001820}
1821
1822void DisplayListRenderer::resetColorFilter() {
Romain Guyb051e892010-09-28 19:09:36 -07001823 addOp(DisplayList::ResetColorFilter);
Romain Guy4aa90572010-09-26 18:40:37 -07001824}
1825
1826void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
Chet Haasead93c2b2010-10-22 16:17:12 -07001827 addOp(DisplayList::SetupColorFilter);
1828 addColorFilter(filter);
Romain Guy4aa90572010-09-26 18:40:37 -07001829}
1830
1831void DisplayListRenderer::resetShadow() {
Romain Guyb051e892010-09-28 19:09:36 -07001832 addOp(DisplayList::ResetShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001833}
1834
1835void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
Romain Guyb051e892010-09-28 19:09:36 -07001836 addOp(DisplayList::SetupShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001837 addFloat(radius);
1838 addPoint(dx, dy);
1839 addInt(color);
Romain Guy4aa90572010-09-26 18:40:37 -07001840}
1841
Romain Guy5ff9df62012-01-23 17:09:05 -08001842void DisplayListRenderer::resetPaintFilter() {
1843 addOp(DisplayList::ResetPaintFilter);
1844}
1845
1846void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
1847 addOp(DisplayList::SetupPaintFilter);
1848 addInt(clearBits);
1849 addInt(setBits);
1850}
1851
Romain Guy4aa90572010-09-26 18:40:37 -07001852}; // namespace uirenderer
1853}; // namespace android