blob: 747856ce9d87473957eb2723bc25921853c90d94 [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 Guy672433d2013-01-04 19:05:13 -080067 "DrawRects",
Romain Guyffac7fc2011-01-13 17:21:49 -080068 "ResetShader",
69 "SetupShader",
70 "ResetColorFilter",
71 "SetupColorFilter",
72 "ResetShadow",
Chet Haasedaf98e92011-01-10 14:10:36 -080073 "SetupShadow",
Romain Guy5ff9df62012-01-23 17:09:05 -080074 "ResetPaintFilter",
75 "SetupPaintFilter",
Chet Haasedaf98e92011-01-10 14:10:36 -080076 "DrawGLFunction"
Romain Guyffac7fc2011-01-13 17:21:49 -080077};
78
Chet Haase9c1e23b2011-03-24 10:51:31 -070079void DisplayList::outputLogBuffer(int fd) {
80 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
81 if (logBuffer.isEmpty()) {
82 return;
83 }
Romain Guy65b345f2011-07-27 18:51:50 -070084
Chet Haase9c1e23b2011-03-24 10:51:31 -070085 FILE *file = fdopen(fd, "a");
Romain Guy65b345f2011-07-27 18:51:50 -070086
Chet Haase9c1e23b2011-03-24 10:51:31 -070087 fprintf(file, "\nRecent DisplayList operations\n");
88 logBuffer.outputCommands(file, OP_NAMES);
Romain Guy65b345f2011-07-27 18:51:50 -070089
90 String8 cachesLog;
91 Caches::getInstance().dumpMemoryUsage(cachesLog);
92 fprintf(file, "\nCaches:\n%s", cachesLog.string());
93 fprintf(file, "\n");
94
Chet Haase9c1e23b2011-03-24 10:51:31 -070095 fflush(file);
96}
97
Chet Haase491189f2012-03-13 11:42:34 -070098DisplayList::DisplayList(const DisplayListRenderer& recorder) :
Chet Haase9420abd2012-03-29 16:28:32 -070099 mTransformMatrix(NULL), mTransformCamera(NULL), mTransformMatrix3D(NULL),
100 mStaticMatrix(NULL), mAnimationMatrix(NULL) {
Chet Haase491189f2012-03-13 11:42:34 -0700101
Chet Haase5977baa2011-01-05 18:01:22 -0800102 initFromDisplayListRenderer(recorder);
103}
104
105DisplayList::~DisplayList() {
Chet Haased63cbd12011-02-03 16:32:46 -0800106 clearResources();
107}
108
Romain Guybb0acdf2012-03-05 13:44:35 -0800109void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) {
110 if (displayList) {
111 DISPLAY_LIST_LOGD("Deferring display list destruction");
112 Caches::getInstance().deleteDisplayListDeferred(displayList);
113 }
114}
115
Chet Haased63cbd12011-02-03 16:32:46 -0800116void DisplayList::clearResources() {
Chet Haase5977baa2011-01-05 18:01:22 -0800117 sk_free((void*) mReader.base());
Romain Guy034de6b2012-09-27 19:01:55 -0700118 mReader.setMemory(NULL, 0);
Chet Haase5977baa2011-01-05 18:01:22 -0800119
Chet Haase1271e2c2012-04-20 09:54:27 -0700120 delete mTransformMatrix;
121 delete mTransformCamera;
122 delete mTransformMatrix3D;
123 delete mStaticMatrix;
124 delete mAnimationMatrix;
Romain Guy58ecc202012-09-07 11:58:36 -0700125
Chet Haase1271e2c2012-04-20 09:54:27 -0700126 mTransformMatrix = NULL;
127 mTransformCamera = NULL;
128 mTransformMatrix3D = NULL;
129 mStaticMatrix = NULL;
130 mAnimationMatrix = NULL;
Chet Haasea1cff502012-02-21 13:43:44 -0800131
Chet Haase5977baa2011-01-05 18:01:22 -0800132 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700133 caches.unregisterFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700134 caches.resourceCache.lock();
Chet Haase5977baa2011-01-05 18:01:22 -0800135
136 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700137 caches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800138 }
Chet Haase5977baa2011-01-05 18:01:22 -0800139
Romain Guy49c5fc02012-05-15 11:10:01 -0700140 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
141 SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
Romain Guy58ecc202012-09-07 11:58:36 -0700142 caches.resourceCache.decrementRefcountLocked(bitmap);
143 caches.resourceCache.destructorLocked(bitmap);
Romain Guy49c5fc02012-05-15 11:10:01 -0700144 }
Romain Guy49c5fc02012-05-15 11:10:01 -0700145
Romain Guyd586ad92011-06-22 16:14:36 -0700146 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700147 caches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -0700148 }
Romain Guyd586ad92011-06-22 16:14:36 -0700149
Romain Guy24c00212011-01-14 15:31:00 -0800150 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700151 caches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
152 caches.resourceCache.destructorLocked(mShaders.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800153 }
Romain Guy58ecc202012-09-07 11:58:36 -0700154
155 for (size_t i = 0; i < mSourcePaths.size(); i++) {
156 caches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
157 }
158
Chet Haase603f6de2012-09-14 15:31:25 -0700159 for (size_t i = 0; i < mLayers.size(); i++) {
160 caches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
161 }
162
Romain Guy58ecc202012-09-07 11:58:36 -0700163 caches.resourceCache.unlock();
Chet Haase5977baa2011-01-05 18:01:22 -0800164
165 for (size_t i = 0; i < mPaints.size(); i++) {
166 delete mPaints.itemAt(i);
167 }
Chet Haase5977baa2011-01-05 18:01:22 -0800168
Romain Guy2fc941e2011-02-03 15:06:05 -0800169 for (size_t i = 0; i < mPaths.size(); i++) {
Romain Guy1af23a32011-03-24 16:03:55 -0700170 SkPath* path = mPaths.itemAt(i);
171 caches.pathCache.remove(path);
172 delete path;
Romain Guy2fc941e2011-02-03 15:06:05 -0800173 }
Chet Haased34dd712012-05-02 18:50:34 -0700174
Chet Haase5977baa2011-01-05 18:01:22 -0800175 for (size_t i = 0; i < mMatrices.size(); i++) {
176 delete mMatrices.itemAt(i);
177 }
Romain Guy58ecc202012-09-07 11:58:36 -0700178
179 mBitmapResources.clear();
180 mOwnedBitmapResources.clear();
181 mFilterResources.clear();
182 mShaders.clear();
183 mSourcePaths.clear();
184 mPaints.clear();
185 mPaths.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800186 mMatrices.clear();
Chet Haase603f6de2012-09-14 15:31:25 -0700187 mLayers.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800188}
189
Chet Haase6a2d17f2012-09-30 12:14:13 -0700190void DisplayList::reset() {
191 clearResources();
192 init();
193}
194
Chet Haased63cbd12011-02-03 16:32:46 -0800195void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
Romain Guyb051e892010-09-28 19:09:36 -0700196
Chet Haased63cbd12011-02-03 16:32:46 -0800197 if (reusing) {
198 // re-using display list - clear out previous allocations
199 clearResources();
200 }
Romain Guy034de6b2012-09-27 19:01:55 -0700201
202 init();
Chet Haased63cbd12011-02-03 16:32:46 -0800203
Chet Haase6a2d17f2012-09-30 12:14:13 -0700204 const SkWriter32& writer = recorder.writeStream();
Romain Guy034de6b2012-09-27 19:01:55 -0700205 if (writer.size() == 0) {
206 return;
207 }
208
Romain Guy65b345f2011-07-27 18:51:50 -0700209 mSize = writer.size();
210 void* buffer = sk_malloc_throw(mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700211 writer.flatten(buffer);
Romain Guy65b345f2011-07-27 18:51:50 -0700212 mReader.setMemory(buffer, mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700213
Romain Guy54c1a642012-09-27 17:55:46 -0700214 mFunctorCount = recorder.getFunctorCount();
215
Chet Haase5c13d892010-10-08 08:37:55 -0700216 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700217 caches.registerFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700218 caches.resourceCache.lock();
Romain Guyb051e892010-09-28 19:09:36 -0700219
Romain Guy49c5fc02012-05-15 11:10:01 -0700220 const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
Chet Haase5c13d892010-10-08 08:37:55 -0700221 for (size_t i = 0; i < bitmapResources.size(); i++) {
222 SkBitmap* resource = bitmapResources.itemAt(i);
223 mBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700224 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700225 }
Chet Haased98aa2d2010-10-25 15:47:32 -0700226
Romain Guy49c5fc02012-05-15 11:10:01 -0700227 const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources();
228 for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
229 SkBitmap* resource = ownedBitmapResources.itemAt(i);
230 mOwnedBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700231 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guy49c5fc02012-05-15 11:10:01 -0700232 }
233
234 const Vector<SkiaColorFilter*>& filterResources = recorder.getFilterResources();
Romain Guyd586ad92011-06-22 16:14:36 -0700235 for (size_t i = 0; i < filterResources.size(); i++) {
236 SkiaColorFilter* resource = filterResources.itemAt(i);
237 mFilterResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700238 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyd586ad92011-06-22 16:14:36 -0700239 }
240
Romain Guy49c5fc02012-05-15 11:10:01 -0700241 const Vector<SkiaShader*>& shaders = recorder.getShaders();
Romain Guy24c00212011-01-14 15:31:00 -0800242 for (size_t i = 0; i < shaders.size(); i++) {
Romain Guyd586ad92011-06-22 16:14:36 -0700243 SkiaShader* resource = shaders.itemAt(i);
244 mShaders.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700245 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700246 }
247
Romain Guy58ecc202012-09-07 11:58:36 -0700248 const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths();
249 for (size_t i = 0; i < sourcePaths.size(); i++) {
250 mSourcePaths.add(sourcePaths.itemAt(i));
251 caches.resourceCache.incrementRefcountLocked(sourcePaths.itemAt(i));
252 }
253
Chet Haase603f6de2012-09-14 15:31:25 -0700254 const Vector<Layer*>& layers = recorder.getLayers();
255 for (size_t i = 0; i < layers.size(); i++) {
256 mLayers.add(layers.itemAt(i));
257 caches.resourceCache.incrementRefcountLocked(layers.itemAt(i));
258 }
259
Romain Guy58ecc202012-09-07 11:58:36 -0700260 caches.resourceCache.unlock();
261
Romain Guy49c5fc02012-05-15 11:10:01 -0700262 const Vector<SkPaint*>& paints = recorder.getPaints();
Chet Haased98aa2d2010-10-25 15:47:32 -0700263 for (size_t i = 0; i < paints.size(); i++) {
264 mPaints.add(paints.itemAt(i));
265 }
266
Romain Guy49c5fc02012-05-15 11:10:01 -0700267 const Vector<SkPath*>& paths = recorder.getPaths();
Romain Guy2fc941e2011-02-03 15:06:05 -0800268 for (size_t i = 0; i < paths.size(); i++) {
269 mPaths.add(paths.itemAt(i));
270 }
271
Romain Guy49c5fc02012-05-15 11:10:01 -0700272 const Vector<SkMatrix*>& matrices = recorder.getMatrices();
Chet Haased98aa2d2010-10-25 15:47:32 -0700273 for (size_t i = 0; i < matrices.size(); i++) {
274 mMatrices.add(matrices.itemAt(i));
275 }
Romain Guyb051e892010-09-28 19:09:36 -0700276}
277
Romain Guyb051e892010-09-28 19:09:36 -0700278void DisplayList::init() {
Romain Guy65b345f2011-07-27 18:51:50 -0700279 mSize = 0;
Romain Guy04c9d8c2011-08-25 14:01:48 -0700280 mIsRenderable = true;
Romain Guy034de6b2012-09-27 19:01:55 -0700281 mFunctorCount = 0;
Chet Haase6a2d17f2012-09-30 12:14:13 -0700282 mLeft = 0;
283 mTop = 0;
284 mRight = 0;
285 mBottom = 0;
286 mClipChildren = true;
287 mAlpha = 1;
288 mMultipliedAlpha = 255;
289 mHasOverlappingRendering = true;
290 mTranslationX = 0;
291 mTranslationY = 0;
292 mRotation = 0;
293 mRotationX = 0;
294 mRotationY= 0;
295 mScaleX = 1;
296 mScaleY = 1;
297 mPivotX = 0;
298 mPivotY = 0;
299 mCameraDistance = 0;
300 mMatrixDirty = false;
301 mMatrixFlags = 0;
302 mPrevWidth = -1;
303 mPrevHeight = -1;
304 mWidth = 0;
305 mHeight = 0;
306 mPivotExplicitlySet = false;
307 mCaching = false;
Romain Guy65b345f2011-07-27 18:51:50 -0700308}
309
310size_t DisplayList::getSize() {
311 return mSize;
Romain Guyb051e892010-09-28 19:09:36 -0700312}
313
Chet Haaseed30fd82011-04-22 16:18:45 -0700314/**
315 * This function is a simplified version of replay(), where we simply retrieve and log the
316 * display list. This function should remain in sync with the replay() function.
317 */
318void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
319 TextContainer text;
320
321 uint32_t count = (level + 1) * 2;
322 char indent[count + 1];
323 for (uint32_t i = 0; i < count; i++) {
324 indent[i] = ' ';
325 }
326 indent[count] = '\0';
Romain Guyddf74372012-05-22 14:07:07 -0700327 ALOGD("%sStart display list (%p, %s, render=%d)", (char*) indent + 2, this,
328 mName.string(), isRenderable());
Chet Haaseed30fd82011-04-22 16:18:45 -0700329
Chet Haase1271e2c2012-04-20 09:54:27 -0700330 ALOGD("%s%s %d", indent, "Save", SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
Chet Haaseed30fd82011-04-22 16:18:45 -0700331 int saveCount = renderer.getSaveCount() - 1;
332
Chet Haasea1cff502012-02-21 13:43:44 -0800333 outputViewProperties(renderer, (char*) indent);
Chet Haaseed30fd82011-04-22 16:18:45 -0700334 mReader.rewind();
335
336 while (!mReader.eof()) {
337 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800338 if (op & OP_MAY_BE_SKIPPED_MASK) {
339 int skip = mReader.readInt();
340 ALOGD("%sSkip %d", (char*) indent, skip);
341 op &= ~OP_MAY_BE_SKIPPED_MASK;
Chet Haasea1cff502012-02-21 13:43:44 -0800342 }
Chet Haaseed30fd82011-04-22 16:18:45 -0700343
344 switch (op) {
345 case DrawGLFunction: {
346 Functor *functor = (Functor *) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000347 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Chet Haaseed30fd82011-04-22 16:18:45 -0700348 }
349 break;
350 case Save: {
351 int rendererNum = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000352 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
Chet Haaseed30fd82011-04-22 16:18:45 -0700353 }
354 break;
355 case Restore: {
Steve Block5baa3a62011-12-20 16:23:08 +0000356 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700357 }
358 break;
359 case RestoreToCount: {
360 int restoreCount = saveCount + getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000361 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
Chet Haaseed30fd82011-04-22 16:18:45 -0700362 }
363 break;
364 case SaveLayer: {
365 float f1 = getFloat();
366 float f2 = getFloat();
367 float f3 = getFloat();
368 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800369 SkPaint* paint = getPaint(renderer);
Chet Haaseed30fd82011-04-22 16:18:45 -0700370 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000371 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800372 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700373 }
374 break;
375 case SaveLayerAlpha: {
376 float f1 = getFloat();
377 float f2 = getFloat();
378 float f3 = getFloat();
379 float f4 = getFloat();
380 int alpha = getInt();
381 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000382 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800383 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700384 }
385 break;
386 case Translate: {
387 float f1 = getFloat();
388 float f2 = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000389 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
Chet Haaseed30fd82011-04-22 16:18:45 -0700390 }
391 break;
392 case Rotate: {
393 float rotation = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000394 ALOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
Chet Haaseed30fd82011-04-22 16:18:45 -0700395 }
396 break;
397 case Scale: {
398 float sx = getFloat();
399 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000400 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700401 }
402 break;
403 case Skew: {
404 float sx = getFloat();
405 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000406 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700407 }
408 break;
409 case SetMatrix: {
410 SkMatrix* matrix = getMatrix();
Steve Block5baa3a62011-12-20 16:23:08 +0000411 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
Chet Haaseed30fd82011-04-22 16:18:45 -0700412 }
413 break;
414 case ConcatMatrix: {
415 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -0800416 ALOGD("%s%s new concat %p: [%f, %f, %f] [%f, %f, %f] [%f, %f, %f]",
417 (char*) indent, OP_NAMES[op], matrix, matrix->get(0), matrix->get(1),
418 matrix->get(2), matrix->get(3), matrix->get(4), matrix->get(5),
419 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haaseed30fd82011-04-22 16:18:45 -0700420 }
421 break;
422 case ClipRect: {
423 float f1 = getFloat();
424 float f2 = getFloat();
425 float f3 = getFloat();
426 float f4 = getFloat();
427 int regionOp = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000428 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800429 f1, f2, f3, f4, regionOp);
Chet Haaseed30fd82011-04-22 16:18:45 -0700430 }
431 break;
432 case DrawDisplayList: {
433 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -0800434 int32_t flags = getInt();
435 ALOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -0700436 displayList, mWidth, mHeight, flags, level + 1);
Chet Haaseed30fd82011-04-22 16:18:45 -0700437 renderer.outputDisplayList(displayList, level + 1);
438 }
439 break;
440 case DrawLayer: {
441 Layer* layer = (Layer*) getInt();
442 float x = getFloat();
443 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800444 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000445 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800446 layer, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700447 }
448 break;
449 case DrawBitmap: {
450 SkBitmap* bitmap = getBitmap();
451 float x = getFloat();
452 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800453 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000454 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800455 bitmap, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700456 }
457 break;
458 case DrawBitmapMatrix: {
459 SkBitmap* bitmap = getBitmap();
460 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -0800461 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000462 ALOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800463 bitmap, matrix, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700464 }
465 break;
466 case DrawBitmapRect: {
467 SkBitmap* bitmap = getBitmap();
468 float f1 = getFloat();
469 float f2 = getFloat();
470 float f3 = getFloat();
471 float f4 = getFloat();
472 float f5 = getFloat();
473 float f6 = getFloat();
474 float f7 = getFloat();
475 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800476 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000477 ALOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800478 (char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700479 }
480 break;
Romain Guye651cc62012-05-14 19:44:40 -0700481 case DrawBitmapData: {
482 SkBitmap* bitmap = getBitmapData();
483 float x = getFloat();
484 float y = getFloat();
485 SkPaint* paint = getPaint(renderer);
486 ALOGD("%s%s %.2f, %.2f, %p", (char*) indent, OP_NAMES[op], x, y, paint);
487 }
488 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700489 case DrawBitmapMesh: {
490 int verticesCount = 0;
491 uint32_t colorsCount = 0;
492 SkBitmap* bitmap = getBitmap();
493 uint32_t meshWidth = getInt();
494 uint32_t meshHeight = getInt();
495 float* vertices = getFloats(verticesCount);
496 bool hasColors = getInt();
497 int* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -0800498 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000499 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700500 }
501 break;
502 case DrawPatch: {
503 int32_t* xDivs = NULL;
504 int32_t* yDivs = NULL;
505 uint32_t* colors = NULL;
506 uint32_t xDivsCount = 0;
507 uint32_t yDivsCount = 0;
508 int8_t numColors = 0;
509 SkBitmap* bitmap = getBitmap();
510 xDivs = getInts(xDivsCount);
511 yDivs = getInts(yDivsCount);
512 colors = getUInts(numColors);
Romain Guya62f1722011-10-19 17:06:19 -0700513 float left = getFloat();
514 float top = getFloat();
515 float right = getFloat();
516 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -0700517 int alpha = getInt();
518 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000519 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", (char*) indent, OP_NAMES[op],
Romain Guya62f1722011-10-19 17:06:19 -0700520 left, top, right, bottom);
Chet Haaseed30fd82011-04-22 16:18:45 -0700521 }
522 break;
523 case DrawColor: {
524 int color = getInt();
525 int xferMode = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000526 ALOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haaseed30fd82011-04-22 16:18:45 -0700527 }
528 break;
529 case DrawRect: {
530 float f1 = getFloat();
531 float f2 = getFloat();
532 float f3 = getFloat();
533 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800534 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000535 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800536 f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700537 }
538 break;
539 case DrawRoundRect: {
540 float f1 = getFloat();
541 float f2 = getFloat();
542 float f3 = getFloat();
543 float f4 = getFloat();
544 float f5 = getFloat();
545 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800546 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000547 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800548 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700549 }
550 break;
551 case DrawCircle: {
552 float f1 = getFloat();
553 float f2 = getFloat();
554 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800555 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000556 ALOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800557 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700558 }
559 break;
560 case DrawOval: {
561 float f1 = getFloat();
562 float f2 = getFloat();
563 float f3 = getFloat();
564 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800565 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000566 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800567 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700568 }
569 break;
570 case DrawArc: {
571 float f1 = getFloat();
572 float f2 = getFloat();
573 float f3 = getFloat();
574 float f4 = getFloat();
575 float f5 = getFloat();
576 float f6 = getFloat();
577 int i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -0800578 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000579 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800580 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700581 }
582 break;
583 case DrawPath: {
584 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -0800585 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000586 ALOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700587 }
588 break;
589 case DrawLines: {
590 int count = 0;
591 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800592 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000593 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700594 }
595 break;
596 case DrawPoints: {
597 int count = 0;
598 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800599 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000600 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700601 }
602 break;
Romain Guy325740f2012-02-24 16:48:34 -0800603 case DrawTextOnPath: {
604 getText(&text);
605 int32_t count = getInt();
606 SkPath* path = getPath();
607 float hOffset = getFloat();
608 float vOffset = getFloat();
609 SkPaint* paint = getPaint(renderer);
610 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
611 text.text(), text.length(), count, paint);
612 }
613 break;
Romain Guyeb9a5362012-01-17 17:39:26 -0800614 case DrawPosText: {
615 getText(&text);
616 int count = getInt();
617 int positionsCount = 0;
618 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -0800619 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -0800620 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800621 text.text(), text.length(), count, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -0800622 }
Raph Levien996e57c2012-07-23 15:22:52 -0700623 break;
Romain Guyc2525952012-07-27 16:41:22 -0700624 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -0700625 getText(&text);
Romain Guy18edb812012-08-03 16:06:55 -0700626 int32_t count = getInt();
627 float x = getFloat();
628 float y = getFloat();
629 int32_t positionsCount = 0;
Raph Levien996e57c2012-07-23 15:22:52 -0700630 float* positions = getFloats(positionsCount);
631 SkPaint* paint = getPaint(renderer);
Romain Guy18edb812012-08-03 16:06:55 -0700632 float length = getFloat();
Raph Levien996e57c2012-07-23 15:22:52 -0700633 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
634 text.text(), text.length(), count, paint);
635 }
636 break;
Romain Guy672433d2013-01-04 19:05:13 -0800637 case DrawRects: {
638 int32_t count = 0;
639 float* rects = getFloats(count);
640 SkPaint* paint = getPaint(renderer);
641 ALOGD("%s%s %d, %p", (char*) indent, OP_NAMES[op], count / 4, paint);
642 }
643 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700644 case ResetShader: {
Steve Block5baa3a62011-12-20 16:23:08 +0000645 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700646 }
647 break;
648 case SetupShader: {
649 SkiaShader* shader = getShader();
Steve Block5baa3a62011-12-20 16:23:08 +0000650 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
Chet Haaseed30fd82011-04-22 16:18:45 -0700651 }
652 break;
653 case ResetColorFilter: {
Steve Block5baa3a62011-12-20 16:23:08 +0000654 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700655 }
656 break;
657 case SetupColorFilter: {
658 SkiaColorFilter *colorFilter = getColorFilter();
Steve Block5baa3a62011-12-20 16:23:08 +0000659 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
Chet Haaseed30fd82011-04-22 16:18:45 -0700660 }
661 break;
662 case ResetShadow: {
Steve Block5baa3a62011-12-20 16:23:08 +0000663 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700664 }
665 break;
666 case SetupShadow: {
667 float radius = getFloat();
668 float dx = getFloat();
669 float dy = getFloat();
670 int color = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000671 ALOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800672 radius, dx, dy, color);
Chet Haaseed30fd82011-04-22 16:18:45 -0700673 }
674 break;
Romain Guy5ff9df62012-01-23 17:09:05 -0800675 case ResetPaintFilter: {
676 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
677 }
678 break;
679 case SetupPaintFilter: {
680 int clearBits = getInt();
681 int setBits = getInt();
682 ALOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op], clearBits, setBits);
683 }
684 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700685 default:
Steve Block5baa3a62011-12-20 16:23:08 +0000686 ALOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -0800687 (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700688 break;
689 }
690 }
Chet Haasea1cff502012-02-21 13:43:44 -0800691 ALOGD("%sDone (%p, %s)", (char*) indent + 2, this, mName.string());
Chet Haaseed30fd82011-04-22 16:18:45 -0700692}
693
Chet Haasea1cff502012-02-21 13:43:44 -0800694void DisplayList::updateMatrix() {
695 if (mMatrixDirty) {
696 if (!mTransformMatrix) {
697 mTransformMatrix = new SkMatrix();
698 }
699 if (mMatrixFlags == 0 || mMatrixFlags == TRANSLATION) {
700 mTransformMatrix->reset();
701 } else {
702 if (!mPivotExplicitlySet) {
703 if (mWidth != mPrevWidth || mHeight != mPrevHeight) {
704 mPrevWidth = mWidth;
705 mPrevHeight = mHeight;
706 mPivotX = mPrevWidth / 2;
707 mPivotY = mPrevHeight / 2;
708 }
709 }
710 if ((mMatrixFlags & ROTATION_3D) == 0) {
711 mTransformMatrix->setTranslate(mTranslationX, mTranslationY);
712 mTransformMatrix->preRotate(mRotation, mPivotX, mPivotY);
713 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
714 } else {
715 if (!mTransformCamera) {
716 mTransformCamera = new Sk3DView();
717 mTransformMatrix3D = new SkMatrix();
718 }
719 mTransformMatrix->reset();
720 mTransformCamera->save();
721 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
722 mTransformCamera->rotateX(mRotationX);
723 mTransformCamera->rotateY(mRotationY);
724 mTransformCamera->rotateZ(-mRotation);
725 mTransformCamera->getMatrix(mTransformMatrix3D);
726 mTransformMatrix3D->preTranslate(-mPivotX, -mPivotY);
727 mTransformMatrix3D->postTranslate(mPivotX + mTranslationX,
728 mPivotY + mTranslationY);
729 mTransformMatrix->postConcat(*mTransformMatrix3D);
730 mTransformCamera->restore();
731 }
732 }
733 mMatrixDirty = false;
734 }
735}
736
737void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
Chet Haase1271e2c2012-04-20 09:54:27 -0700738 updateMatrix();
739 if (mLeft != 0 || mTop != 0) {
740 ALOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
741 }
742 if (mStaticMatrix) {
743 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
744 indent, "ConcatMatrix (static)", mStaticMatrix,
745 mStaticMatrix->get(0), mStaticMatrix->get(1),
746 mStaticMatrix->get(2), mStaticMatrix->get(3),
747 mStaticMatrix->get(4), mStaticMatrix->get(5),
748 mStaticMatrix->get(6), mStaticMatrix->get(7),
749 mStaticMatrix->get(8));
750 }
751 if (mAnimationMatrix) {
752 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
753 indent, "ConcatMatrix (animation)", mAnimationMatrix,
754 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
755 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
756 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
757 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
758 mAnimationMatrix->get(8));
759 }
760 if (mMatrixFlags != 0) {
761 if (mMatrixFlags == TRANSLATION) {
762 ALOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
763 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700764 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700765 indent, "ConcatMatrix", mTransformMatrix,
766 mTransformMatrix->get(0), mTransformMatrix->get(1),
767 mTransformMatrix->get(2), mTransformMatrix->get(3),
768 mTransformMatrix->get(4), mTransformMatrix->get(5),
769 mTransformMatrix->get(6), mTransformMatrix->get(7),
770 mTransformMatrix->get(8));
Chet Haase9420abd2012-03-29 16:28:32 -0700771 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700772 }
773 if (mAlpha < 1 && !mCaching) {
Chet Haase3561d062012-10-23 12:54:51 -0700774 if (!mHasOverlappingRendering) {
775 ALOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
776 } else {
777 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
778 if (mClipChildren) {
779 flags |= SkCanvas::kClipToLayer_SaveFlag;
780 }
781 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
782 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
783 mMultipliedAlpha, flags);
Chet Haasea1cff502012-02-21 13:43:44 -0800784 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700785 }
786 if (mClipChildren) {
787 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
788 (float) mRight - mLeft, (float) mBottom - mTop);
Chet Haasea1cff502012-02-21 13:43:44 -0800789 }
790}
791
Chet Haase1271e2c2012-04-20 09:54:27 -0700792void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t level) {
Chet Haasea1cff502012-02-21 13:43:44 -0800793#if DEBUG_DISPLAY_LIST
794 uint32_t count = (level + 1) * 2;
795 char indent[count + 1];
796 for (uint32_t i = 0; i < count; i++) {
797 indent[i] = ' ';
798 }
799 indent[count] = '\0';
800#endif
Chet Haase1271e2c2012-04-20 09:54:27 -0700801 updateMatrix();
802 if (mLeft != 0 || mTop != 0) {
803 DISPLAY_LIST_LOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
804 renderer.translate(mLeft, mTop);
805 }
806 if (mStaticMatrix) {
807 DISPLAY_LIST_LOGD(
808 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
809 indent, "ConcatMatrix (static)", mStaticMatrix,
810 mStaticMatrix->get(0), mStaticMatrix->get(1),
811 mStaticMatrix->get(2), mStaticMatrix->get(3),
812 mStaticMatrix->get(4), mStaticMatrix->get(5),
813 mStaticMatrix->get(6), mStaticMatrix->get(7),
814 mStaticMatrix->get(8));
815 renderer.concatMatrix(mStaticMatrix);
816 } else if (mAnimationMatrix) {
817 DISPLAY_LIST_LOGD(
818 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
819 indent, "ConcatMatrix (animation)", mAnimationMatrix,
820 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
821 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
822 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
823 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
824 mAnimationMatrix->get(8));
825 renderer.concatMatrix(mAnimationMatrix);
826 }
827 if (mMatrixFlags != 0) {
828 if (mMatrixFlags == TRANSLATION) {
829 DISPLAY_LIST_LOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
830 renderer.translate(mTranslationX, mTranslationY);
831 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700832 DISPLAY_LIST_LOGD(
833 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700834 indent, "ConcatMatrix", mTransformMatrix,
835 mTransformMatrix->get(0), mTransformMatrix->get(1),
836 mTransformMatrix->get(2), mTransformMatrix->get(3),
837 mTransformMatrix->get(4), mTransformMatrix->get(5),
838 mTransformMatrix->get(6), mTransformMatrix->get(7),
839 mTransformMatrix->get(8));
840 renderer.concatMatrix(mTransformMatrix);
Chet Haasea1cff502012-02-21 13:43:44 -0800841 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700842 }
843 if (mAlpha < 1 && !mCaching) {
844 if (!mHasOverlappingRendering) {
845 DISPLAY_LIST_LOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
846 renderer.setAlpha(mAlpha);
847 } else {
848 // TODO: should be able to store the size of a DL at record time and not
849 // have to pass it into this call. In fact, this information might be in the
850 // location/size info that we store with the new native transform data.
851 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
852 if (mClipChildren) {
853 flags |= SkCanvas::kClipToLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800854 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700855 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
856 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
857 mMultipliedAlpha, flags);
858 renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
859 mMultipliedAlpha, flags);
Chet Haasea1cff502012-02-21 13:43:44 -0800860 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700861 }
862 if (mClipChildren) {
863 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
864 (float) mRight - mLeft, (float) mBottom - mTop);
865 renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
866 SkRegion::kIntersect_Op);
Chet Haasea1cff502012-02-21 13:43:44 -0800867 }
868}
869
Chet Haaseed30fd82011-04-22 16:18:45 -0700870/**
871 * Changes to replay(), specifically those involving opcode or parameter changes, should be mimicked
872 * in the output() function, since that function processes the same list of opcodes for the
873 * purposes of logging display list info for a given view.
874 */
Chet Haase1271e2c2012-04-20 09:54:27 -0700875status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level) {
Chet Haase48659092012-05-31 15:21:51 -0700876 status_t drawGlStatus = DrawGlInfo::kStatusDone;
Romain Guyb051e892010-09-28 19:09:36 -0700877 TextContainer text;
878 mReader.rewind();
879
Romain Guyffac7fc2011-01-13 17:21:49 -0800880#if DEBUG_DISPLAY_LIST
881 uint32_t count = (level + 1) * 2;
882 char indent[count + 1];
883 for (uint32_t i = 0; i < count; i++) {
884 indent[i] = ' ';
885 }
886 indent[count] = '\0';
Chet Haasea23eed82012-04-12 15:19:04 -0700887 Rect* clipRect = renderer.getClipRect();
888 DISPLAY_LIST_LOGD("%sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
889 (char*) indent + 2, this, mName.string(), clipRect->left, clipRect->top,
890 clipRect->right, clipRect->bottom);
Romain Guyffac7fc2011-01-13 17:21:49 -0800891#endif
Romain Guyb051e892010-09-28 19:09:36 -0700892
Romain Guy13631f32012-01-30 17:41:55 -0800893 renderer.startMark(mName.string());
Romain Guy8a4ac612012-07-17 17:32:48 -0700894
Chet Haase1271e2c2012-04-20 09:54:27 -0700895 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
896 DISPLAY_LIST_LOGD("%s%s %d %d", indent, "Save",
897 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
898 setViewProperties(renderer, level);
Romain Guy8a4ac612012-07-17 17:32:48 -0700899
900 if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
Chet Haaseb85967b2012-03-26 14:37:51 -0700901 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
902 renderer.restoreToCount(restoreTo);
903 renderer.endMark();
Chet Haase48659092012-05-31 15:21:51 -0700904 return drawGlStatus;
Chet Haaseb85967b2012-03-26 14:37:51 -0700905 }
Romain Guy13631f32012-01-30 17:41:55 -0800906
Chet Haase9c1e23b2011-03-24 10:51:31 -0700907 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
Romain Guyffac7fc2011-01-13 17:21:49 -0800908 int saveCount = renderer.getSaveCount() - 1;
Romain Guy8a4ac612012-07-17 17:32:48 -0700909
Romain Guyb051e892010-09-28 19:09:36 -0700910 while (!mReader.eof()) {
Romain Guy5b3b3522010-10-27 18:57:51 -0700911 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800912 if (op & OP_MAY_BE_SKIPPED_MASK) {
Romain Guy390f8822012-03-13 18:00:10 -0700913 int32_t skip = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800914 if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
915 mReader.skip(skip);
916 DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,
917 OP_NAMES[op & ~OP_MAY_BE_SKIPPED_MASK], skip);
918 continue;
919 } else {
920 op &= ~OP_MAY_BE_SKIPPED_MASK;
Romain Guy33f6beb2012-02-16 19:24:51 -0800921 }
922 }
Chet Haase9c1e23b2011-03-24 10:51:31 -0700923 logBuffer.writeCommand(level, op);
Romain Guyffac7fc2011-01-13 17:21:49 -0800924
Romain Guy8a4ac612012-07-17 17:32:48 -0700925#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
926 Caches::getInstance().eventMark(strlen(OP_NAMES[op]), OP_NAMES[op]);
927#endif
928
Romain Guy5b3b3522010-10-27 18:57:51 -0700929 switch (op) {
Chet Haasedaf98e92011-01-10 14:10:36 -0800930 case DrawGLFunction: {
931 Functor *functor = (Functor *) getInt();
932 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Romain Guy13631f32012-01-30 17:41:55 -0800933 renderer.startMark("GL functor");
Romain Guy65549432012-03-26 16:45:05 -0700934 drawGlStatus |= renderer.callDrawGLFunction(functor, dirty);
Romain Guy13631f32012-01-30 17:41:55 -0800935 renderer.endMark();
Chet Haasedaf98e92011-01-10 14:10:36 -0800936 }
937 break;
Romain Guyb051e892010-09-28 19:09:36 -0700938 case Save: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800939 int32_t rendererNum = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800940 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
941 renderer.save(rendererNum);
Romain Guyb051e892010-09-28 19:09:36 -0700942 }
943 break;
944 case Restore: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800945 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700946 renderer.restore();
947 }
948 break;
949 case RestoreToCount: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800950 int32_t restoreCount = saveCount + getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800951 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
952 renderer.restoreToCount(restoreCount);
Romain Guyb051e892010-09-28 19:09:36 -0700953 }
954 break;
955 case SaveLayer: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800956 float f1 = getFloat();
957 float f2 = getFloat();
958 float f3 = getFloat();
959 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800960 SkPaint* paint = getPaint(renderer);
Romain Guy33f6beb2012-02-16 19:24:51 -0800961 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800962 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800963 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800964 renderer.saveLayer(f1, f2, f3, f4, paint, flags);
Romain Guyb051e892010-09-28 19:09:36 -0700965 }
966 break;
Romain Guy5b3b3522010-10-27 18:57:51 -0700967 case SaveLayerAlpha: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800968 float f1 = getFloat();
969 float f2 = getFloat();
970 float f3 = getFloat();
971 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -0800972 int32_t alpha = getInt();
973 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800974 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800975 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800976 renderer.saveLayerAlpha(f1, f2, f3, f4, alpha, flags);
Romain Guy5b3b3522010-10-27 18:57:51 -0700977 }
978 break;
Romain Guyb051e892010-09-28 19:09:36 -0700979 case Translate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800980 float f1 = getFloat();
981 float f2 = getFloat();
982 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
983 renderer.translate(f1, f2);
Romain Guyb051e892010-09-28 19:09:36 -0700984 }
985 break;
986 case Rotate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800987 float rotation = getFloat();
988 DISPLAY_LIST_LOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
989 renderer.rotate(rotation);
Romain Guyb051e892010-09-28 19:09:36 -0700990 }
991 break;
992 case Scale: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800993 float sx = getFloat();
994 float sy = getFloat();
995 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
996 renderer.scale(sx, sy);
Romain Guyb051e892010-09-28 19:09:36 -0700997 }
998 break;
Romain Guy807daf72011-01-18 11:19:19 -0800999 case Skew: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001000 float sx = getFloat();
1001 float sy = getFloat();
1002 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
1003 renderer.skew(sx, sy);
Romain Guy807daf72011-01-18 11:19:19 -08001004 }
1005 break;
Romain Guyb051e892010-09-28 19:09:36 -07001006 case SetMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001007 SkMatrix* matrix = getMatrix();
1008 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
1009 renderer.setMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -07001010 }
1011 break;
1012 case ConcatMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001013 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -08001014 DISPLAY_LIST_LOGD(
1015 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
1016 (char*) indent, OP_NAMES[op], matrix,
1017 matrix->get(0), matrix->get(1), matrix->get(2),
1018 matrix->get(3), matrix->get(4), matrix->get(5),
1019 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haasedaf98e92011-01-10 14:10:36 -08001020 renderer.concatMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -07001021 }
1022 break;
1023 case ClipRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001024 float f1 = getFloat();
1025 float f2 = getFloat();
1026 float f3 = getFloat();
1027 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001028 int32_t regionOp = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001029 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001030 f1, f2, f3, f4, regionOp);
Chet Haasedaf98e92011-01-10 14:10:36 -08001031 renderer.clipRect(f1, f2, f3, f4, (SkRegion::Op) regionOp);
Romain Guyb051e892010-09-28 19:09:36 -07001032 }
1033 break;
Romain Guy0fe478e2010-11-08 12:08:41 -08001034 case DrawDisplayList: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001035 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -08001036 int32_t flags = getInt();
1037 DISPLAY_LIST_LOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -07001038 displayList, mWidth, mHeight, flags, level + 1);
1039 drawGlStatus |= renderer.drawDisplayList(displayList, dirty, flags, level + 1);
Romain Guy0fe478e2010-11-08 12:08:41 -08001040 }
1041 break;
Romain Guy6c319ca2011-01-11 14:29:25 -08001042 case DrawLayer: {
Chet Haased15ebf22012-09-05 11:40:29 -07001043 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001044 Layer* layer = (Layer*) getInt();
1045 float x = getFloat();
1046 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001047 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001048 if (mCaching && mMultipliedAlpha < 255) {
1049 oldAlpha = layer->getAlpha();
1050 layer->setAlpha(mMultipliedAlpha);
Chet Haasea1cff502012-02-21 13:43:44 -08001051 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001052 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001053 layer, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001054 drawGlStatus |= renderer.drawLayer(layer, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001055 if (oldAlpha >= 0) {
1056 layer->setAlpha(oldAlpha);
1057 }
Romain Guy6c319ca2011-01-11 14:29:25 -08001058 }
1059 break;
Romain Guyb051e892010-09-28 19:09:36 -07001060 case DrawBitmap: {
Chet Haased15ebf22012-09-05 11:40:29 -07001061 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001062 SkBitmap* bitmap = getBitmap();
1063 float x = getFloat();
1064 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001065 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001066 if (mCaching && mMultipliedAlpha < 255) {
1067 oldAlpha = paint->getAlpha();
Chet Haaseb85967b2012-03-26 14:37:51 -07001068 paint->setAlpha(mMultipliedAlpha);
1069 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001070 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001071 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001072 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001073 if (oldAlpha >= 0) {
1074 paint->setAlpha(oldAlpha);
1075 }
Romain Guyb051e892010-09-28 19:09:36 -07001076 }
1077 break;
1078 case DrawBitmapMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001079 SkBitmap* bitmap = getBitmap();
1080 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -08001081 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001082 DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001083 bitmap, matrix, paint);
Chet Haase48659092012-05-31 15:21:51 -07001084 drawGlStatus |= renderer.drawBitmap(bitmap, matrix, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001085 }
1086 break;
1087 case DrawBitmapRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001088 SkBitmap* bitmap = getBitmap();
1089 float f1 = getFloat();
1090 float f2 = getFloat();
1091 float f3 = getFloat();
1092 float f4 = getFloat();
1093 float f5 = getFloat();
1094 float f6 = getFloat();
1095 float f7 = getFloat();
1096 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001097 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001098 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001099 (char*) indent, OP_NAMES[op], bitmap,
1100 f1, f2, f3, f4, f5, f6, f7, f8,paint);
Chet Haase48659092012-05-31 15:21:51 -07001101 drawGlStatus |= renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001102 }
1103 break;
Romain Guye651cc62012-05-14 19:44:40 -07001104 case DrawBitmapData: {
1105 SkBitmap* bitmap = getBitmapData();
1106 float x = getFloat();
1107 float y = getFloat();
1108 SkPaint* paint = getPaint(renderer);
1109 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
1110 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001111 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Romain Guye651cc62012-05-14 19:44:40 -07001112 }
1113 break;
Romain Guy5a7b4662011-01-20 19:09:30 -08001114 case DrawBitmapMesh: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001115 int32_t verticesCount = 0;
Romain Guy5a7b4662011-01-20 19:09:30 -08001116 uint32_t colorsCount = 0;
1117
1118 SkBitmap* bitmap = getBitmap();
1119 uint32_t meshWidth = getInt();
1120 uint32_t meshHeight = getInt();
1121 float* vertices = getFloats(verticesCount);
1122 bool hasColors = getInt();
Romain Guy33f6beb2012-02-16 19:24:51 -08001123 int32_t* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -08001124 SkPaint* paint = getPaint(renderer);
Romain Guy5a7b4662011-01-20 19:09:30 -08001125
Chet Haasedaf98e92011-01-10 14:10:36 -08001126 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001127 drawGlStatus |= renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices,
1128 colors, paint);
Romain Guy5a7b4662011-01-20 19:09:30 -08001129 }
Romain Guya566b7c2011-01-23 16:36:11 -08001130 break;
Romain Guyb051e892010-09-28 19:09:36 -07001131 case DrawPatch: {
1132 int32_t* xDivs = NULL;
1133 int32_t* yDivs = NULL;
Romain Guy4bb94202010-10-12 15:59:26 -07001134 uint32_t* colors = NULL;
Romain Guyb051e892010-09-28 19:09:36 -07001135 uint32_t xDivsCount = 0;
1136 uint32_t yDivsCount = 0;
Romain Guy4bb94202010-10-12 15:59:26 -07001137 int8_t numColors = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001138
1139 SkBitmap* bitmap = getBitmap();
1140
1141 xDivs = getInts(xDivsCount);
1142 yDivs = getInts(yDivsCount);
Romain Guy4bb94202010-10-12 15:59:26 -07001143 colors = getUInts(numColors);
Romain Guyb051e892010-09-28 19:09:36 -07001144
Romain Guy9ff3cb52011-06-28 14:02:11 -07001145 float left = getFloat();
1146 float top = getFloat();
1147 float right = getFloat();
1148 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -07001149
1150 int alpha = getInt();
1151 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Romain Guy9ff3cb52011-06-28 14:02:11 -07001152
Chet Haasedaf98e92011-01-10 14:10:36 -08001153 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001154 drawGlStatus |= renderer.drawPatch(bitmap, xDivs, yDivs, colors,
Romain Guybe6f9dc2012-07-16 12:41:17 -07001155 xDivsCount, yDivsCount, numColors, left, top, right, bottom,
1156 alpha, mode);
Romain Guyb051e892010-09-28 19:09:36 -07001157 }
1158 break;
1159 case DrawColor: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001160 int32_t color = getInt();
1161 int32_t xferMode = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001162 DISPLAY_LIST_LOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haase48659092012-05-31 15:21:51 -07001163 drawGlStatus |= renderer.drawColor(color, (SkXfermode::Mode) xferMode);
Romain Guyb051e892010-09-28 19:09:36 -07001164 }
1165 break;
1166 case DrawRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001167 float f1 = getFloat();
1168 float f2 = getFloat();
1169 float f3 = getFloat();
1170 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001171 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001172 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001173 f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001174 drawGlStatus |= renderer.drawRect(f1, f2, f3, f4, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001175 }
1176 break;
Romain Guy01d58e42011-01-19 21:54:02 -08001177 case DrawRoundRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001178 float f1 = getFloat();
1179 float f2 = getFloat();
1180 float f3 = getFloat();
1181 float f4 = getFloat();
1182 float f5 = getFloat();
1183 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001184 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001185 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001186 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haase48659092012-05-31 15:21:51 -07001187 drawGlStatus |= renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001188 }
1189 break;
1190 case DrawCircle: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001191 float f1 = getFloat();
1192 float f2 = getFloat();
1193 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001194 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001195 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001196 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haase48659092012-05-31 15:21:51 -07001197 drawGlStatus |= renderer.drawCircle(f1, f2, f3, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001198 }
1199 break;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001200 case DrawOval: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001201 float f1 = getFloat();
1202 float f2 = getFloat();
1203 float f3 = getFloat();
1204 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001205 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001206 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001207 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001208 drawGlStatus |= renderer.drawOval(f1, f2, f3, f4, paint);
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001209 }
1210 break;
Romain Guy8b2f5262011-01-23 16:15:02 -08001211 case DrawArc: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001212 float f1 = getFloat();
1213 float f2 = getFloat();
1214 float f3 = getFloat();
1215 float f4 = getFloat();
1216 float f5 = getFloat();
1217 float f6 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001218 int32_t i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001219 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001220 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001221 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haase48659092012-05-31 15:21:51 -07001222 drawGlStatus |= renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
Romain Guy8b2f5262011-01-23 16:15:02 -08001223 }
1224 break;
Romain Guyb051e892010-09-28 19:09:36 -07001225 case DrawPath: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001226 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -08001227 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001228 DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haase48659092012-05-31 15:21:51 -07001229 drawGlStatus |= renderer.drawPath(path, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001230 }
1231 break;
1232 case DrawLines: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001233 int32_t count = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001234 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001235 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001236 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001237 drawGlStatus |= renderer.drawLines(points, count, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001238 }
1239 break;
Romain Guyed6fcb02011-03-21 13:11:28 -07001240 case DrawPoints: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001241 int32_t count = 0;
Romain Guyed6fcb02011-03-21 13:11:28 -07001242 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001243 SkPaint* paint = getPaint(renderer);
Romain Guyed6fcb02011-03-21 13:11:28 -07001244 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001245 drawGlStatus |= renderer.drawPoints(points, count, paint);
Romain Guyed6fcb02011-03-21 13:11:28 -07001246 }
1247 break;
Romain Guy325740f2012-02-24 16:48:34 -08001248 case DrawTextOnPath: {
1249 getText(&text);
1250 int32_t count = getInt();
1251 SkPath* path = getPath();
1252 float hOffset = getFloat();
1253 float vOffset = getFloat();
1254 SkPaint* paint = getPaint(renderer);
1255 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
1256 text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001257 drawGlStatus |= renderer.drawTextOnPath(text.text(), text.length(), count, path,
Romain Guy325740f2012-02-24 16:48:34 -08001258 hOffset, vOffset, paint);
1259 }
1260 break;
Romain Guyeb9a5362012-01-17 17:39:26 -08001261 case DrawPosText: {
1262 getText(&text);
Romain Guy33f6beb2012-02-16 19:24:51 -08001263 int32_t count = getInt();
1264 int32_t positionsCount = 0;
Romain Guyeb9a5362012-01-17 17:39:26 -08001265 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -08001266 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -08001267 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent,
1268 OP_NAMES[op], text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001269 drawGlStatus |= renderer.drawPosText(text.text(), text.length(), count,
1270 positions, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -08001271 }
1272 break;
Romain Guyc2525952012-07-27 16:41:22 -07001273 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -07001274 getText(&text);
1275 int32_t count = getInt();
1276 float x = getFloat();
1277 float y = getFloat();
1278 int32_t positionsCount = 0;
1279 float* positions = getFloats(positionsCount);
1280 SkPaint* paint = getPaint(renderer);
1281 float length = getFloat();
1282 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent,
1283 OP_NAMES[op], text.text(), text.length(), count, x, y, paint, length);
Romain Guyc2525952012-07-27 16:41:22 -07001284 drawGlStatus |= renderer.drawText(text.text(), text.length(), count,
Raph Levien996e57c2012-07-23 15:22:52 -07001285 x, y, positions, paint, length);
1286 }
1287 break;
Romain Guy672433d2013-01-04 19:05:13 -08001288 case DrawRects: {
1289 int32_t count = 0;
1290 float* rects = getFloats(count);
1291 SkPaint* paint = getPaint(renderer);
1292 DISPLAY_LIST_LOGD("%s%s %d, %p", (char*) indent, OP_NAMES[op], count, paint);
1293 drawGlStatus |= renderer.drawRects(rects, count / 4, paint);
1294 }
1295 break;
Romain Guyb051e892010-09-28 19:09:36 -07001296 case ResetShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001297 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001298 renderer.resetShader();
1299 }
1300 break;
1301 case SetupShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001302 SkiaShader* shader = getShader();
1303 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
1304 renderer.setupShader(shader);
Romain Guyb051e892010-09-28 19:09:36 -07001305 }
1306 break;
1307 case ResetColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001308 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001309 renderer.resetColorFilter();
1310 }
1311 break;
1312 case SetupColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001313 SkiaColorFilter *colorFilter = getColorFilter();
1314 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
1315 renderer.setupColorFilter(colorFilter);
Romain Guyb051e892010-09-28 19:09:36 -07001316 }
1317 break;
1318 case ResetShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001319 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001320 renderer.resetShadow();
1321 }
1322 break;
1323 case SetupShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001324 float radius = getFloat();
1325 float dx = getFloat();
1326 float dy = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001327 int32_t color = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001328 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001329 radius, dx, dy, color);
Chet Haasedaf98e92011-01-10 14:10:36 -08001330 renderer.setupShadow(radius, dx, dy, color);
Romain Guyb051e892010-09-28 19:09:36 -07001331 }
1332 break;
Romain Guy5ff9df62012-01-23 17:09:05 -08001333 case ResetPaintFilter: {
1334 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
1335 renderer.resetPaintFilter();
1336 }
1337 break;
1338 case SetupPaintFilter: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001339 int32_t clearBits = getInt();
1340 int32_t setBits = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001341 DISPLAY_LIST_LOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op],
1342 clearBits, setBits);
1343 renderer.setupPaintFilter(clearBits, setBits);
1344 }
1345 break;
Chet Haasedaf98e92011-01-10 14:10:36 -08001346 default:
1347 DISPLAY_LIST_LOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -08001348 (char*) indent, OP_NAMES[op]);
Chet Haasedaf98e92011-01-10 14:10:36 -08001349 break;
Romain Guyb051e892010-09-28 19:09:36 -07001350 }
1351 }
Romain Guyffac7fc2011-01-13 17:21:49 -08001352
Chet Haase1271e2c2012-04-20 09:54:27 -07001353 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
1354 renderer.restoreToCount(restoreTo);
Romain Guy13631f32012-01-30 17:41:55 -08001355 renderer.endMark();
1356
Chet Haasea1cff502012-02-21 13:43:44 -08001357 DISPLAY_LIST_LOGD("%sDone (%p, %s), returning %d", (char*) indent + 2, this, mName.string(),
Romain Guy65549432012-03-26 16:45:05 -07001358 drawGlStatus);
1359 return drawGlStatus;
Romain Guyb051e892010-09-28 19:09:36 -07001360}
1361
1362///////////////////////////////////////////////////////////////////////////////
Romain Guy4aa90572010-09-26 18:40:37 -07001363// Base structure
1364///////////////////////////////////////////////////////////////////////////////
1365
Romain Guy58ecc202012-09-07 11:58:36 -07001366DisplayListRenderer::DisplayListRenderer():
1367 mCaches(Caches::getInstance()), mWriter(MIN_WRITER_SIZE),
Romain Guy54c1a642012-09-27 17:55:46 -07001368 mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false),
1369 mHasDrawOps(false), mFunctorCount(0) {
Romain Guy4aa90572010-09-26 18:40:37 -07001370}
1371
1372DisplayListRenderer::~DisplayListRenderer() {
1373 reset();
1374}
1375
1376void DisplayListRenderer::reset() {
Romain Guy4aa90572010-09-26 18:40:37 -07001377 mWriter.reset();
Chet Haase5c13d892010-10-08 08:37:55 -07001378
Romain Guy58ecc202012-09-07 11:58:36 -07001379 mCaches.resourceCache.lock();
1380
Chet Haase5c13d892010-10-08 08:37:55 -07001381 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001382 mCaches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5c13d892010-10-08 08:37:55 -07001383 }
Chet Haased98aa2d2010-10-25 15:47:32 -07001384
Romain Guy49c5fc02012-05-15 11:10:01 -07001385 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001386 mCaches.resourceCache.decrementRefcountLocked(mOwnedBitmapResources.itemAt(i));
Romain Guy49c5fc02012-05-15 11:10:01 -07001387 }
Romain Guy49c5fc02012-05-15 11:10:01 -07001388
Romain Guyd586ad92011-06-22 16:14:36 -07001389 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001390 mCaches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -07001391 }
Romain Guyd586ad92011-06-22 16:14:36 -07001392
Romain Guy43ccf462011-01-14 18:51:01 -08001393 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001394 mCaches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
Romain Guy43ccf462011-01-14 18:51:01 -08001395 }
Romain Guy43ccf462011-01-14 18:51:01 -08001396
Chet Haased34dd712012-05-02 18:50:34 -07001397 for (size_t i = 0; i < mSourcePaths.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001398 mCaches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
Chet Haased34dd712012-05-02 18:50:34 -07001399 }
Romain Guy58ecc202012-09-07 11:58:36 -07001400
Chet Haase603f6de2012-09-14 15:31:25 -07001401 for (size_t i = 0; i < mLayers.size(); i++) {
1402 mCaches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
1403 }
1404
Romain Guy58ecc202012-09-07 11:58:36 -07001405 mCaches.resourceCache.unlock();
1406
1407 mBitmapResources.clear();
1408 mOwnedBitmapResources.clear();
1409 mFilterResources.clear();
Chet Haased34dd712012-05-02 18:50:34 -07001410 mSourcePaths.clear();
1411
Romain Guy58ecc202012-09-07 11:58:36 -07001412 mShaders.clear();
1413 mShaderMap.clear();
1414
Romain Guy43ccf462011-01-14 18:51:01 -08001415 mPaints.clear();
1416 mPaintMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001417
Romain Guy2fc941e2011-02-03 15:06:05 -08001418 mPaths.clear();
1419 mPathMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001420
Chet Haased98aa2d2010-10-25 15:47:32 -07001421 mMatrices.clear();
Romain Guy04c9d8c2011-08-25 14:01:48 -07001422
Chet Haase603f6de2012-09-14 15:31:25 -07001423 mLayers.clear();
1424
Romain Guy04c9d8c2011-08-25 14:01:48 -07001425 mHasDrawOps = false;
Romain Guy54c1a642012-09-27 17:55:46 -07001426 mFunctorCount = 0;
Romain Guy4aa90572010-09-26 18:40:37 -07001427}
1428
1429///////////////////////////////////////////////////////////////////////////////
1430// Operations
1431///////////////////////////////////////////////////////////////////////////////
1432
Jeff Brown162a0212011-07-21 17:02:54 -07001433DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
1434 if (!displayList) {
1435 displayList = new DisplayList(*this);
Chet Haase5977baa2011-01-05 18:01:22 -08001436 } else {
Jeff Brown162a0212011-07-21 17:02:54 -07001437 displayList->initFromDisplayListRenderer(*this, true);
Chet Haase5977baa2011-01-05 18:01:22 -08001438 }
Romain Guy04c9d8c2011-08-25 14:01:48 -07001439 displayList->setRenderable(mHasDrawOps);
Jeff Brown162a0212011-07-21 17:02:54 -07001440 return displayList;
Chet Haase5977baa2011-01-05 18:01:22 -08001441}
1442
Romain Guy49c5fc02012-05-15 11:10:01 -07001443bool DisplayListRenderer::isDeferred() {
1444 return true;
1445}
1446
Romain Guyb051e892010-09-28 19:09:36 -07001447void DisplayListRenderer::setViewport(int width, int height) {
1448 mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
1449
1450 mWidth = width;
1451 mHeight = height;
1452}
1453
Romain Guy7c25aab2012-10-18 15:05:02 -07001454status_t DisplayListRenderer::prepareDirty(float left, float top,
Romain Guy7d7b5492011-01-24 16:33:45 -08001455 float right, float bottom, bool opaque) {
Romain Guyb051e892010-09-28 19:09:36 -07001456 mSnapshot = new Snapshot(mFirstSnapshot,
1457 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
1458 mSaveCount = 1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001459
Romain Guyb051e892010-09-28 19:09:36 -07001460 mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
Romain Guy45e4c3d2012-09-11 17:17:07 -07001461 mDirtyClip = opaque;
1462
Romain Guy27454a42011-01-23 12:01:41 -08001463 mRestoreSaveCount = -1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001464
Chet Haase44b2fe32012-06-06 19:03:58 -07001465 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Romain Guy27454a42011-01-23 12:01:41 -08001466}
1467
1468void DisplayListRenderer::finish() {
1469 insertRestoreToCount();
Romain Guy33f6beb2012-02-16 19:24:51 -08001470 insertTranlate();
Romain Guyb051e892010-09-28 19:09:36 -07001471}
1472
Chet Haasedaf98e92011-01-10 14:10:36 -08001473void DisplayListRenderer::interrupt() {
Chet Haasedaf98e92011-01-10 14:10:36 -08001474}
Romain Guy2b1847e2011-01-26 13:43:01 -08001475
Chet Haasedaf98e92011-01-10 14:10:36 -08001476void DisplayListRenderer::resume() {
Romain Guy4aa90572010-09-26 18:40:37 -07001477}
1478
Romain Guy65549432012-03-26 16:45:05 -07001479status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
Romain Guycabfcc12011-03-07 18:06:46 -08001480 // Ignore dirty during recording, it matters only when we replay
Chet Haasedaf98e92011-01-10 14:10:36 -08001481 addOp(DisplayList::DrawGLFunction);
1482 addInt((int) functor);
Romain Guy54c1a642012-09-27 17:55:46 -07001483 mFunctorCount++;
Romain Guy65549432012-03-26 16:45:05 -07001484 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Chet Haasedaf98e92011-01-10 14:10:36 -08001485}
1486
Romain Guy4aa90572010-09-26 18:40:37 -07001487int DisplayListRenderer::save(int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001488 addOp(DisplayList::Save);
Romain Guy4aa90572010-09-26 18:40:37 -07001489 addInt(flags);
1490 return OpenGLRenderer::save(flags);
1491}
1492
1493void DisplayListRenderer::restore() {
Romain Guy04c9d8c2011-08-25 14:01:48 -07001494 if (mRestoreSaveCount < 0) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001495 restoreToCount(getSaveCount() - 1);
1496 return;
Romain Guy04c9d8c2011-08-25 14:01:48 -07001497 }
Romain Guy33f6beb2012-02-16 19:24:51 -08001498
1499 mRestoreSaveCount--;
1500 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001501 OpenGLRenderer::restore();
1502}
1503
1504void DisplayListRenderer::restoreToCount(int saveCount) {
Romain Guy27454a42011-01-23 12:01:41 -08001505 mRestoreSaveCount = saveCount;
Romain Guy33f6beb2012-02-16 19:24:51 -08001506 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001507 OpenGLRenderer::restoreToCount(saveCount);
1508}
1509
1510int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001511 SkPaint* p, int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001512 addOp(DisplayList::SaveLayer);
Romain Guy4aa90572010-09-26 18:40:37 -07001513 addBounds(left, top, right, bottom);
1514 addPaint(p);
1515 addInt(flags);
Romain Guyb051e892010-09-28 19:09:36 -07001516 return OpenGLRenderer::save(flags);
Romain Guy4aa90572010-09-26 18:40:37 -07001517}
1518
Romain Guy5b3b3522010-10-27 18:57:51 -07001519int DisplayListRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
1520 int alpha, int flags) {
1521 addOp(DisplayList::SaveLayerAlpha);
1522 addBounds(left, top, right, bottom);
1523 addInt(alpha);
1524 addInt(flags);
1525 return OpenGLRenderer::save(flags);
1526}
1527
Romain Guy4aa90572010-09-26 18:40:37 -07001528void DisplayListRenderer::translate(float dx, float dy) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001529 mHasTranslate = true;
1530 mTranslateX += dx;
1531 mTranslateY += dy;
1532 insertRestoreToCount();
Romain Guy4aa90572010-09-26 18:40:37 -07001533 OpenGLRenderer::translate(dx, dy);
1534}
1535
1536void DisplayListRenderer::rotate(float degrees) {
Romain Guyb051e892010-09-28 19:09:36 -07001537 addOp(DisplayList::Rotate);
Romain Guy4aa90572010-09-26 18:40:37 -07001538 addFloat(degrees);
1539 OpenGLRenderer::rotate(degrees);
1540}
1541
1542void DisplayListRenderer::scale(float sx, float sy) {
Romain Guyb051e892010-09-28 19:09:36 -07001543 addOp(DisplayList::Scale);
Romain Guy4aa90572010-09-26 18:40:37 -07001544 addPoint(sx, sy);
1545 OpenGLRenderer::scale(sx, sy);
1546}
1547
Romain Guy807daf72011-01-18 11:19:19 -08001548void DisplayListRenderer::skew(float sx, float sy) {
1549 addOp(DisplayList::Skew);
1550 addPoint(sx, sy);
1551 OpenGLRenderer::skew(sx, sy);
1552}
1553
Romain Guy4aa90572010-09-26 18:40:37 -07001554void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001555 addOp(DisplayList::SetMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001556 addMatrix(matrix);
1557 OpenGLRenderer::setMatrix(matrix);
1558}
1559
1560void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001561 addOp(DisplayList::ConcatMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001562 addMatrix(matrix);
1563 OpenGLRenderer::concatMatrix(matrix);
1564}
1565
1566bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
1567 SkRegion::Op op) {
Romain Guyb051e892010-09-28 19:09:36 -07001568 addOp(DisplayList::ClipRect);
Romain Guy4aa90572010-09-26 18:40:37 -07001569 addBounds(left, top, right, bottom);
1570 addInt(op);
1571 return OpenGLRenderer::clipRect(left, top, right, bottom, op);
1572}
1573
Romain Guy65549432012-03-26 16:45:05 -07001574status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
Chet Haase1271e2c2012-04-20 09:54:27 -07001575 Rect& dirty, int32_t flags, uint32_t level) {
Romain Guycabfcc12011-03-07 18:06:46 -08001576 // dirty is an out parameter and should not be recorded,
1577 // it matters only when replaying the display list
Chet Haaseb85967b2012-03-26 14:37:51 -07001578
1579 addOp(DisplayList::DrawDisplayList);
Romain Guy0fe478e2010-11-08 12:08:41 -08001580 addDisplayList(displayList);
Romain Guy33f6beb2012-02-16 19:24:51 -08001581 addInt(flags);
Romain Guy65549432012-03-26 16:45:05 -07001582 return DrawGlInfo::kStatusDone;
Romain Guy0fe478e2010-11-08 12:08:41 -08001583}
1584
Chet Haase48659092012-05-31 15:21:51 -07001585status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
Romain Guy6c319ca2011-01-11 14:29:25 -08001586 addOp(DisplayList::DrawLayer);
Chet Haase603f6de2012-09-14 15:31:25 -07001587 addLayer(layer);
Romain Guyada830f2011-01-13 12:13:20 -08001588 addPoint(x, y);
Romain Guy6c319ca2011-01-11 14:29:25 -08001589 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001590 return DrawGlInfo::kStatusDone;
Romain Guy6c319ca2011-01-11 14:29:25 -08001591}
1592
Chet Haase48659092012-05-31 15:21:51 -07001593status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
Romain Guya3dc55f2012-09-28 13:55:44 -07001594 const bool reject = quickRejectNoScissor(left, top,
1595 left + bitmap->width(), top + bitmap->height());
Romain Guy33f6beb2012-02-16 19:24:51 -08001596 uint32_t* location = addOp(DisplayList::DrawBitmap, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001597 addBitmap(bitmap);
1598 addPoint(left, top);
1599 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001600 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001601 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001602}
1603
Chet Haase48659092012-05-31 15:21:51 -07001604status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001605 Rect r(0.0f, 0.0f, bitmap->width(), bitmap->height());
1606 const mat4 transform(*matrix);
1607 transform.mapRect(r);
1608
Romain Guya3dc55f2012-09-28 13:55:44 -07001609 const bool reject = quickRejectNoScissor(r.left, r.top, r.right, r.bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001610 uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001611 addBitmap(bitmap);
1612 addMatrix(matrix);
1613 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001614 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001615 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001616}
1617
Chet Haase48659092012-05-31 15:21:51 -07001618status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
Romain Guy4aa90572010-09-26 18:40:37 -07001619 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -07001620 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guya3dc55f2012-09-28 13:55:44 -07001621 const bool reject = quickRejectNoScissor(dstLeft, dstTop, dstRight, dstBottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001622 uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001623 addBitmap(bitmap);
1624 addBounds(srcLeft, srcTop, srcRight, srcBottom);
1625 addBounds(dstLeft, dstTop, dstRight, dstBottom);
1626 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001627 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001628 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001629}
1630
Chet Haase48659092012-05-31 15:21:51 -07001631status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
1632 SkPaint* paint) {
Romain Guya3dc55f2012-09-28 13:55:44 -07001633 const bool reject = quickRejectNoScissor(left, top,
1634 left + bitmap->width(), top + bitmap->height());
Romain Guye651cc62012-05-14 19:44:40 -07001635 uint32_t* location = addOp(DisplayList::DrawBitmapData, reject);
1636 addBitmapData(bitmap);
1637 addPoint(left, top);
1638 addPaint(paint);
1639 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001640 return DrawGlInfo::kStatusDone;
Romain Guye651cc62012-05-14 19:44:40 -07001641}
1642
Chet Haase48659092012-05-31 15:21:51 -07001643status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
Romain Guy5a7b4662011-01-20 19:09:30 -08001644 float* vertices, int* colors, SkPaint* paint) {
1645 addOp(DisplayList::DrawBitmapMesh);
1646 addBitmap(bitmap);
1647 addInt(meshWidth);
1648 addInt(meshHeight);
1649 addFloats(vertices, (meshWidth + 1) * (meshHeight + 1) * 2);
1650 if (colors) {
1651 addInt(1);
1652 addInts(colors, (meshWidth + 1) * (meshHeight + 1));
1653 } else {
1654 addInt(0);
1655 }
1656 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001657 return DrawGlInfo::kStatusDone;
Romain Guy5a7b4662011-01-20 19:09:30 -08001658}
1659
Chet Haase48659092012-05-31 15:21:51 -07001660status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs,
1661 const int32_t* yDivs, const uint32_t* colors, uint32_t width, uint32_t height,
1662 int8_t numColors, float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guybe6f9dc2012-07-16 12:41:17 -07001663 int alpha;
1664 SkXfermode::Mode mode;
1665 OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
1666
Romain Guya3dc55f2012-09-28 13:55:44 -07001667 const bool reject = quickRejectNoScissor(left, top, right, bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001668 uint32_t* location = addOp(DisplayList::DrawPatch, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001669 addBitmap(bitmap);
1670 addInts(xDivs, width);
1671 addInts(yDivs, height);
Romain Guy4bb94202010-10-12 15:59:26 -07001672 addUInts(colors, numColors);
Romain Guy4aa90572010-09-26 18:40:37 -07001673 addBounds(left, top, right, bottom);
Romain Guybe6f9dc2012-07-16 12:41:17 -07001674 addInt(alpha);
1675 addInt(mode);
Romain Guy33f6beb2012-02-16 19:24:51 -08001676 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001677 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001678}
1679
Chet Haase48659092012-05-31 15:21:51 -07001680status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
Romain Guyb051e892010-09-28 19:09:36 -07001681 addOp(DisplayList::DrawColor);
Romain Guy4aa90572010-09-26 18:40:37 -07001682 addInt(color);
1683 addInt(mode);
Chet Haase48659092012-05-31 15:21:51 -07001684 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001685}
1686
Chet Haase48659092012-05-31 15:21:51 -07001687status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001688 SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001689 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
Romain Guya3dc55f2012-09-28 13:55:44 -07001690 quickRejectNoScissor(left, top, right, bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001691 uint32_t* location = addOp(DisplayList::DrawRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001692 addBounds(left, top, right, bottom);
1693 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001694 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001695 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001696}
1697
Chet Haase48659092012-05-31 15:21:51 -07001698status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
Chet Haasea1cff502012-02-21 13:43:44 -08001699 float rx, float ry, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001700 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
Romain Guya3dc55f2012-09-28 13:55:44 -07001701 quickRejectNoScissor(left, top, right, bottom);
Romain Guy33f6beb2012-02-16 19:24:51 -08001702 uint32_t* location = addOp(DisplayList::DrawRoundRect, reject);
Romain Guy01d58e42011-01-19 21:54:02 -08001703 addBounds(left, top, right, bottom);
1704 addPoint(rx, ry);
1705 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001706 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001707 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001708}
1709
Chet Haase48659092012-05-31 15:21:51 -07001710status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
Romain Guy01d58e42011-01-19 21:54:02 -08001711 addOp(DisplayList::DrawCircle);
1712 addPoint(x, y);
1713 addFloat(radius);
1714 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001715 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001716}
1717
Chet Haase48659092012-05-31 15:21:51 -07001718status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001719 SkPaint* paint) {
1720 addOp(DisplayList::DrawOval);
1721 addBounds(left, top, right, bottom);
1722 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001723 return DrawGlInfo::kStatusDone;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001724}
1725
Chet Haase48659092012-05-31 15:21:51 -07001726status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
Romain Guy8b2f5262011-01-23 16:15:02 -08001727 float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
Romain Guy82d41a52011-01-24 21:53:42 -08001728 addOp(DisplayList::DrawArc);
Romain Guy8b2f5262011-01-23 16:15:02 -08001729 addBounds(left, top, right, bottom);
1730 addPoint(startAngle, sweepAngle);
1731 addInt(useCenter ? 1 : 0);
1732 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001733 return DrawGlInfo::kStatusDone;
Romain Guy8b2f5262011-01-23 16:15:02 -08001734}
1735
Chet Haase48659092012-05-31 15:21:51 -07001736status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001737 float left, top, offset;
1738 uint32_t width, height;
1739 computePathBounds(path, paint, left, top, offset, width, height);
1740
Romain Guy95c21d02012-07-17 17:46:03 -07001741 left -= offset;
1742 top -= offset;
1743
Romain Guya3dc55f2012-09-28 13:55:44 -07001744 const bool reject = quickRejectNoScissor(left, top, left + width, top + height);
Romain Guy33f6beb2012-02-16 19:24:51 -08001745 uint32_t* location = addOp(DisplayList::DrawPath, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001746 addPath(path);
1747 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001748 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001749 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001750}
1751
Chet Haase48659092012-05-31 15:21:51 -07001752status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -07001753 addOp(DisplayList::DrawLines);
Romain Guy4aa90572010-09-26 18:40:37 -07001754 addFloats(points, count);
1755 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001756 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001757}
1758
Chet Haase48659092012-05-31 15:21:51 -07001759status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
Romain Guyed6fcb02011-03-21 13:11:28 -07001760 addOp(DisplayList::DrawPoints);
1761 addFloats(points, count);
1762 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001763 return DrawGlInfo::kStatusDone;
Romain Guyed6fcb02011-03-21 13:11:28 -07001764}
1765
Chet Haase48659092012-05-31 15:21:51 -07001766status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
Romain Guy325740f2012-02-24 16:48:34 -08001767 SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001768 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001769 addOp(DisplayList::DrawTextOnPath);
1770 addText(text, bytesCount);
1771 addInt(count);
1772 addPath(path);
1773 addFloat(hOffset);
1774 addFloat(vOffset);
1775 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001776 SkPaint* addedPaint = addPaint(paint);
1777 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1778 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001779 return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001780}
1781
Chet Haase48659092012-05-31 15:21:51 -07001782status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
Romain Guyeb9a5362012-01-17 17:39:26 -08001783 const float* positions, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001784 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001785 addOp(DisplayList::DrawPosText);
1786 addText(text, bytesCount);
1787 addInt(count);
1788 addFloats(positions, count * 2);
1789 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001790 SkPaint* addedPaint = addPaint(paint);
1791 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1792 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001793 return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001794}
1795
Romain Guyc2525952012-07-27 16:41:22 -07001796status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
Raph Levien996e57c2012-07-23 15:22:52 -07001797 float x, float y, const float* positions, SkPaint* paint, float length) {
1798 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
1799
1800 // TODO: We should probably make a copy of the paint instead of modifying
1801 // it; modifying the paint will change its generationID the first
1802 // time, which might impact caches. More investigation needed to
1803 // see if it matters.
1804 // If we make a copy, then drawTextDecorations() should *not* make
1805 // its own copy as it does right now.
1806 // Beware: this needs Glyph encoding (already done on the Paint constructor)
1807 paint->setAntiAlias(true);
1808 if (length < 0.0f) length = paint->measureText(text, bytesCount);
1809
1810 bool reject = false;
1811 if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) {
1812 SkPaint::FontMetrics metrics;
1813 paint->getFontMetrics(&metrics, 0.0f);
Romain Guya3dc55f2012-09-28 13:55:44 -07001814 reject = quickRejectNoScissor(x, y + metrics.fTop, x + length, y + metrics.fBottom);
Raph Levien996e57c2012-07-23 15:22:52 -07001815 }
1816
Romain Guyc2525952012-07-27 16:41:22 -07001817 uint32_t* location = addOp(DisplayList::DrawText, reject);
Raph Levien996e57c2012-07-23 15:22:52 -07001818 addText(text, bytesCount);
1819 addInt(count);
1820 addFloat(x);
1821 addFloat(y);
1822 addFloats(positions, count * 2);
Chet Haasee816bae2012-08-09 13:39:02 -07001823 SkPaint* addedPaint = addPaint(paint);
1824 if (!reject) {
1825 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1826 fontRenderer.precache(addedPaint, text, count);
1827 }
Raph Levien996e57c2012-07-23 15:22:52 -07001828 addFloat(length);
1829 addSkip(location);
1830 return DrawGlInfo::kStatusDone;
1831}
1832
Romain Guy672433d2013-01-04 19:05:13 -08001833status_t DisplayListRenderer::drawRects(const float* rects, int count, SkPaint* paint) {
1834 if (count <= 0) return DrawGlInfo::kStatusDone;
1835
1836 addOp(DisplayList::DrawRects);
1837 addFloats(rects, count * 4);
1838 addPaint(paint);
1839 return DrawGlInfo::kStatusDone;
1840}
1841
Romain Guy4aa90572010-09-26 18:40:37 -07001842void DisplayListRenderer::resetShader() {
Romain Guyb051e892010-09-28 19:09:36 -07001843 addOp(DisplayList::ResetShader);
Romain Guy4aa90572010-09-26 18:40:37 -07001844}
1845
1846void DisplayListRenderer::setupShader(SkiaShader* shader) {
Chet Haase5c13d892010-10-08 08:37:55 -07001847 addOp(DisplayList::SetupShader);
1848 addShader(shader);
Romain Guy4aa90572010-09-26 18:40:37 -07001849}
1850
1851void DisplayListRenderer::resetColorFilter() {
Romain Guyb051e892010-09-28 19:09:36 -07001852 addOp(DisplayList::ResetColorFilter);
Romain Guy4aa90572010-09-26 18:40:37 -07001853}
1854
1855void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
Chet Haasead93c2b2010-10-22 16:17:12 -07001856 addOp(DisplayList::SetupColorFilter);
1857 addColorFilter(filter);
Romain Guy4aa90572010-09-26 18:40:37 -07001858}
1859
1860void DisplayListRenderer::resetShadow() {
Romain Guyb051e892010-09-28 19:09:36 -07001861 addOp(DisplayList::ResetShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001862}
1863
1864void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
Romain Guyb051e892010-09-28 19:09:36 -07001865 addOp(DisplayList::SetupShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001866 addFloat(radius);
1867 addPoint(dx, dy);
1868 addInt(color);
Romain Guy4aa90572010-09-26 18:40:37 -07001869}
1870
Romain Guy5ff9df62012-01-23 17:09:05 -08001871void DisplayListRenderer::resetPaintFilter() {
1872 addOp(DisplayList::ResetPaintFilter);
1873}
1874
1875void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
1876 addOp(DisplayList::SetupPaintFilter);
1877 addInt(clearBits);
1878 addInt(setBits);
1879}
1880
Romain Guy4aa90572010-09-26 18:40:37 -07001881}; // namespace uirenderer
1882}; // namespace android