blob: 589d5c2eb98557aa5787e9c028f08b66ef936399 [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
Romain Guybb0acdf2012-03-05 13:44:35 -0800108void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) {
109 if (displayList) {
110 DISPLAY_LIST_LOGD("Deferring display list destruction");
111 Caches::getInstance().deleteDisplayListDeferred(displayList);
112 }
113}
114
Chet Haased63cbd12011-02-03 16:32:46 -0800115void DisplayList::clearResources() {
Chet Haase5977baa2011-01-05 18:01:22 -0800116 sk_free((void*) mReader.base());
Romain Guy034de6b2012-09-27 19:01:55 -0700117 mReader.setMemory(NULL, 0);
Chet Haase5977baa2011-01-05 18:01:22 -0800118
Chet Haase1271e2c2012-04-20 09:54:27 -0700119 delete mTransformMatrix;
120 delete mTransformCamera;
121 delete mTransformMatrix3D;
122 delete mStaticMatrix;
123 delete mAnimationMatrix;
Romain Guy58ecc202012-09-07 11:58:36 -0700124
Chet Haase1271e2c2012-04-20 09:54:27 -0700125 mTransformMatrix = NULL;
126 mTransformCamera = NULL;
127 mTransformMatrix3D = NULL;
128 mStaticMatrix = NULL;
129 mAnimationMatrix = NULL;
Chet Haasea1cff502012-02-21 13:43:44 -0800130
Chet Haase5977baa2011-01-05 18:01:22 -0800131 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700132 caches.unregisterFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700133 caches.resourceCache.lock();
Chet Haase5977baa2011-01-05 18:01:22 -0800134
135 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700136 caches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800137 }
Chet Haase5977baa2011-01-05 18:01:22 -0800138
Romain Guy49c5fc02012-05-15 11:10:01 -0700139 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
140 SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
Romain Guy58ecc202012-09-07 11:58:36 -0700141 caches.resourceCache.decrementRefcountLocked(bitmap);
142 caches.resourceCache.destructorLocked(bitmap);
Romain Guy49c5fc02012-05-15 11:10:01 -0700143 }
Romain Guy49c5fc02012-05-15 11:10:01 -0700144
Romain Guyd586ad92011-06-22 16:14:36 -0700145 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700146 caches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -0700147 }
Romain Guyd586ad92011-06-22 16:14:36 -0700148
Romain Guy24c00212011-01-14 15:31:00 -0800149 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700150 caches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
151 caches.resourceCache.destructorLocked(mShaders.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800152 }
Romain Guy58ecc202012-09-07 11:58:36 -0700153
154 for (size_t i = 0; i < mSourcePaths.size(); i++) {
155 caches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
156 }
157
Chet Haase603f6de2012-09-14 15:31:25 -0700158 for (size_t i = 0; i < mLayers.size(); i++) {
159 caches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
160 }
161
Romain Guy58ecc202012-09-07 11:58:36 -0700162 caches.resourceCache.unlock();
Chet Haase5977baa2011-01-05 18:01:22 -0800163
164 for (size_t i = 0; i < mPaints.size(); i++) {
165 delete mPaints.itemAt(i);
166 }
Chet Haase5977baa2011-01-05 18:01:22 -0800167
Romain Guy2fc941e2011-02-03 15:06:05 -0800168 for (size_t i = 0; i < mPaths.size(); i++) {
Romain Guy1af23a32011-03-24 16:03:55 -0700169 SkPath* path = mPaths.itemAt(i);
170 caches.pathCache.remove(path);
171 delete path;
Romain Guy2fc941e2011-02-03 15:06:05 -0800172 }
Chet Haased34dd712012-05-02 18:50:34 -0700173
Chet Haase5977baa2011-01-05 18:01:22 -0800174 for (size_t i = 0; i < mMatrices.size(); i++) {
175 delete mMatrices.itemAt(i);
176 }
Romain Guy58ecc202012-09-07 11:58:36 -0700177
178 mBitmapResources.clear();
179 mOwnedBitmapResources.clear();
180 mFilterResources.clear();
181 mShaders.clear();
182 mSourcePaths.clear();
183 mPaints.clear();
184 mPaths.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800185 mMatrices.clear();
Chet Haase603f6de2012-09-14 15:31:25 -0700186 mLayers.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800187}
188
Chet Haase6a2d17f2012-09-30 12:14:13 -0700189void DisplayList::reset() {
190 clearResources();
191 init();
192}
193
Chet Haased63cbd12011-02-03 16:32:46 -0800194void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
Romain Guyb051e892010-09-28 19:09:36 -0700195
Chet Haased63cbd12011-02-03 16:32:46 -0800196 if (reusing) {
197 // re-using display list - clear out previous allocations
198 clearResources();
199 }
Romain Guy034de6b2012-09-27 19:01:55 -0700200
201 init();
Chet Haased63cbd12011-02-03 16:32:46 -0800202
Chet Haase6a2d17f2012-09-30 12:14:13 -0700203 const SkWriter32& writer = recorder.writeStream();
Romain Guy034de6b2012-09-27 19:01:55 -0700204 if (writer.size() == 0) {
205 return;
206 }
207
Romain Guy65b345f2011-07-27 18:51:50 -0700208 mSize = writer.size();
209 void* buffer = sk_malloc_throw(mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700210 writer.flatten(buffer);
Romain Guy65b345f2011-07-27 18:51:50 -0700211 mReader.setMemory(buffer, mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700212
Romain Guy54c1a642012-09-27 17:55:46 -0700213 mFunctorCount = recorder.getFunctorCount();
214
Chet Haase5c13d892010-10-08 08:37:55 -0700215 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700216 caches.registerFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700217 caches.resourceCache.lock();
Romain Guyb051e892010-09-28 19:09:36 -0700218
Romain Guy49c5fc02012-05-15 11:10:01 -0700219 const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
Chet Haase5c13d892010-10-08 08:37:55 -0700220 for (size_t i = 0; i < bitmapResources.size(); i++) {
221 SkBitmap* resource = bitmapResources.itemAt(i);
222 mBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700223 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700224 }
Chet Haased98aa2d2010-10-25 15:47:32 -0700225
Romain Guy49c5fc02012-05-15 11:10:01 -0700226 const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources();
227 for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
228 SkBitmap* resource = ownedBitmapResources.itemAt(i);
229 mOwnedBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700230 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guy49c5fc02012-05-15 11:10:01 -0700231 }
232
233 const Vector<SkiaColorFilter*>& filterResources = recorder.getFilterResources();
Romain Guyd586ad92011-06-22 16:14:36 -0700234 for (size_t i = 0; i < filterResources.size(); i++) {
235 SkiaColorFilter* resource = filterResources.itemAt(i);
236 mFilterResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700237 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyd586ad92011-06-22 16:14:36 -0700238 }
239
Romain Guy49c5fc02012-05-15 11:10:01 -0700240 const Vector<SkiaShader*>& shaders = recorder.getShaders();
Romain Guy24c00212011-01-14 15:31:00 -0800241 for (size_t i = 0; i < shaders.size(); i++) {
Romain Guyd586ad92011-06-22 16:14:36 -0700242 SkiaShader* resource = shaders.itemAt(i);
243 mShaders.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700244 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700245 }
246
Romain Guy58ecc202012-09-07 11:58:36 -0700247 const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths();
248 for (size_t i = 0; i < sourcePaths.size(); i++) {
249 mSourcePaths.add(sourcePaths.itemAt(i));
250 caches.resourceCache.incrementRefcountLocked(sourcePaths.itemAt(i));
251 }
252
Chet Haase603f6de2012-09-14 15:31:25 -0700253 const Vector<Layer*>& layers = recorder.getLayers();
254 for (size_t i = 0; i < layers.size(); i++) {
255 mLayers.add(layers.itemAt(i));
256 caches.resourceCache.incrementRefcountLocked(layers.itemAt(i));
257 }
258
Romain Guy58ecc202012-09-07 11:58:36 -0700259 caches.resourceCache.unlock();
260
Romain Guy49c5fc02012-05-15 11:10:01 -0700261 const Vector<SkPaint*>& paints = recorder.getPaints();
Chet Haased98aa2d2010-10-25 15:47:32 -0700262 for (size_t i = 0; i < paints.size(); i++) {
263 mPaints.add(paints.itemAt(i));
264 }
265
Romain Guy49c5fc02012-05-15 11:10:01 -0700266 const Vector<SkPath*>& paths = recorder.getPaths();
Romain Guy2fc941e2011-02-03 15:06:05 -0800267 for (size_t i = 0; i < paths.size(); i++) {
268 mPaths.add(paths.itemAt(i));
269 }
270
Romain Guy49c5fc02012-05-15 11:10:01 -0700271 const Vector<SkMatrix*>& matrices = recorder.getMatrices();
Chet Haased98aa2d2010-10-25 15:47:32 -0700272 for (size_t i = 0; i < matrices.size(); i++) {
273 mMatrices.add(matrices.itemAt(i));
274 }
Romain Guyb051e892010-09-28 19:09:36 -0700275}
276
Romain Guyb051e892010-09-28 19:09:36 -0700277void DisplayList::init() {
Romain Guy65b345f2011-07-27 18:51:50 -0700278 mSize = 0;
Romain Guy04c9d8c2011-08-25 14:01:48 -0700279 mIsRenderable = true;
Romain Guy034de6b2012-09-27 19:01:55 -0700280 mFunctorCount = 0;
Chet Haase6a2d17f2012-09-30 12:14:13 -0700281 mLeft = 0;
282 mTop = 0;
283 mRight = 0;
284 mBottom = 0;
285 mClipChildren = true;
286 mAlpha = 1;
287 mMultipliedAlpha = 255;
288 mHasOverlappingRendering = true;
289 mTranslationX = 0;
290 mTranslationY = 0;
291 mRotation = 0;
292 mRotationX = 0;
293 mRotationY= 0;
294 mScaleX = 1;
295 mScaleY = 1;
296 mPivotX = 0;
297 mPivotY = 0;
298 mCameraDistance = 0;
299 mMatrixDirty = false;
300 mMatrixFlags = 0;
301 mPrevWidth = -1;
302 mPrevHeight = -1;
303 mWidth = 0;
304 mHeight = 0;
305 mPivotExplicitlySet = false;
306 mCaching = false;
Romain Guy65b345f2011-07-27 18:51:50 -0700307}
308
309size_t DisplayList::getSize() {
310 return mSize;
Romain Guyb051e892010-09-28 19:09:36 -0700311}
312
Chet Haaseed30fd82011-04-22 16:18:45 -0700313/**
314 * This function is a simplified version of replay(), where we simply retrieve and log the
315 * display list. This function should remain in sync with the replay() function.
316 */
317void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
318 TextContainer text;
319
320 uint32_t count = (level + 1) * 2;
321 char indent[count + 1];
322 for (uint32_t i = 0; i < count; i++) {
323 indent[i] = ' ';
324 }
325 indent[count] = '\0';
Romain Guyddf74372012-05-22 14:07:07 -0700326 ALOGD("%sStart display list (%p, %s, render=%d)", (char*) indent + 2, this,
327 mName.string(), isRenderable());
Chet Haaseed30fd82011-04-22 16:18:45 -0700328
Chet Haase1271e2c2012-04-20 09:54:27 -0700329 ALOGD("%s%s %d", indent, "Save", SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
Chet Haaseed30fd82011-04-22 16:18:45 -0700330 int saveCount = renderer.getSaveCount() - 1;
331
Chet Haasea1cff502012-02-21 13:43:44 -0800332 outputViewProperties(renderer, (char*) indent);
Chet Haaseed30fd82011-04-22 16:18:45 -0700333 mReader.rewind();
334
335 while (!mReader.eof()) {
336 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800337 if (op & OP_MAY_BE_SKIPPED_MASK) {
338 int skip = mReader.readInt();
339 ALOGD("%sSkip %d", (char*) indent, skip);
340 op &= ~OP_MAY_BE_SKIPPED_MASK;
Chet Haasea1cff502012-02-21 13:43:44 -0800341 }
Chet Haaseed30fd82011-04-22 16:18:45 -0700342
343 switch (op) {
344 case DrawGLFunction: {
345 Functor *functor = (Functor *) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000346 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Chet Haaseed30fd82011-04-22 16:18:45 -0700347 }
348 break;
349 case Save: {
350 int rendererNum = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000351 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
Chet Haaseed30fd82011-04-22 16:18:45 -0700352 }
353 break;
354 case Restore: {
Steve Block5baa3a62011-12-20 16:23:08 +0000355 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700356 }
357 break;
358 case RestoreToCount: {
359 int restoreCount = saveCount + getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000360 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
Chet Haaseed30fd82011-04-22 16:18:45 -0700361 }
362 break;
363 case SaveLayer: {
364 float f1 = getFloat();
365 float f2 = getFloat();
366 float f3 = getFloat();
367 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800368 SkPaint* paint = getPaint(renderer);
Chet Haaseed30fd82011-04-22 16:18:45 -0700369 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000370 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800371 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700372 }
373 break;
374 case SaveLayerAlpha: {
375 float f1 = getFloat();
376 float f2 = getFloat();
377 float f3 = getFloat();
378 float f4 = getFloat();
379 int alpha = getInt();
380 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000381 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800382 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700383 }
384 break;
385 case Translate: {
386 float f1 = getFloat();
387 float f2 = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000388 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
Chet Haaseed30fd82011-04-22 16:18:45 -0700389 }
390 break;
391 case Rotate: {
392 float rotation = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000393 ALOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
Chet Haaseed30fd82011-04-22 16:18:45 -0700394 }
395 break;
396 case Scale: {
397 float sx = getFloat();
398 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000399 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700400 }
401 break;
402 case Skew: {
403 float sx = getFloat();
404 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000405 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700406 }
407 break;
408 case SetMatrix: {
409 SkMatrix* matrix = getMatrix();
Steve Block5baa3a62011-12-20 16:23:08 +0000410 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
Chet Haaseed30fd82011-04-22 16:18:45 -0700411 }
412 break;
413 case ConcatMatrix: {
414 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -0800415 ALOGD("%s%s new concat %p: [%f, %f, %f] [%f, %f, %f] [%f, %f, %f]",
416 (char*) indent, OP_NAMES[op], matrix, matrix->get(0), matrix->get(1),
417 matrix->get(2), matrix->get(3), matrix->get(4), matrix->get(5),
418 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haaseed30fd82011-04-22 16:18:45 -0700419 }
420 break;
421 case ClipRect: {
422 float f1 = getFloat();
423 float f2 = getFloat();
424 float f3 = getFloat();
425 float f4 = getFloat();
426 int regionOp = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000427 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800428 f1, f2, f3, f4, regionOp);
Chet Haaseed30fd82011-04-22 16:18:45 -0700429 }
430 break;
431 case DrawDisplayList: {
432 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -0800433 int32_t flags = getInt();
434 ALOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -0700435 displayList, mWidth, mHeight, flags, level + 1);
Chet Haaseed30fd82011-04-22 16:18:45 -0700436 renderer.outputDisplayList(displayList, level + 1);
437 }
438 break;
439 case DrawLayer: {
440 Layer* layer = (Layer*) getInt();
441 float x = getFloat();
442 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800443 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000444 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800445 layer, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700446 }
447 break;
448 case DrawBitmap: {
449 SkBitmap* bitmap = getBitmap();
450 float x = getFloat();
451 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800452 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000453 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800454 bitmap, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700455 }
456 break;
457 case DrawBitmapMatrix: {
458 SkBitmap* bitmap = getBitmap();
459 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -0800460 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000461 ALOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800462 bitmap, matrix, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700463 }
464 break;
465 case DrawBitmapRect: {
466 SkBitmap* bitmap = getBitmap();
467 float f1 = getFloat();
468 float f2 = getFloat();
469 float f3 = getFloat();
470 float f4 = getFloat();
471 float f5 = getFloat();
472 float f6 = getFloat();
473 float f7 = getFloat();
474 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800475 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000476 ALOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800477 (char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700478 }
479 break;
Romain Guye651cc62012-05-14 19:44:40 -0700480 case DrawBitmapData: {
481 SkBitmap* bitmap = getBitmapData();
482 float x = getFloat();
483 float y = getFloat();
484 SkPaint* paint = getPaint(renderer);
485 ALOGD("%s%s %.2f, %.2f, %p", (char*) indent, OP_NAMES[op], x, y, paint);
486 }
487 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700488 case DrawBitmapMesh: {
489 int verticesCount = 0;
490 uint32_t colorsCount = 0;
491 SkBitmap* bitmap = getBitmap();
492 uint32_t meshWidth = getInt();
493 uint32_t meshHeight = getInt();
494 float* vertices = getFloats(verticesCount);
495 bool hasColors = getInt();
496 int* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -0800497 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000498 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700499 }
500 break;
501 case DrawPatch: {
502 int32_t* xDivs = NULL;
503 int32_t* yDivs = NULL;
504 uint32_t* colors = NULL;
505 uint32_t xDivsCount = 0;
506 uint32_t yDivsCount = 0;
507 int8_t numColors = 0;
508 SkBitmap* bitmap = getBitmap();
509 xDivs = getInts(xDivsCount);
510 yDivs = getInts(yDivsCount);
511 colors = getUInts(numColors);
Romain Guya62f1722011-10-19 17:06:19 -0700512 float left = getFloat();
513 float top = getFloat();
514 float right = getFloat();
515 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -0700516 int alpha = getInt();
517 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000518 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", (char*) indent, OP_NAMES[op],
Romain Guya62f1722011-10-19 17:06:19 -0700519 left, top, right, bottom);
Chet Haaseed30fd82011-04-22 16:18:45 -0700520 }
521 break;
522 case DrawColor: {
523 int color = getInt();
524 int xferMode = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000525 ALOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haaseed30fd82011-04-22 16:18:45 -0700526 }
527 break;
528 case DrawRect: {
529 float f1 = getFloat();
530 float f2 = getFloat();
531 float f3 = getFloat();
532 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800533 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000534 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800535 f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700536 }
537 break;
538 case DrawRoundRect: {
539 float f1 = getFloat();
540 float f2 = getFloat();
541 float f3 = getFloat();
542 float f4 = getFloat();
543 float f5 = getFloat();
544 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800545 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000546 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800547 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700548 }
549 break;
550 case DrawCircle: {
551 float f1 = getFloat();
552 float f2 = getFloat();
553 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800554 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000555 ALOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800556 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700557 }
558 break;
559 case DrawOval: {
560 float f1 = getFloat();
561 float f2 = getFloat();
562 float f3 = getFloat();
563 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800564 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000565 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800566 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700567 }
568 break;
569 case DrawArc: {
570 float f1 = getFloat();
571 float f2 = getFloat();
572 float f3 = getFloat();
573 float f4 = getFloat();
574 float f5 = getFloat();
575 float f6 = getFloat();
576 int i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -0800577 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000578 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800579 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700580 }
581 break;
582 case DrawPath: {
583 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -0800584 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000585 ALOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700586 }
587 break;
588 case DrawLines: {
589 int count = 0;
590 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800591 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000592 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700593 }
594 break;
595 case DrawPoints: {
596 int count = 0;
597 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800598 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000599 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700600 }
601 break;
Romain Guy325740f2012-02-24 16:48:34 -0800602 case DrawTextOnPath: {
603 getText(&text);
604 int32_t count = getInt();
605 SkPath* path = getPath();
606 float hOffset = getFloat();
607 float vOffset = getFloat();
608 SkPaint* paint = getPaint(renderer);
609 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
610 text.text(), text.length(), count, paint);
611 }
612 break;
Romain Guyeb9a5362012-01-17 17:39:26 -0800613 case DrawPosText: {
614 getText(&text);
615 int count = getInt();
616 int positionsCount = 0;
617 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -0800618 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -0800619 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800620 text.text(), text.length(), count, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -0800621 }
Raph Levien996e57c2012-07-23 15:22:52 -0700622 break;
Romain Guyc2525952012-07-27 16:41:22 -0700623 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -0700624 getText(&text);
Romain Guy18edb812012-08-03 16:06:55 -0700625 int32_t count = getInt();
626 float x = getFloat();
627 float y = getFloat();
628 int32_t positionsCount = 0;
Raph Levien996e57c2012-07-23 15:22:52 -0700629 float* positions = getFloats(positionsCount);
630 SkPaint* paint = getPaint(renderer);
Romain Guy18edb812012-08-03 16:06:55 -0700631 float length = getFloat();
Raph Levien996e57c2012-07-23 15:22:52 -0700632 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
633 text.text(), text.length(), count, paint);
634 }
635 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700636 case ResetShader: {
Steve Block5baa3a62011-12-20 16:23:08 +0000637 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700638 }
639 break;
640 case SetupShader: {
641 SkiaShader* shader = getShader();
Steve Block5baa3a62011-12-20 16:23:08 +0000642 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
Chet Haaseed30fd82011-04-22 16:18:45 -0700643 }
644 break;
645 case ResetColorFilter: {
Steve Block5baa3a62011-12-20 16:23:08 +0000646 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700647 }
648 break;
649 case SetupColorFilter: {
650 SkiaColorFilter *colorFilter = getColorFilter();
Steve Block5baa3a62011-12-20 16:23:08 +0000651 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
Chet Haaseed30fd82011-04-22 16:18:45 -0700652 }
653 break;
654 case ResetShadow: {
Steve Block5baa3a62011-12-20 16:23:08 +0000655 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700656 }
657 break;
658 case SetupShadow: {
659 float radius = getFloat();
660 float dx = getFloat();
661 float dy = getFloat();
662 int color = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000663 ALOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800664 radius, dx, dy, color);
Chet Haaseed30fd82011-04-22 16:18:45 -0700665 }
666 break;
Romain Guy5ff9df62012-01-23 17:09:05 -0800667 case ResetPaintFilter: {
668 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
669 }
670 break;
671 case SetupPaintFilter: {
672 int clearBits = getInt();
673 int setBits = getInt();
674 ALOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op], clearBits, setBits);
675 }
676 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700677 default:
Steve Block5baa3a62011-12-20 16:23:08 +0000678 ALOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -0800679 (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700680 break;
681 }
682 }
Chet Haasea1cff502012-02-21 13:43:44 -0800683 ALOGD("%sDone (%p, %s)", (char*) indent + 2, this, mName.string());
Chet Haaseed30fd82011-04-22 16:18:45 -0700684}
685
Chet Haasea1cff502012-02-21 13:43:44 -0800686void DisplayList::updateMatrix() {
687 if (mMatrixDirty) {
688 if (!mTransformMatrix) {
689 mTransformMatrix = new SkMatrix();
690 }
691 if (mMatrixFlags == 0 || mMatrixFlags == TRANSLATION) {
692 mTransformMatrix->reset();
693 } else {
694 if (!mPivotExplicitlySet) {
695 if (mWidth != mPrevWidth || mHeight != mPrevHeight) {
696 mPrevWidth = mWidth;
697 mPrevHeight = mHeight;
698 mPivotX = mPrevWidth / 2;
699 mPivotY = mPrevHeight / 2;
700 }
701 }
702 if ((mMatrixFlags & ROTATION_3D) == 0) {
703 mTransformMatrix->setTranslate(mTranslationX, mTranslationY);
704 mTransformMatrix->preRotate(mRotation, mPivotX, mPivotY);
705 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
706 } else {
707 if (!mTransformCamera) {
708 mTransformCamera = new Sk3DView();
709 mTransformMatrix3D = new SkMatrix();
710 }
711 mTransformMatrix->reset();
712 mTransformCamera->save();
713 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
714 mTransformCamera->rotateX(mRotationX);
715 mTransformCamera->rotateY(mRotationY);
716 mTransformCamera->rotateZ(-mRotation);
717 mTransformCamera->getMatrix(mTransformMatrix3D);
718 mTransformMatrix3D->preTranslate(-mPivotX, -mPivotY);
719 mTransformMatrix3D->postTranslate(mPivotX + mTranslationX,
720 mPivotY + mTranslationY);
721 mTransformMatrix->postConcat(*mTransformMatrix3D);
722 mTransformCamera->restore();
723 }
724 }
725 mMatrixDirty = false;
726 }
727}
728
729void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
Chet Haase1271e2c2012-04-20 09:54:27 -0700730 updateMatrix();
731 if (mLeft != 0 || mTop != 0) {
732 ALOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
733 }
734 if (mStaticMatrix) {
735 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
736 indent, "ConcatMatrix (static)", mStaticMatrix,
737 mStaticMatrix->get(0), mStaticMatrix->get(1),
738 mStaticMatrix->get(2), mStaticMatrix->get(3),
739 mStaticMatrix->get(4), mStaticMatrix->get(5),
740 mStaticMatrix->get(6), mStaticMatrix->get(7),
741 mStaticMatrix->get(8));
742 }
743 if (mAnimationMatrix) {
744 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
745 indent, "ConcatMatrix (animation)", mAnimationMatrix,
746 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
747 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
748 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
749 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
750 mAnimationMatrix->get(8));
751 }
752 if (mMatrixFlags != 0) {
753 if (mMatrixFlags == TRANSLATION) {
754 ALOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
755 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700756 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700757 indent, "ConcatMatrix", mTransformMatrix,
758 mTransformMatrix->get(0), mTransformMatrix->get(1),
759 mTransformMatrix->get(2), mTransformMatrix->get(3),
760 mTransformMatrix->get(4), mTransformMatrix->get(5),
761 mTransformMatrix->get(6), mTransformMatrix->get(7),
762 mTransformMatrix->get(8));
Chet Haase9420abd2012-03-29 16:28:32 -0700763 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700764 }
765 if (mAlpha < 1 && !mCaching) {
766 // TODO: should be able to store the size of a DL at record time and not
767 // have to pass it into this call. In fact, this information might be in the
768 // location/size info that we store with the new native transform data.
769 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800770 if (mClipChildren) {
Chet Haase1271e2c2012-04-20 09:54:27 -0700771 flags |= SkCanvas::kClipToLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800772 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700773 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
774 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
775 mMultipliedAlpha, flags);
776 }
777 if (mClipChildren) {
778 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
779 (float) mRight - mLeft, (float) mBottom - mTop);
Chet Haasea1cff502012-02-21 13:43:44 -0800780 }
781}
782
Chet Haase1271e2c2012-04-20 09:54:27 -0700783void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t level) {
Chet Haasea1cff502012-02-21 13:43:44 -0800784#if DEBUG_DISPLAY_LIST
785 uint32_t count = (level + 1) * 2;
786 char indent[count + 1];
787 for (uint32_t i = 0; i < count; i++) {
788 indent[i] = ' ';
789 }
790 indent[count] = '\0';
791#endif
Chet Haase1271e2c2012-04-20 09:54:27 -0700792 updateMatrix();
793 if (mLeft != 0 || mTop != 0) {
794 DISPLAY_LIST_LOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
795 renderer.translate(mLeft, mTop);
796 }
797 if (mStaticMatrix) {
798 DISPLAY_LIST_LOGD(
799 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
800 indent, "ConcatMatrix (static)", mStaticMatrix,
801 mStaticMatrix->get(0), mStaticMatrix->get(1),
802 mStaticMatrix->get(2), mStaticMatrix->get(3),
803 mStaticMatrix->get(4), mStaticMatrix->get(5),
804 mStaticMatrix->get(6), mStaticMatrix->get(7),
805 mStaticMatrix->get(8));
806 renderer.concatMatrix(mStaticMatrix);
807 } else if (mAnimationMatrix) {
808 DISPLAY_LIST_LOGD(
809 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
810 indent, "ConcatMatrix (animation)", mAnimationMatrix,
811 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
812 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
813 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
814 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
815 mAnimationMatrix->get(8));
816 renderer.concatMatrix(mAnimationMatrix);
817 }
818 if (mMatrixFlags != 0) {
819 if (mMatrixFlags == TRANSLATION) {
820 DISPLAY_LIST_LOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
821 renderer.translate(mTranslationX, mTranslationY);
822 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700823 DISPLAY_LIST_LOGD(
824 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700825 indent, "ConcatMatrix", mTransformMatrix,
826 mTransformMatrix->get(0), mTransformMatrix->get(1),
827 mTransformMatrix->get(2), mTransformMatrix->get(3),
828 mTransformMatrix->get(4), mTransformMatrix->get(5),
829 mTransformMatrix->get(6), mTransformMatrix->get(7),
830 mTransformMatrix->get(8));
831 renderer.concatMatrix(mTransformMatrix);
Chet Haasea1cff502012-02-21 13:43:44 -0800832 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700833 }
834 if (mAlpha < 1 && !mCaching) {
835 if (!mHasOverlappingRendering) {
836 DISPLAY_LIST_LOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
837 renderer.setAlpha(mAlpha);
838 } else {
839 // TODO: should be able to store the size of a DL at record time and not
840 // have to pass it into this call. In fact, this information might be in the
841 // location/size info that we store with the new native transform data.
842 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
843 if (mClipChildren) {
844 flags |= SkCanvas::kClipToLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800845 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700846 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
847 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
848 mMultipliedAlpha, flags);
849 renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
850 mMultipliedAlpha, flags);
Chet Haasea1cff502012-02-21 13:43:44 -0800851 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700852 }
853 if (mClipChildren) {
854 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
855 (float) mRight - mLeft, (float) mBottom - mTop);
856 renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
857 SkRegion::kIntersect_Op);
Chet Haasea1cff502012-02-21 13:43:44 -0800858 }
859}
860
Chet Haaseed30fd82011-04-22 16:18:45 -0700861/**
862 * Changes to replay(), specifically those involving opcode or parameter changes, should be mimicked
863 * in the output() function, since that function processes the same list of opcodes for the
864 * purposes of logging display list info for a given view.
865 */
Chet Haase1271e2c2012-04-20 09:54:27 -0700866status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level) {
Chet Haase48659092012-05-31 15:21:51 -0700867 status_t drawGlStatus = DrawGlInfo::kStatusDone;
Romain Guyb051e892010-09-28 19:09:36 -0700868 TextContainer text;
869 mReader.rewind();
870
Romain Guyffac7fc2011-01-13 17:21:49 -0800871#if DEBUG_DISPLAY_LIST
872 uint32_t count = (level + 1) * 2;
873 char indent[count + 1];
874 for (uint32_t i = 0; i < count; i++) {
875 indent[i] = ' ';
876 }
877 indent[count] = '\0';
Chet Haasea23eed82012-04-12 15:19:04 -0700878 Rect* clipRect = renderer.getClipRect();
879 DISPLAY_LIST_LOGD("%sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
880 (char*) indent + 2, this, mName.string(), clipRect->left, clipRect->top,
881 clipRect->right, clipRect->bottom);
Romain Guyffac7fc2011-01-13 17:21:49 -0800882#endif
Romain Guyb051e892010-09-28 19:09:36 -0700883
Romain Guy13631f32012-01-30 17:41:55 -0800884 renderer.startMark(mName.string());
Romain Guy8a4ac612012-07-17 17:32:48 -0700885
Chet Haase1271e2c2012-04-20 09:54:27 -0700886 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
887 DISPLAY_LIST_LOGD("%s%s %d %d", indent, "Save",
888 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
889 setViewProperties(renderer, level);
Romain Guy8a4ac612012-07-17 17:32:48 -0700890
891 if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
Chet Haaseb85967b2012-03-26 14:37:51 -0700892 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
893 renderer.restoreToCount(restoreTo);
894 renderer.endMark();
Chet Haase48659092012-05-31 15:21:51 -0700895 return drawGlStatus;
Chet Haaseb85967b2012-03-26 14:37:51 -0700896 }
Romain Guy13631f32012-01-30 17:41:55 -0800897
Chet Haase9c1e23b2011-03-24 10:51:31 -0700898 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
Romain Guyffac7fc2011-01-13 17:21:49 -0800899 int saveCount = renderer.getSaveCount() - 1;
Romain Guy8a4ac612012-07-17 17:32:48 -0700900
Romain Guyb051e892010-09-28 19:09:36 -0700901 while (!mReader.eof()) {
Romain Guy5b3b3522010-10-27 18:57:51 -0700902 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800903 if (op & OP_MAY_BE_SKIPPED_MASK) {
Romain Guy390f8822012-03-13 18:00:10 -0700904 int32_t skip = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800905 if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
906 mReader.skip(skip);
907 DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,
908 OP_NAMES[op & ~OP_MAY_BE_SKIPPED_MASK], skip);
909 continue;
910 } else {
911 op &= ~OP_MAY_BE_SKIPPED_MASK;
Romain Guy33f6beb2012-02-16 19:24:51 -0800912 }
913 }
Chet Haase9c1e23b2011-03-24 10:51:31 -0700914 logBuffer.writeCommand(level, op);
Romain Guyffac7fc2011-01-13 17:21:49 -0800915
Romain Guy8a4ac612012-07-17 17:32:48 -0700916#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
917 Caches::getInstance().eventMark(strlen(OP_NAMES[op]), OP_NAMES[op]);
918#endif
919
Romain Guy5b3b3522010-10-27 18:57:51 -0700920 switch (op) {
Chet Haasedaf98e92011-01-10 14:10:36 -0800921 case DrawGLFunction: {
922 Functor *functor = (Functor *) getInt();
923 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Romain Guy13631f32012-01-30 17:41:55 -0800924 renderer.startMark("GL functor");
Romain Guy65549432012-03-26 16:45:05 -0700925 drawGlStatus |= renderer.callDrawGLFunction(functor, dirty);
Romain Guy13631f32012-01-30 17:41:55 -0800926 renderer.endMark();
Chet Haasedaf98e92011-01-10 14:10:36 -0800927 }
928 break;
Romain Guyb051e892010-09-28 19:09:36 -0700929 case Save: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800930 int32_t rendererNum = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800931 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
932 renderer.save(rendererNum);
Romain Guyb051e892010-09-28 19:09:36 -0700933 }
934 break;
935 case Restore: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800936 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700937 renderer.restore();
938 }
939 break;
940 case RestoreToCount: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800941 int32_t restoreCount = saveCount + getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800942 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
943 renderer.restoreToCount(restoreCount);
Romain Guyb051e892010-09-28 19:09:36 -0700944 }
945 break;
946 case SaveLayer: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800947 float f1 = getFloat();
948 float f2 = getFloat();
949 float f3 = getFloat();
950 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800951 SkPaint* paint = getPaint(renderer);
Romain Guy33f6beb2012-02-16 19:24:51 -0800952 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800953 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800954 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800955 renderer.saveLayer(f1, f2, f3, f4, paint, flags);
Romain Guyb051e892010-09-28 19:09:36 -0700956 }
957 break;
Romain Guy5b3b3522010-10-27 18:57:51 -0700958 case SaveLayerAlpha: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800959 float f1 = getFloat();
960 float f2 = getFloat();
961 float f3 = getFloat();
962 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -0800963 int32_t alpha = getInt();
964 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800965 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800966 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800967 renderer.saveLayerAlpha(f1, f2, f3, f4, alpha, flags);
Romain Guy5b3b3522010-10-27 18:57:51 -0700968 }
969 break;
Romain Guyb051e892010-09-28 19:09:36 -0700970 case Translate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800971 float f1 = getFloat();
972 float f2 = getFloat();
973 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
974 renderer.translate(f1, f2);
Romain Guyb051e892010-09-28 19:09:36 -0700975 }
976 break;
977 case Rotate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800978 float rotation = getFloat();
979 DISPLAY_LIST_LOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
980 renderer.rotate(rotation);
Romain Guyb051e892010-09-28 19:09:36 -0700981 }
982 break;
983 case Scale: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800984 float sx = getFloat();
985 float sy = getFloat();
986 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
987 renderer.scale(sx, sy);
Romain Guyb051e892010-09-28 19:09:36 -0700988 }
989 break;
Romain Guy807daf72011-01-18 11:19:19 -0800990 case Skew: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800991 float sx = getFloat();
992 float sy = getFloat();
993 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
994 renderer.skew(sx, sy);
Romain Guy807daf72011-01-18 11:19:19 -0800995 }
996 break;
Romain Guyb051e892010-09-28 19:09:36 -0700997 case SetMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800998 SkMatrix* matrix = getMatrix();
999 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
1000 renderer.setMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -07001001 }
1002 break;
1003 case ConcatMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001004 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -08001005 DISPLAY_LIST_LOGD(
1006 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
1007 (char*) indent, OP_NAMES[op], matrix,
1008 matrix->get(0), matrix->get(1), matrix->get(2),
1009 matrix->get(3), matrix->get(4), matrix->get(5),
1010 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haasedaf98e92011-01-10 14:10:36 -08001011 renderer.concatMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -07001012 }
1013 break;
1014 case ClipRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001015 float f1 = getFloat();
1016 float f2 = getFloat();
1017 float f3 = getFloat();
1018 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001019 int32_t regionOp = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001020 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001021 f1, f2, f3, f4, regionOp);
Chet Haasedaf98e92011-01-10 14:10:36 -08001022 renderer.clipRect(f1, f2, f3, f4, (SkRegion::Op) regionOp);
Romain Guyb051e892010-09-28 19:09:36 -07001023 }
1024 break;
Romain Guy0fe478e2010-11-08 12:08:41 -08001025 case DrawDisplayList: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001026 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -08001027 int32_t flags = getInt();
1028 DISPLAY_LIST_LOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -07001029 displayList, mWidth, mHeight, flags, level + 1);
1030 drawGlStatus |= renderer.drawDisplayList(displayList, dirty, flags, level + 1);
Romain Guy0fe478e2010-11-08 12:08:41 -08001031 }
1032 break;
Romain Guy6c319ca2011-01-11 14:29:25 -08001033 case DrawLayer: {
Chet Haased15ebf22012-09-05 11:40:29 -07001034 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001035 Layer* layer = (Layer*) getInt();
1036 float x = getFloat();
1037 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001038 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001039 if (mCaching && mMultipliedAlpha < 255) {
1040 oldAlpha = layer->getAlpha();
1041 layer->setAlpha(mMultipliedAlpha);
Chet Haasea1cff502012-02-21 13:43:44 -08001042 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001043 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001044 layer, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001045 drawGlStatus |= renderer.drawLayer(layer, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001046 if (oldAlpha >= 0) {
1047 layer->setAlpha(oldAlpha);
1048 }
Romain Guy6c319ca2011-01-11 14:29:25 -08001049 }
1050 break;
Romain Guyb051e892010-09-28 19:09:36 -07001051 case DrawBitmap: {
Chet Haased15ebf22012-09-05 11:40:29 -07001052 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001053 SkBitmap* bitmap = getBitmap();
1054 float x = getFloat();
1055 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001056 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001057 if (mCaching && mMultipliedAlpha < 255) {
1058 oldAlpha = paint->getAlpha();
Chet Haaseb85967b2012-03-26 14:37:51 -07001059 paint->setAlpha(mMultipliedAlpha);
1060 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001061 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001062 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001063 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001064 if (oldAlpha >= 0) {
1065 paint->setAlpha(oldAlpha);
1066 }
Romain Guyb051e892010-09-28 19:09:36 -07001067 }
1068 break;
1069 case DrawBitmapMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001070 SkBitmap* bitmap = getBitmap();
1071 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -08001072 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001073 DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001074 bitmap, matrix, paint);
Chet Haase48659092012-05-31 15:21:51 -07001075 drawGlStatus |= renderer.drawBitmap(bitmap, matrix, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001076 }
1077 break;
1078 case DrawBitmapRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001079 SkBitmap* bitmap = getBitmap();
1080 float f1 = getFloat();
1081 float f2 = getFloat();
1082 float f3 = getFloat();
1083 float f4 = getFloat();
1084 float f5 = getFloat();
1085 float f6 = getFloat();
1086 float f7 = getFloat();
1087 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001088 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001089 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001090 (char*) indent, OP_NAMES[op], bitmap,
1091 f1, f2, f3, f4, f5, f6, f7, f8,paint);
Chet Haase48659092012-05-31 15:21:51 -07001092 drawGlStatus |= renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001093 }
1094 break;
Romain Guye651cc62012-05-14 19:44:40 -07001095 case DrawBitmapData: {
1096 SkBitmap* bitmap = getBitmapData();
1097 float x = getFloat();
1098 float y = getFloat();
1099 SkPaint* paint = getPaint(renderer);
1100 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
1101 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001102 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Romain Guye651cc62012-05-14 19:44:40 -07001103 }
1104 break;
Romain Guy5a7b4662011-01-20 19:09:30 -08001105 case DrawBitmapMesh: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001106 int32_t verticesCount = 0;
Romain Guy5a7b4662011-01-20 19:09:30 -08001107 uint32_t colorsCount = 0;
1108
1109 SkBitmap* bitmap = getBitmap();
1110 uint32_t meshWidth = getInt();
1111 uint32_t meshHeight = getInt();
1112 float* vertices = getFloats(verticesCount);
1113 bool hasColors = getInt();
Romain Guy33f6beb2012-02-16 19:24:51 -08001114 int32_t* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -08001115 SkPaint* paint = getPaint(renderer);
Romain Guy5a7b4662011-01-20 19:09:30 -08001116
Chet Haasedaf98e92011-01-10 14:10:36 -08001117 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001118 drawGlStatus |= renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices,
1119 colors, paint);
Romain Guy5a7b4662011-01-20 19:09:30 -08001120 }
Romain Guya566b7c2011-01-23 16:36:11 -08001121 break;
Romain Guyb051e892010-09-28 19:09:36 -07001122 case DrawPatch: {
1123 int32_t* xDivs = NULL;
1124 int32_t* yDivs = NULL;
Romain Guy4bb94202010-10-12 15:59:26 -07001125 uint32_t* colors = NULL;
Romain Guyb051e892010-09-28 19:09:36 -07001126 uint32_t xDivsCount = 0;
1127 uint32_t yDivsCount = 0;
Romain Guy4bb94202010-10-12 15:59:26 -07001128 int8_t numColors = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001129
1130 SkBitmap* bitmap = getBitmap();
1131
1132 xDivs = getInts(xDivsCount);
1133 yDivs = getInts(yDivsCount);
Romain Guy4bb94202010-10-12 15:59:26 -07001134 colors = getUInts(numColors);
Romain Guyb051e892010-09-28 19:09:36 -07001135
Romain Guy9ff3cb52011-06-28 14:02:11 -07001136 float left = getFloat();
1137 float top = getFloat();
1138 float right = getFloat();
1139 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -07001140
1141 int alpha = getInt();
1142 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Romain Guy9ff3cb52011-06-28 14:02:11 -07001143
Chet Haasedaf98e92011-01-10 14:10:36 -08001144 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001145 drawGlStatus |= renderer.drawPatch(bitmap, xDivs, yDivs, colors,
Romain Guybe6f9dc2012-07-16 12:41:17 -07001146 xDivsCount, yDivsCount, numColors, left, top, right, bottom,
1147 alpha, mode);
Romain Guyb051e892010-09-28 19:09:36 -07001148 }
1149 break;
1150 case DrawColor: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001151 int32_t color = getInt();
1152 int32_t xferMode = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001153 DISPLAY_LIST_LOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haase48659092012-05-31 15:21:51 -07001154 drawGlStatus |= renderer.drawColor(color, (SkXfermode::Mode) xferMode);
Romain Guyb051e892010-09-28 19:09:36 -07001155 }
1156 break;
1157 case DrawRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001158 float f1 = getFloat();
1159 float f2 = getFloat();
1160 float f3 = getFloat();
1161 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001162 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001163 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001164 f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001165 drawGlStatus |= renderer.drawRect(f1, f2, f3, f4, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001166 }
1167 break;
Romain Guy01d58e42011-01-19 21:54:02 -08001168 case DrawRoundRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001169 float f1 = getFloat();
1170 float f2 = getFloat();
1171 float f3 = getFloat();
1172 float f4 = getFloat();
1173 float f5 = getFloat();
1174 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001175 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001176 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001177 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haase48659092012-05-31 15:21:51 -07001178 drawGlStatus |= renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001179 }
1180 break;
1181 case DrawCircle: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001182 float f1 = getFloat();
1183 float f2 = getFloat();
1184 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001185 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001186 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001187 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haase48659092012-05-31 15:21:51 -07001188 drawGlStatus |= renderer.drawCircle(f1, f2, f3, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001189 }
1190 break;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001191 case DrawOval: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001192 float f1 = getFloat();
1193 float f2 = getFloat();
1194 float f3 = getFloat();
1195 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001196 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001197 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001198 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001199 drawGlStatus |= renderer.drawOval(f1, f2, f3, f4, paint);
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001200 }
1201 break;
Romain Guy8b2f5262011-01-23 16:15:02 -08001202 case DrawArc: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001203 float f1 = getFloat();
1204 float f2 = getFloat();
1205 float f3 = getFloat();
1206 float f4 = getFloat();
1207 float f5 = getFloat();
1208 float f6 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001209 int32_t i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001210 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001211 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001212 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haase48659092012-05-31 15:21:51 -07001213 drawGlStatus |= renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
Romain Guy8b2f5262011-01-23 16:15:02 -08001214 }
1215 break;
Romain Guyb051e892010-09-28 19:09:36 -07001216 case DrawPath: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001217 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -08001218 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001219 DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haase48659092012-05-31 15:21:51 -07001220 drawGlStatus |= renderer.drawPath(path, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001221 }
1222 break;
1223 case DrawLines: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001224 int32_t count = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001225 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001226 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001227 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001228 drawGlStatus |= renderer.drawLines(points, count, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001229 }
1230 break;
Romain Guyed6fcb02011-03-21 13:11:28 -07001231 case DrawPoints: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001232 int32_t count = 0;
Romain Guyed6fcb02011-03-21 13:11:28 -07001233 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001234 SkPaint* paint = getPaint(renderer);
Romain Guyed6fcb02011-03-21 13:11:28 -07001235 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001236 drawGlStatus |= renderer.drawPoints(points, count, paint);
Romain Guyed6fcb02011-03-21 13:11:28 -07001237 }
1238 break;
Romain Guy325740f2012-02-24 16:48:34 -08001239 case DrawTextOnPath: {
1240 getText(&text);
1241 int32_t count = getInt();
1242 SkPath* path = getPath();
1243 float hOffset = getFloat();
1244 float vOffset = getFloat();
1245 SkPaint* paint = getPaint(renderer);
1246 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
1247 text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001248 drawGlStatus |= renderer.drawTextOnPath(text.text(), text.length(), count, path,
Romain Guy325740f2012-02-24 16:48:34 -08001249 hOffset, vOffset, paint);
1250 }
1251 break;
Romain Guyeb9a5362012-01-17 17:39:26 -08001252 case DrawPosText: {
1253 getText(&text);
Romain Guy33f6beb2012-02-16 19:24:51 -08001254 int32_t count = getInt();
1255 int32_t positionsCount = 0;
Romain Guyeb9a5362012-01-17 17:39:26 -08001256 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -08001257 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -08001258 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent,
1259 OP_NAMES[op], text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001260 drawGlStatus |= renderer.drawPosText(text.text(), text.length(), count,
1261 positions, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -08001262 }
1263 break;
Romain Guyc2525952012-07-27 16:41:22 -07001264 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -07001265 getText(&text);
1266 int32_t count = getInt();
1267 float x = getFloat();
1268 float y = getFloat();
1269 int32_t positionsCount = 0;
1270 float* positions = getFloats(positionsCount);
1271 SkPaint* paint = getPaint(renderer);
1272 float length = getFloat();
1273 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent,
1274 OP_NAMES[op], text.text(), text.length(), count, x, y, paint, length);
Romain Guyc2525952012-07-27 16:41:22 -07001275 drawGlStatus |= renderer.drawText(text.text(), text.length(), count,
Raph Levien996e57c2012-07-23 15:22:52 -07001276 x, y, positions, paint, length);
1277 }
1278 break;
Romain Guyb051e892010-09-28 19:09:36 -07001279 case ResetShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001280 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001281 renderer.resetShader();
1282 }
1283 break;
1284 case SetupShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001285 SkiaShader* shader = getShader();
1286 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
1287 renderer.setupShader(shader);
Romain Guyb051e892010-09-28 19:09:36 -07001288 }
1289 break;
1290 case ResetColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001291 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001292 renderer.resetColorFilter();
1293 }
1294 break;
1295 case SetupColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001296 SkiaColorFilter *colorFilter = getColorFilter();
1297 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
1298 renderer.setupColorFilter(colorFilter);
Romain Guyb051e892010-09-28 19:09:36 -07001299 }
1300 break;
1301 case ResetShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001302 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001303 renderer.resetShadow();
1304 }
1305 break;
1306 case SetupShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001307 float radius = getFloat();
1308 float dx = getFloat();
1309 float dy = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001310 int32_t color = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001311 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001312 radius, dx, dy, color);
Chet Haasedaf98e92011-01-10 14:10:36 -08001313 renderer.setupShadow(radius, dx, dy, color);
Romain Guyb051e892010-09-28 19:09:36 -07001314 }
1315 break;
Romain Guy5ff9df62012-01-23 17:09:05 -08001316 case ResetPaintFilter: {
1317 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
1318 renderer.resetPaintFilter();
1319 }
1320 break;
1321 case SetupPaintFilter: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001322 int32_t clearBits = getInt();
1323 int32_t setBits = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001324 DISPLAY_LIST_LOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op],
1325 clearBits, setBits);
1326 renderer.setupPaintFilter(clearBits, setBits);
1327 }
1328 break;
Chet Haasedaf98e92011-01-10 14:10:36 -08001329 default:
1330 DISPLAY_LIST_LOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -08001331 (char*) indent, OP_NAMES[op]);
Chet Haasedaf98e92011-01-10 14:10:36 -08001332 break;
Romain Guyb051e892010-09-28 19:09:36 -07001333 }
1334 }
Romain Guyffac7fc2011-01-13 17:21:49 -08001335
Chet Haase1271e2c2012-04-20 09:54:27 -07001336 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
1337 renderer.restoreToCount(restoreTo);
Romain Guy13631f32012-01-30 17:41:55 -08001338 renderer.endMark();
1339
Chet Haasea1cff502012-02-21 13:43:44 -08001340 DISPLAY_LIST_LOGD("%sDone (%p, %s), returning %d", (char*) indent + 2, this, mName.string(),
Romain Guy65549432012-03-26 16:45:05 -07001341 drawGlStatus);
1342 return drawGlStatus;
Romain Guyb051e892010-09-28 19:09:36 -07001343}
1344
1345///////////////////////////////////////////////////////////////////////////////
Romain Guy4aa90572010-09-26 18:40:37 -07001346// Base structure
1347///////////////////////////////////////////////////////////////////////////////
1348
Romain Guy58ecc202012-09-07 11:58:36 -07001349DisplayListRenderer::DisplayListRenderer():
1350 mCaches(Caches::getInstance()), mWriter(MIN_WRITER_SIZE),
Romain Guy54c1a642012-09-27 17:55:46 -07001351 mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false),
1352 mHasDrawOps(false), mFunctorCount(0) {
Romain Guy4aa90572010-09-26 18:40:37 -07001353}
1354
1355DisplayListRenderer::~DisplayListRenderer() {
1356 reset();
1357}
1358
1359void DisplayListRenderer::reset() {
Romain Guy4aa90572010-09-26 18:40:37 -07001360 mWriter.reset();
Chet Haase5c13d892010-10-08 08:37:55 -07001361
Romain Guy58ecc202012-09-07 11:58:36 -07001362 mCaches.resourceCache.lock();
1363
Chet Haase5c13d892010-10-08 08:37:55 -07001364 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001365 mCaches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5c13d892010-10-08 08:37:55 -07001366 }
Chet Haased98aa2d2010-10-25 15:47:32 -07001367
Romain Guy49c5fc02012-05-15 11:10:01 -07001368 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001369 mCaches.resourceCache.decrementRefcountLocked(mOwnedBitmapResources.itemAt(i));
Romain Guy49c5fc02012-05-15 11:10:01 -07001370 }
Romain Guy49c5fc02012-05-15 11:10:01 -07001371
Romain Guyd586ad92011-06-22 16:14:36 -07001372 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001373 mCaches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -07001374 }
Romain Guyd586ad92011-06-22 16:14:36 -07001375
Romain Guy43ccf462011-01-14 18:51:01 -08001376 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001377 mCaches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
Romain Guy43ccf462011-01-14 18:51:01 -08001378 }
Romain Guy43ccf462011-01-14 18:51:01 -08001379
Chet Haased34dd712012-05-02 18:50:34 -07001380 for (size_t i = 0; i < mSourcePaths.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001381 mCaches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
Chet Haased34dd712012-05-02 18:50:34 -07001382 }
Romain Guy58ecc202012-09-07 11:58:36 -07001383
Chet Haase603f6de2012-09-14 15:31:25 -07001384 for (size_t i = 0; i < mLayers.size(); i++) {
1385 mCaches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
1386 }
1387
Romain Guy58ecc202012-09-07 11:58:36 -07001388 mCaches.resourceCache.unlock();
1389
1390 mBitmapResources.clear();
1391 mOwnedBitmapResources.clear();
1392 mFilterResources.clear();
Chet Haased34dd712012-05-02 18:50:34 -07001393 mSourcePaths.clear();
1394
Romain Guy58ecc202012-09-07 11:58:36 -07001395 mShaders.clear();
1396 mShaderMap.clear();
1397
Romain Guy43ccf462011-01-14 18:51:01 -08001398 mPaints.clear();
1399 mPaintMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001400
Romain Guy2fc941e2011-02-03 15:06:05 -08001401 mPaths.clear();
1402 mPathMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001403
Chet Haased98aa2d2010-10-25 15:47:32 -07001404 mMatrices.clear();
Romain Guy04c9d8c2011-08-25 14:01:48 -07001405
Chet Haase603f6de2012-09-14 15:31:25 -07001406 mLayers.clear();
1407
Romain Guy04c9d8c2011-08-25 14:01:48 -07001408 mHasDrawOps = false;
Romain Guy54c1a642012-09-27 17:55:46 -07001409 mFunctorCount = 0;
Romain Guy4aa90572010-09-26 18:40:37 -07001410}
1411
1412///////////////////////////////////////////////////////////////////////////////
1413// Operations
1414///////////////////////////////////////////////////////////////////////////////
1415
Jeff Brown162a0212011-07-21 17:02:54 -07001416DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
1417 if (!displayList) {
1418 displayList = new DisplayList(*this);
Chet Haase5977baa2011-01-05 18:01:22 -08001419 } else {
Jeff Brown162a0212011-07-21 17:02:54 -07001420 displayList->initFromDisplayListRenderer(*this, true);
Chet Haase5977baa2011-01-05 18:01:22 -08001421 }
Romain Guy04c9d8c2011-08-25 14:01:48 -07001422 displayList->setRenderable(mHasDrawOps);
Jeff Brown162a0212011-07-21 17:02:54 -07001423 return displayList;
Chet Haase5977baa2011-01-05 18:01:22 -08001424}
1425
Romain Guy49c5fc02012-05-15 11:10:01 -07001426bool DisplayListRenderer::isDeferred() {
1427 return true;
1428}
1429
Romain Guyb051e892010-09-28 19:09:36 -07001430void DisplayListRenderer::setViewport(int width, int height) {
1431 mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
1432
1433 mWidth = width;
1434 mHeight = height;
1435}
1436
Chet Haase44b2fe32012-06-06 19:03:58 -07001437int DisplayListRenderer::prepareDirty(float left, float top,
Romain Guy7d7b5492011-01-24 16:33:45 -08001438 float right, float bottom, bool opaque) {
Romain Guyb051e892010-09-28 19:09:36 -07001439 mSnapshot = new Snapshot(mFirstSnapshot,
1440 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
1441 mSaveCount = 1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001442
Romain Guyb051e892010-09-28 19:09:36 -07001443 mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
Romain Guy45e4c3d2012-09-11 17:17:07 -07001444 mDirtyClip = opaque;
1445
Romain Guy27454a42011-01-23 12:01:41 -08001446 mRestoreSaveCount = -1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001447
Chet Haase44b2fe32012-06-06 19:03:58 -07001448 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Romain Guy27454a42011-01-23 12:01:41 -08001449}
1450
1451void DisplayListRenderer::finish() {
1452 insertRestoreToCount();
Romain Guy33f6beb2012-02-16 19:24:51 -08001453 insertTranlate();
Romain Guyb051e892010-09-28 19:09:36 -07001454}
1455
Chet Haasedaf98e92011-01-10 14:10:36 -08001456void DisplayListRenderer::interrupt() {
Chet Haasedaf98e92011-01-10 14:10:36 -08001457}
Romain Guy2b1847e2011-01-26 13:43:01 -08001458
Chet Haasedaf98e92011-01-10 14:10:36 -08001459void DisplayListRenderer::resume() {
Romain Guy4aa90572010-09-26 18:40:37 -07001460}
1461
Romain Guy65549432012-03-26 16:45:05 -07001462status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
Romain Guycabfcc12011-03-07 18:06:46 -08001463 // Ignore dirty during recording, it matters only when we replay
Chet Haasedaf98e92011-01-10 14:10:36 -08001464 addOp(DisplayList::DrawGLFunction);
1465 addInt((int) functor);
Romain Guy54c1a642012-09-27 17:55:46 -07001466 mFunctorCount++;
Romain Guy65549432012-03-26 16:45:05 -07001467 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Chet Haasedaf98e92011-01-10 14:10:36 -08001468}
1469
Romain Guy4aa90572010-09-26 18:40:37 -07001470int DisplayListRenderer::save(int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001471 addOp(DisplayList::Save);
Romain Guy4aa90572010-09-26 18:40:37 -07001472 addInt(flags);
1473 return OpenGLRenderer::save(flags);
1474}
1475
1476void DisplayListRenderer::restore() {
Romain Guy04c9d8c2011-08-25 14:01:48 -07001477 if (mRestoreSaveCount < 0) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001478 restoreToCount(getSaveCount() - 1);
1479 return;
Romain Guy04c9d8c2011-08-25 14:01:48 -07001480 }
Romain Guy33f6beb2012-02-16 19:24:51 -08001481
1482 mRestoreSaveCount--;
1483 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001484 OpenGLRenderer::restore();
1485}
1486
1487void DisplayListRenderer::restoreToCount(int saveCount) {
Romain Guy27454a42011-01-23 12:01:41 -08001488 mRestoreSaveCount = saveCount;
Romain Guy33f6beb2012-02-16 19:24:51 -08001489 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001490 OpenGLRenderer::restoreToCount(saveCount);
1491}
1492
1493int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001494 SkPaint* p, int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001495 addOp(DisplayList::SaveLayer);
Romain Guy4aa90572010-09-26 18:40:37 -07001496 addBounds(left, top, right, bottom);
1497 addPaint(p);
1498 addInt(flags);
Romain Guyb051e892010-09-28 19:09:36 -07001499 return OpenGLRenderer::save(flags);
Romain Guy4aa90572010-09-26 18:40:37 -07001500}
1501
Romain Guy5b3b3522010-10-27 18:57:51 -07001502int DisplayListRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
1503 int alpha, int flags) {
1504 addOp(DisplayList::SaveLayerAlpha);
1505 addBounds(left, top, right, bottom);
1506 addInt(alpha);
1507 addInt(flags);
1508 return OpenGLRenderer::save(flags);
1509}
1510
Romain Guy4aa90572010-09-26 18:40:37 -07001511void DisplayListRenderer::translate(float dx, float dy) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001512 mHasTranslate = true;
1513 mTranslateX += dx;
1514 mTranslateY += dy;
1515 insertRestoreToCount();
Romain Guy4aa90572010-09-26 18:40:37 -07001516 OpenGLRenderer::translate(dx, dy);
1517}
1518
1519void DisplayListRenderer::rotate(float degrees) {
Romain Guyb051e892010-09-28 19:09:36 -07001520 addOp(DisplayList::Rotate);
Romain Guy4aa90572010-09-26 18:40:37 -07001521 addFloat(degrees);
1522 OpenGLRenderer::rotate(degrees);
1523}
1524
1525void DisplayListRenderer::scale(float sx, float sy) {
Romain Guyb051e892010-09-28 19:09:36 -07001526 addOp(DisplayList::Scale);
Romain Guy4aa90572010-09-26 18:40:37 -07001527 addPoint(sx, sy);
1528 OpenGLRenderer::scale(sx, sy);
1529}
1530
Romain Guy807daf72011-01-18 11:19:19 -08001531void DisplayListRenderer::skew(float sx, float sy) {
1532 addOp(DisplayList::Skew);
1533 addPoint(sx, sy);
1534 OpenGLRenderer::skew(sx, sy);
1535}
1536
Romain Guy4aa90572010-09-26 18:40:37 -07001537void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001538 addOp(DisplayList::SetMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001539 addMatrix(matrix);
1540 OpenGLRenderer::setMatrix(matrix);
1541}
1542
1543void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001544 addOp(DisplayList::ConcatMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001545 addMatrix(matrix);
1546 OpenGLRenderer::concatMatrix(matrix);
1547}
1548
1549bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
1550 SkRegion::Op op) {
Romain Guyb051e892010-09-28 19:09:36 -07001551 addOp(DisplayList::ClipRect);
Romain Guy4aa90572010-09-26 18:40:37 -07001552 addBounds(left, top, right, bottom);
1553 addInt(op);
1554 return OpenGLRenderer::clipRect(left, top, right, bottom, op);
1555}
1556
Romain Guy65549432012-03-26 16:45:05 -07001557status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
Chet Haase1271e2c2012-04-20 09:54:27 -07001558 Rect& dirty, int32_t flags, uint32_t level) {
Romain Guycabfcc12011-03-07 18:06:46 -08001559 // dirty is an out parameter and should not be recorded,
1560 // it matters only when replaying the display list
Chet Haaseb85967b2012-03-26 14:37:51 -07001561
1562 addOp(DisplayList::DrawDisplayList);
Romain Guy0fe478e2010-11-08 12:08:41 -08001563 addDisplayList(displayList);
Romain Guy33f6beb2012-02-16 19:24:51 -08001564 addInt(flags);
Romain Guy65549432012-03-26 16:45:05 -07001565 return DrawGlInfo::kStatusDone;
Romain Guy0fe478e2010-11-08 12:08:41 -08001566}
1567
Chet Haase48659092012-05-31 15:21:51 -07001568status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
Romain Guy6c319ca2011-01-11 14:29:25 -08001569 addOp(DisplayList::DrawLayer);
Chet Haase603f6de2012-09-14 15:31:25 -07001570 addLayer(layer);
Romain Guyada830f2011-01-13 12:13:20 -08001571 addPoint(x, y);
Romain Guy6c319ca2011-01-11 14:29:25 -08001572 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001573 return DrawGlInfo::kStatusDone;
Romain Guy6c319ca2011-01-11 14:29:25 -08001574}
1575
Chet Haase48659092012-05-31 15:21:51 -07001576status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
Romain Guya3dc55f2012-09-28 13:55:44 -07001577 const bool reject = quickRejectNoScissor(left, top,
1578 left + bitmap->width(), top + bitmap->height());
Romain Guy33f6beb2012-02-16 19:24:51 -08001579 uint32_t* location = addOp(DisplayList::DrawBitmap, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001580 addBitmap(bitmap);
1581 addPoint(left, top);
1582 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001583 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001584 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001585}
1586
Chet Haase48659092012-05-31 15:21:51 -07001587status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001588 Rect r(0.0f, 0.0f, bitmap->width(), bitmap->height());
1589 const mat4 transform(*matrix);
1590 transform.mapRect(r);
1591
Romain Guya3dc55f2012-09-28 13:55:44 -07001592 const bool reject = quickRejectNoScissor(r.left, r.top, r.right, r.bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001593 uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001594 addBitmap(bitmap);
1595 addMatrix(matrix);
1596 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001597 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001598 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001599}
1600
Chet Haase48659092012-05-31 15:21:51 -07001601status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
Romain Guy4aa90572010-09-26 18:40:37 -07001602 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -07001603 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guya3dc55f2012-09-28 13:55:44 -07001604 const bool reject = quickRejectNoScissor(dstLeft, dstTop, dstRight, dstBottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001605 uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001606 addBitmap(bitmap);
1607 addBounds(srcLeft, srcTop, srcRight, srcBottom);
1608 addBounds(dstLeft, dstTop, dstRight, dstBottom);
1609 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001610 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001611 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001612}
1613
Chet Haase48659092012-05-31 15:21:51 -07001614status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
1615 SkPaint* paint) {
Romain Guya3dc55f2012-09-28 13:55:44 -07001616 const bool reject = quickRejectNoScissor(left, top,
1617 left + bitmap->width(), top + bitmap->height());
Romain Guye651cc62012-05-14 19:44:40 -07001618 uint32_t* location = addOp(DisplayList::DrawBitmapData, reject);
1619 addBitmapData(bitmap);
1620 addPoint(left, top);
1621 addPaint(paint);
1622 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001623 return DrawGlInfo::kStatusDone;
Romain Guye651cc62012-05-14 19:44:40 -07001624}
1625
Chet Haase48659092012-05-31 15:21:51 -07001626status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
Romain Guy5a7b4662011-01-20 19:09:30 -08001627 float* vertices, int* colors, SkPaint* paint) {
1628 addOp(DisplayList::DrawBitmapMesh);
1629 addBitmap(bitmap);
1630 addInt(meshWidth);
1631 addInt(meshHeight);
1632 addFloats(vertices, (meshWidth + 1) * (meshHeight + 1) * 2);
1633 if (colors) {
1634 addInt(1);
1635 addInts(colors, (meshWidth + 1) * (meshHeight + 1));
1636 } else {
1637 addInt(0);
1638 }
1639 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001640 return DrawGlInfo::kStatusDone;
Romain Guy5a7b4662011-01-20 19:09:30 -08001641}
1642
Chet Haase48659092012-05-31 15:21:51 -07001643status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs,
1644 const int32_t* yDivs, const uint32_t* colors, uint32_t width, uint32_t height,
1645 int8_t numColors, float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guybe6f9dc2012-07-16 12:41:17 -07001646 int alpha;
1647 SkXfermode::Mode mode;
1648 OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
1649
Romain Guya3dc55f2012-09-28 13:55:44 -07001650 const bool reject = quickRejectNoScissor(left, top, right, bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001651 uint32_t* location = addOp(DisplayList::DrawPatch, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001652 addBitmap(bitmap);
1653 addInts(xDivs, width);
1654 addInts(yDivs, height);
Romain Guy4bb94202010-10-12 15:59:26 -07001655 addUInts(colors, numColors);
Romain Guy4aa90572010-09-26 18:40:37 -07001656 addBounds(left, top, right, bottom);
Romain Guybe6f9dc2012-07-16 12:41:17 -07001657 addInt(alpha);
1658 addInt(mode);
Romain Guy33f6beb2012-02-16 19:24:51 -08001659 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001660 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001661}
1662
Chet Haase48659092012-05-31 15:21:51 -07001663status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
Romain Guyb051e892010-09-28 19:09:36 -07001664 addOp(DisplayList::DrawColor);
Romain Guy4aa90572010-09-26 18:40:37 -07001665 addInt(color);
1666 addInt(mode);
Chet Haase48659092012-05-31 15:21:51 -07001667 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001668}
1669
Chet Haase48659092012-05-31 15:21:51 -07001670status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001671 SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001672 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
Romain Guya3dc55f2012-09-28 13:55:44 -07001673 quickRejectNoScissor(left, top, right, bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001674 uint32_t* location = addOp(DisplayList::DrawRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001675 addBounds(left, top, right, bottom);
1676 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001677 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001678 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001679}
1680
Chet Haase48659092012-05-31 15:21:51 -07001681status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
Chet Haasea1cff502012-02-21 13:43:44 -08001682 float rx, float ry, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001683 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
Romain Guya3dc55f2012-09-28 13:55:44 -07001684 quickRejectNoScissor(left, top, right, bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001685 uint32_t* location = addOp(DisplayList::DrawRoundRect, reject);
Romain Guy01d58e42011-01-19 21:54:02 -08001686 addBounds(left, top, right, bottom);
1687 addPoint(rx, ry);
1688 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001689 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001690 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001691}
1692
Chet Haase48659092012-05-31 15:21:51 -07001693status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
Romain Guy01d58e42011-01-19 21:54:02 -08001694 addOp(DisplayList::DrawCircle);
1695 addPoint(x, y);
1696 addFloat(radius);
1697 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001698 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001699}
1700
Chet Haase48659092012-05-31 15:21:51 -07001701status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001702 SkPaint* paint) {
1703 addOp(DisplayList::DrawOval);
1704 addBounds(left, top, right, bottom);
1705 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001706 return DrawGlInfo::kStatusDone;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001707}
1708
Chet Haase48659092012-05-31 15:21:51 -07001709status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
Romain Guy8b2f5262011-01-23 16:15:02 -08001710 float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
Romain Guy82d41a52011-01-24 21:53:42 -08001711 addOp(DisplayList::DrawArc);
Romain Guy8b2f5262011-01-23 16:15:02 -08001712 addBounds(left, top, right, bottom);
1713 addPoint(startAngle, sweepAngle);
1714 addInt(useCenter ? 1 : 0);
1715 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001716 return DrawGlInfo::kStatusDone;
Romain Guy8b2f5262011-01-23 16:15:02 -08001717}
1718
Chet Haase48659092012-05-31 15:21:51 -07001719status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001720 float left, top, offset;
1721 uint32_t width, height;
1722 computePathBounds(path, paint, left, top, offset, width, height);
1723
Romain Guy95c21d02012-07-17 17:46:03 -07001724 left -= offset;
1725 top -= offset;
1726
Romain Guya3dc55f2012-09-28 13:55:44 -07001727 const bool reject = quickRejectNoScissor(left, top, left + width, top + height);
Romain Guy33f6beb2012-02-16 19:24:51 -08001728 uint32_t* location = addOp(DisplayList::DrawPath, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001729 addPath(path);
1730 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001731 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001732 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001733}
1734
Chet Haase48659092012-05-31 15:21:51 -07001735status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -07001736 addOp(DisplayList::DrawLines);
Romain Guy4aa90572010-09-26 18:40:37 -07001737 addFloats(points, count);
1738 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001739 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001740}
1741
Chet Haase48659092012-05-31 15:21:51 -07001742status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
Romain Guyed6fcb02011-03-21 13:11:28 -07001743 addOp(DisplayList::DrawPoints);
1744 addFloats(points, count);
1745 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001746 return DrawGlInfo::kStatusDone;
Romain Guyed6fcb02011-03-21 13:11:28 -07001747}
1748
Chet Haase48659092012-05-31 15:21:51 -07001749status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
Romain Guy325740f2012-02-24 16:48:34 -08001750 SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001751 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001752 addOp(DisplayList::DrawTextOnPath);
1753 addText(text, bytesCount);
1754 addInt(count);
1755 addPath(path);
1756 addFloat(hOffset);
1757 addFloat(vOffset);
1758 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001759 SkPaint* addedPaint = addPaint(paint);
1760 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1761 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001762 return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001763}
1764
Chet Haase48659092012-05-31 15:21:51 -07001765status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
Romain Guyeb9a5362012-01-17 17:39:26 -08001766 const float* positions, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001767 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001768 addOp(DisplayList::DrawPosText);
1769 addText(text, bytesCount);
1770 addInt(count);
1771 addFloats(positions, count * 2);
1772 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001773 SkPaint* addedPaint = addPaint(paint);
1774 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1775 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001776 return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001777}
1778
Romain Guyc2525952012-07-27 16:41:22 -07001779status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
Raph Levien996e57c2012-07-23 15:22:52 -07001780 float x, float y, const float* positions, SkPaint* paint, float length) {
1781 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
1782
1783 // TODO: We should probably make a copy of the paint instead of modifying
1784 // it; modifying the paint will change its generationID the first
1785 // time, which might impact caches. More investigation needed to
1786 // see if it matters.
1787 // If we make a copy, then drawTextDecorations() should *not* make
1788 // its own copy as it does right now.
1789 // Beware: this needs Glyph encoding (already done on the Paint constructor)
1790 paint->setAntiAlias(true);
1791 if (length < 0.0f) length = paint->measureText(text, bytesCount);
1792
1793 bool reject = false;
1794 if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) {
1795 SkPaint::FontMetrics metrics;
1796 paint->getFontMetrics(&metrics, 0.0f);
Romain Guya3dc55f2012-09-28 13:55:44 -07001797 reject = quickRejectNoScissor(x, y + metrics.fTop, x + length, y + metrics.fBottom);
Raph Levien996e57c2012-07-23 15:22:52 -07001798 }
1799
Romain Guyc2525952012-07-27 16:41:22 -07001800 uint32_t* location = addOp(DisplayList::DrawText, reject);
Raph Levien996e57c2012-07-23 15:22:52 -07001801 addText(text, bytesCount);
1802 addInt(count);
1803 addFloat(x);
1804 addFloat(y);
1805 addFloats(positions, count * 2);
Chet Haasee816bae2012-08-09 13:39:02 -07001806 SkPaint* addedPaint = addPaint(paint);
1807 if (!reject) {
1808 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1809 fontRenderer.precache(addedPaint, text, count);
1810 }
Raph Levien996e57c2012-07-23 15:22:52 -07001811 addFloat(length);
1812 addSkip(location);
1813 return DrawGlInfo::kStatusDone;
1814}
1815
Romain Guy4aa90572010-09-26 18:40:37 -07001816void DisplayListRenderer::resetShader() {
Romain Guyb051e892010-09-28 19:09:36 -07001817 addOp(DisplayList::ResetShader);
Romain Guy4aa90572010-09-26 18:40:37 -07001818}
1819
1820void DisplayListRenderer::setupShader(SkiaShader* shader) {
Chet Haase5c13d892010-10-08 08:37:55 -07001821 addOp(DisplayList::SetupShader);
1822 addShader(shader);
Romain Guy4aa90572010-09-26 18:40:37 -07001823}
1824
1825void DisplayListRenderer::resetColorFilter() {
Romain Guyb051e892010-09-28 19:09:36 -07001826 addOp(DisplayList::ResetColorFilter);
Romain Guy4aa90572010-09-26 18:40:37 -07001827}
1828
1829void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
Chet Haasead93c2b2010-10-22 16:17:12 -07001830 addOp(DisplayList::SetupColorFilter);
1831 addColorFilter(filter);
Romain Guy4aa90572010-09-26 18:40:37 -07001832}
1833
1834void DisplayListRenderer::resetShadow() {
Romain Guyb051e892010-09-28 19:09:36 -07001835 addOp(DisplayList::ResetShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001836}
1837
1838void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
Romain Guyb051e892010-09-28 19:09:36 -07001839 addOp(DisplayList::SetupShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001840 addFloat(radius);
1841 addPoint(dx, dy);
1842 addInt(color);
Romain Guy4aa90572010-09-26 18:40:37 -07001843}
1844
Romain Guy5ff9df62012-01-23 17:09:05 -08001845void DisplayListRenderer::resetPaintFilter() {
1846 addOp(DisplayList::ResetPaintFilter);
1847}
1848
1849void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
1850 addOp(DisplayList::SetupPaintFilter);
1851 addInt(clearBits);
1852 addInt(setBits);
1853}
1854
Romain Guy4aa90572010-09-26 18:40:37 -07001855}; // namespace uirenderer
1856}; // namespace android