blob: 6aff8d4aa776c8a19e1c3d956c74fe9f95d2241b [file] [log] [blame]
Romain Guy4aa90572010-09-26 18:40:37 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "OpenGLRenderer"
18
Romain Guyd5a85fb2012-03-13 11:18:20 -070019#include <SkCamera.h>
Chet Haase9c1e23b2011-03-24 10:51:31 -070020
Romain Guy65549432012-03-26 16:45:05 -070021#include <private/hwui/DrawGlInfo.h>
22
Chet Haase9c1e23b2011-03-24 10:51:31 -070023#include "DisplayListLogBuffer.h"
Romain Guy4aa90572010-09-26 18:40:37 -070024#include "DisplayListRenderer.h"
Chet Haase9c1e23b2011-03-24 10:51:31 -070025#include "Caches.h"
Romain Guy13631f32012-01-30 17:41:55 -080026
Romain Guy4aa90572010-09-26 18:40:37 -070027namespace android {
28namespace uirenderer {
29
30///////////////////////////////////////////////////////////////////////////////
Romain Guyb051e892010-09-28 19:09:36 -070031// Display list
32///////////////////////////////////////////////////////////////////////////////
33
Romain Guyffac7fc2011-01-13 17:21:49 -080034const char* DisplayList::OP_NAMES[] = {
Romain Guyffac7fc2011-01-13 17:21:49 -080035 "Save",
36 "Restore",
37 "RestoreToCount",
38 "SaveLayer",
39 "SaveLayerAlpha",
40 "Translate",
41 "Rotate",
42 "Scale",
Romain Guy4cf6e2f2011-01-23 11:35:13 -080043 "Skew",
Romain Guyffac7fc2011-01-13 17:21:49 -080044 "SetMatrix",
45 "ConcatMatrix",
46 "ClipRect",
47 "DrawDisplayList",
48 "DrawLayer",
49 "DrawBitmap",
50 "DrawBitmapMatrix",
51 "DrawBitmapRect",
Romain Guye651cc62012-05-14 19:44:40 -070052 "DrawBitmapData",
Romain Guy5a7b4662011-01-20 19:09:30 -080053 "DrawBitmapMesh",
Romain Guyffac7fc2011-01-13 17:21:49 -080054 "DrawPatch",
55 "DrawColor",
56 "DrawRect",
Romain Guy01d58e42011-01-19 21:54:02 -080057 "DrawRoundRect",
58 "DrawCircle",
Romain Guyc1cd9ba32011-01-23 14:18:41 -080059 "DrawOval",
Romain Guy8b2f5262011-01-23 16:15:02 -080060 "DrawArc",
Romain Guyffac7fc2011-01-13 17:21:49 -080061 "DrawPath",
62 "DrawLines",
Romain Guyed6fcb02011-03-21 13:11:28 -070063 "DrawPoints",
Romain Guy325740f2012-02-24 16:48:34 -080064 "DrawTextOnPath",
Romain Guyeb9a5362012-01-17 17:39:26 -080065 "DrawPosText",
Romain Guyc2525952012-07-27 16:41:22 -070066 "DrawText",
Romain Guyffac7fc2011-01-13 17:21:49 -080067 "ResetShader",
68 "SetupShader",
69 "ResetColorFilter",
70 "SetupColorFilter",
71 "ResetShadow",
Chet Haasedaf98e92011-01-10 14:10:36 -080072 "SetupShadow",
Romain Guy5ff9df62012-01-23 17:09:05 -080073 "ResetPaintFilter",
74 "SetupPaintFilter",
Chet Haasedaf98e92011-01-10 14:10:36 -080075 "DrawGLFunction"
Romain Guyffac7fc2011-01-13 17:21:49 -080076};
77
Chet Haase9c1e23b2011-03-24 10:51:31 -070078void DisplayList::outputLogBuffer(int fd) {
79 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
80 if (logBuffer.isEmpty()) {
81 return;
82 }
Romain Guy65b345f2011-07-27 18:51:50 -070083
Chet Haase9c1e23b2011-03-24 10:51:31 -070084 FILE *file = fdopen(fd, "a");
Romain Guy65b345f2011-07-27 18:51:50 -070085
Chet Haase9c1e23b2011-03-24 10:51:31 -070086 fprintf(file, "\nRecent DisplayList operations\n");
87 logBuffer.outputCommands(file, OP_NAMES);
Romain Guy65b345f2011-07-27 18:51:50 -070088
89 String8 cachesLog;
90 Caches::getInstance().dumpMemoryUsage(cachesLog);
91 fprintf(file, "\nCaches:\n%s", cachesLog.string());
92 fprintf(file, "\n");
93
Chet Haase9c1e23b2011-03-24 10:51:31 -070094 fflush(file);
95}
96
Chet Haase491189f2012-03-13 11:42:34 -070097DisplayList::DisplayList(const DisplayListRenderer& recorder) :
Chet Haase9420abd2012-03-29 16:28:32 -070098 mTransformMatrix(NULL), mTransformCamera(NULL), mTransformMatrix3D(NULL),
99 mStaticMatrix(NULL), mAnimationMatrix(NULL) {
Chet Haase491189f2012-03-13 11:42:34 -0700100
Chet Haase5977baa2011-01-05 18:01:22 -0800101 initFromDisplayListRenderer(recorder);
102}
103
104DisplayList::~DisplayList() {
Chet Haased63cbd12011-02-03 16:32:46 -0800105 clearResources();
106}
107
Chet Haasea1cff502012-02-21 13:43:44 -0800108void DisplayList::initProperties() {
109 mLeft = 0;
110 mTop = 0;
Chet Haaseb85967b2012-03-26 14:37:51 -0700111 mRight = 0;
Chet Haasea1cff502012-02-21 13:43:44 -0800112 mBottom = 0;
Chet Haasea1cff502012-02-21 13:43:44 -0800113 mClipChildren = true;
114 mAlpha = 1;
115 mMultipliedAlpha = 255;
Chet Haasedb8c9a62012-03-21 18:54:18 -0700116 mHasOverlappingRendering = true;
Chet Haasea1cff502012-02-21 13:43:44 -0800117 mTranslationX = 0;
118 mTranslationY = 0;
119 mRotation = 0;
120 mRotationX = 0;
121 mRotationY= 0;
122 mScaleX = 1;
123 mScaleY = 1;
124 mPivotX = 0;
125 mPivotY = 0;
Chet Haaseb85967b2012-03-26 14:37:51 -0700126 mCameraDistance = 0;
Chet Haasea1cff502012-02-21 13:43:44 -0800127 mMatrixDirty = false;
128 mMatrixFlags = 0;
129 mPrevWidth = -1;
130 mPrevHeight = -1;
131 mWidth = 0;
132 mHeight = 0;
133 mPivotExplicitlySet = false;
Chet Haasea1cff502012-02-21 13:43:44 -0800134 mCaching = false;
135}
136
Romain Guybb0acdf2012-03-05 13:44:35 -0800137void DisplayList::destroyDisplayListDeferred(DisplayList* displayList) {
138 if (displayList) {
139 DISPLAY_LIST_LOGD("Deferring display list destruction");
140 Caches::getInstance().deleteDisplayListDeferred(displayList);
141 }
142}
143
Chet Haased63cbd12011-02-03 16:32:46 -0800144void DisplayList::clearResources() {
Chet Haase5977baa2011-01-05 18:01:22 -0800145 sk_free((void*) mReader.base());
146
Chet Haase1271e2c2012-04-20 09:54:27 -0700147 delete mTransformMatrix;
148 delete mTransformCamera;
149 delete mTransformMatrix3D;
150 delete mStaticMatrix;
151 delete mAnimationMatrix;
Romain Guy58ecc202012-09-07 11:58:36 -0700152
Chet Haase1271e2c2012-04-20 09:54:27 -0700153 mTransformMatrix = NULL;
154 mTransformCamera = NULL;
155 mTransformMatrix3D = NULL;
156 mStaticMatrix = NULL;
157 mAnimationMatrix = NULL;
Chet Haasea1cff502012-02-21 13:43:44 -0800158
Chet Haase5977baa2011-01-05 18:01:22 -0800159 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700160 caches.unregisterFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700161 caches.resourceCache.lock();
Chet Haase5977baa2011-01-05 18:01:22 -0800162
163 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700164 caches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800165 }
Chet Haase5977baa2011-01-05 18:01:22 -0800166
Romain Guy49c5fc02012-05-15 11:10:01 -0700167 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
168 SkBitmap* bitmap = mOwnedBitmapResources.itemAt(i);
Romain Guy58ecc202012-09-07 11:58:36 -0700169 caches.resourceCache.decrementRefcountLocked(bitmap);
170 caches.resourceCache.destructorLocked(bitmap);
Romain Guy49c5fc02012-05-15 11:10:01 -0700171 }
Romain Guy49c5fc02012-05-15 11:10:01 -0700172
Romain Guyd586ad92011-06-22 16:14:36 -0700173 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700174 caches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -0700175 }
Romain Guyd586ad92011-06-22 16:14:36 -0700176
Romain Guy24c00212011-01-14 15:31:00 -0800177 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -0700178 caches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
179 caches.resourceCache.destructorLocked(mShaders.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800180 }
Romain Guy58ecc202012-09-07 11:58:36 -0700181
182 for (size_t i = 0; i < mSourcePaths.size(); i++) {
183 caches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
184 }
185
Chet Haase603f6de2012-09-14 15:31:25 -0700186 for (size_t i = 0; i < mLayers.size(); i++) {
187 caches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
188 }
189
Romain Guy58ecc202012-09-07 11:58:36 -0700190 caches.resourceCache.unlock();
Chet Haase5977baa2011-01-05 18:01:22 -0800191
192 for (size_t i = 0; i < mPaints.size(); i++) {
193 delete mPaints.itemAt(i);
194 }
Chet Haase5977baa2011-01-05 18:01:22 -0800195
Romain Guy2fc941e2011-02-03 15:06:05 -0800196 for (size_t i = 0; i < mPaths.size(); i++) {
Romain Guy1af23a32011-03-24 16:03:55 -0700197 SkPath* path = mPaths.itemAt(i);
198 caches.pathCache.remove(path);
199 delete path;
Romain Guy2fc941e2011-02-03 15:06:05 -0800200 }
Chet Haased34dd712012-05-02 18:50:34 -0700201
Chet Haase5977baa2011-01-05 18:01:22 -0800202 for (size_t i = 0; i < mMatrices.size(); i++) {
203 delete mMatrices.itemAt(i);
204 }
Romain Guy58ecc202012-09-07 11:58:36 -0700205
206 mBitmapResources.clear();
207 mOwnedBitmapResources.clear();
208 mFilterResources.clear();
209 mShaders.clear();
210 mSourcePaths.clear();
211 mPaints.clear();
212 mPaths.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800213 mMatrices.clear();
Chet Haase603f6de2012-09-14 15:31:25 -0700214 mLayers.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800215}
216
Chet Haased63cbd12011-02-03 16:32:46 -0800217void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
Romain Guyb051e892010-09-28 19:09:36 -0700218 const SkWriter32& writer = recorder.writeStream();
219 init();
220
221 if (writer.size() == 0) {
Romain Guy54c1a642012-09-27 17:55:46 -0700222 mFunctorCount = 0;
Romain Guyb051e892010-09-28 19:09:36 -0700223 return;
224 }
225
Chet Haased63cbd12011-02-03 16:32:46 -0800226 if (reusing) {
227 // re-using display list - clear out previous allocations
228 clearResources();
229 }
Chet Haasea1cff502012-02-21 13:43:44 -0800230 initProperties();
Chet Haased63cbd12011-02-03 16:32:46 -0800231
Romain Guy65b345f2011-07-27 18:51:50 -0700232 mSize = writer.size();
233 void* buffer = sk_malloc_throw(mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700234 writer.flatten(buffer);
Romain Guy65b345f2011-07-27 18:51:50 -0700235 mReader.setMemory(buffer, mSize);
Romain Guyb051e892010-09-28 19:09:36 -0700236
Romain Guy54c1a642012-09-27 17:55:46 -0700237 mFunctorCount = recorder.getFunctorCount();
238
Chet Haase5c13d892010-10-08 08:37:55 -0700239 Caches& caches = Caches::getInstance();
Romain Guy54c1a642012-09-27 17:55:46 -0700240 caches.registerFunctors(mFunctorCount);
Romain Guy58ecc202012-09-07 11:58:36 -0700241 caches.resourceCache.lock();
Romain Guyb051e892010-09-28 19:09:36 -0700242
Romain Guy49c5fc02012-05-15 11:10:01 -0700243 const Vector<SkBitmap*>& bitmapResources = recorder.getBitmapResources();
Chet Haase5c13d892010-10-08 08:37:55 -0700244 for (size_t i = 0; i < bitmapResources.size(); i++) {
245 SkBitmap* resource = bitmapResources.itemAt(i);
246 mBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700247 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700248 }
Chet Haased98aa2d2010-10-25 15:47:32 -0700249
Romain Guy49c5fc02012-05-15 11:10:01 -0700250 const Vector<SkBitmap*> &ownedBitmapResources = recorder.getOwnedBitmapResources();
251 for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
252 SkBitmap* resource = ownedBitmapResources.itemAt(i);
253 mOwnedBitmapResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700254 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guy49c5fc02012-05-15 11:10:01 -0700255 }
256
257 const Vector<SkiaColorFilter*>& filterResources = recorder.getFilterResources();
Romain Guyd586ad92011-06-22 16:14:36 -0700258 for (size_t i = 0; i < filterResources.size(); i++) {
259 SkiaColorFilter* resource = filterResources.itemAt(i);
260 mFilterResources.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700261 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyd586ad92011-06-22 16:14:36 -0700262 }
263
Romain Guy49c5fc02012-05-15 11:10:01 -0700264 const Vector<SkiaShader*>& shaders = recorder.getShaders();
Romain Guy24c00212011-01-14 15:31:00 -0800265 for (size_t i = 0; i < shaders.size(); i++) {
Romain Guyd586ad92011-06-22 16:14:36 -0700266 SkiaShader* resource = shaders.itemAt(i);
267 mShaders.add(resource);
Romain Guy58ecc202012-09-07 11:58:36 -0700268 caches.resourceCache.incrementRefcountLocked(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700269 }
270
Romain Guy58ecc202012-09-07 11:58:36 -0700271 const SortedVector<SkPath*>& sourcePaths = recorder.getSourcePaths();
272 for (size_t i = 0; i < sourcePaths.size(); i++) {
273 mSourcePaths.add(sourcePaths.itemAt(i));
274 caches.resourceCache.incrementRefcountLocked(sourcePaths.itemAt(i));
275 }
276
Chet Haase603f6de2012-09-14 15:31:25 -0700277 const Vector<Layer*>& layers = recorder.getLayers();
278 for (size_t i = 0; i < layers.size(); i++) {
279 mLayers.add(layers.itemAt(i));
280 caches.resourceCache.incrementRefcountLocked(layers.itemAt(i));
281 }
282
Romain Guy58ecc202012-09-07 11:58:36 -0700283 caches.resourceCache.unlock();
284
Romain Guy49c5fc02012-05-15 11:10:01 -0700285 const Vector<SkPaint*>& paints = recorder.getPaints();
Chet Haased98aa2d2010-10-25 15:47:32 -0700286 for (size_t i = 0; i < paints.size(); i++) {
287 mPaints.add(paints.itemAt(i));
288 }
289
Romain Guy49c5fc02012-05-15 11:10:01 -0700290 const Vector<SkPath*>& paths = recorder.getPaths();
Romain Guy2fc941e2011-02-03 15:06:05 -0800291 for (size_t i = 0; i < paths.size(); i++) {
292 mPaths.add(paths.itemAt(i));
293 }
294
Romain Guy49c5fc02012-05-15 11:10:01 -0700295 const Vector<SkMatrix*>& matrices = recorder.getMatrices();
Chet Haased98aa2d2010-10-25 15:47:32 -0700296 for (size_t i = 0; i < matrices.size(); i++) {
297 mMatrices.add(matrices.itemAt(i));
298 }
Romain Guyb051e892010-09-28 19:09:36 -0700299}
300
Romain Guyb051e892010-09-28 19:09:36 -0700301void DisplayList::init() {
Romain Guy65b345f2011-07-27 18:51:50 -0700302 mSize = 0;
Romain Guy04c9d8c2011-08-25 14:01:48 -0700303 mIsRenderable = true;
Romain Guy65b345f2011-07-27 18:51:50 -0700304}
305
306size_t DisplayList::getSize() {
307 return mSize;
Romain Guyb051e892010-09-28 19:09:36 -0700308}
309
Chet Haaseed30fd82011-04-22 16:18:45 -0700310/**
311 * This function is a simplified version of replay(), where we simply retrieve and log the
312 * display list. This function should remain in sync with the replay() function.
313 */
314void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
315 TextContainer text;
316
317 uint32_t count = (level + 1) * 2;
318 char indent[count + 1];
319 for (uint32_t i = 0; i < count; i++) {
320 indent[i] = ' ';
321 }
322 indent[count] = '\0';
Romain Guyddf74372012-05-22 14:07:07 -0700323 ALOGD("%sStart display list (%p, %s, render=%d)", (char*) indent + 2, this,
324 mName.string(), isRenderable());
Chet Haaseed30fd82011-04-22 16:18:45 -0700325
Chet Haase1271e2c2012-04-20 09:54:27 -0700326 ALOGD("%s%s %d", indent, "Save", SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
Chet Haaseed30fd82011-04-22 16:18:45 -0700327 int saveCount = renderer.getSaveCount() - 1;
328
Chet Haasea1cff502012-02-21 13:43:44 -0800329 outputViewProperties(renderer, (char*) indent);
Chet Haaseed30fd82011-04-22 16:18:45 -0700330 mReader.rewind();
331
332 while (!mReader.eof()) {
333 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800334 if (op & OP_MAY_BE_SKIPPED_MASK) {
335 int skip = mReader.readInt();
336 ALOGD("%sSkip %d", (char*) indent, skip);
337 op &= ~OP_MAY_BE_SKIPPED_MASK;
Chet Haasea1cff502012-02-21 13:43:44 -0800338 }
Chet Haaseed30fd82011-04-22 16:18:45 -0700339
340 switch (op) {
341 case DrawGLFunction: {
342 Functor *functor = (Functor *) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000343 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Chet Haaseed30fd82011-04-22 16:18:45 -0700344 }
345 break;
346 case Save: {
347 int rendererNum = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000348 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
Chet Haaseed30fd82011-04-22 16:18:45 -0700349 }
350 break;
351 case Restore: {
Steve Block5baa3a62011-12-20 16:23:08 +0000352 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700353 }
354 break;
355 case RestoreToCount: {
356 int restoreCount = saveCount + getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000357 ALOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
Chet Haaseed30fd82011-04-22 16:18:45 -0700358 }
359 break;
360 case SaveLayer: {
361 float f1 = getFloat();
362 float f2 = getFloat();
363 float f3 = getFloat();
364 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800365 SkPaint* paint = getPaint(renderer);
Chet Haaseed30fd82011-04-22 16:18:45 -0700366 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000367 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800368 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700369 }
370 break;
371 case SaveLayerAlpha: {
372 float f1 = getFloat();
373 float f2 = getFloat();
374 float f3 = getFloat();
375 float f4 = getFloat();
376 int alpha = getInt();
377 int flags = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000378 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800379 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haaseed30fd82011-04-22 16:18:45 -0700380 }
381 break;
382 case Translate: {
383 float f1 = getFloat();
384 float f2 = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000385 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
Chet Haaseed30fd82011-04-22 16:18:45 -0700386 }
387 break;
388 case Rotate: {
389 float rotation = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000390 ALOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
Chet Haaseed30fd82011-04-22 16:18:45 -0700391 }
392 break;
393 case Scale: {
394 float sx = getFloat();
395 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000396 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700397 }
398 break;
399 case Skew: {
400 float sx = getFloat();
401 float sy = getFloat();
Steve Block5baa3a62011-12-20 16:23:08 +0000402 ALOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
Chet Haaseed30fd82011-04-22 16:18:45 -0700403 }
404 break;
405 case SetMatrix: {
406 SkMatrix* matrix = getMatrix();
Steve Block5baa3a62011-12-20 16:23:08 +0000407 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
Chet Haaseed30fd82011-04-22 16:18:45 -0700408 }
409 break;
410 case ConcatMatrix: {
411 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -0800412 ALOGD("%s%s new concat %p: [%f, %f, %f] [%f, %f, %f] [%f, %f, %f]",
413 (char*) indent, OP_NAMES[op], matrix, matrix->get(0), matrix->get(1),
414 matrix->get(2), matrix->get(3), matrix->get(4), matrix->get(5),
415 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haaseed30fd82011-04-22 16:18:45 -0700416 }
417 break;
418 case ClipRect: {
419 float f1 = getFloat();
420 float f2 = getFloat();
421 float f3 = getFloat();
422 float f4 = getFloat();
423 int regionOp = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000424 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800425 f1, f2, f3, f4, regionOp);
Chet Haaseed30fd82011-04-22 16:18:45 -0700426 }
427 break;
428 case DrawDisplayList: {
429 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -0800430 int32_t flags = getInt();
431 ALOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -0700432 displayList, mWidth, mHeight, flags, level + 1);
Chet Haaseed30fd82011-04-22 16:18:45 -0700433 renderer.outputDisplayList(displayList, level + 1);
434 }
435 break;
436 case DrawLayer: {
437 Layer* layer = (Layer*) getInt();
438 float x = getFloat();
439 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800440 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000441 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800442 layer, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700443 }
444 break;
445 case DrawBitmap: {
446 SkBitmap* bitmap = getBitmap();
447 float x = getFloat();
448 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800449 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000450 ALOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800451 bitmap, x, y, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700452 }
453 break;
454 case DrawBitmapMatrix: {
455 SkBitmap* bitmap = getBitmap();
456 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -0800457 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000458 ALOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800459 bitmap, matrix, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700460 }
461 break;
462 case DrawBitmapRect: {
463 SkBitmap* bitmap = getBitmap();
464 float f1 = getFloat();
465 float f2 = getFloat();
466 float f3 = getFloat();
467 float f4 = getFloat();
468 float f5 = getFloat();
469 float f6 = getFloat();
470 float f7 = getFloat();
471 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800472 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000473 ALOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800474 (char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700475 }
476 break;
Romain Guye651cc62012-05-14 19:44:40 -0700477 case DrawBitmapData: {
478 SkBitmap* bitmap = getBitmapData();
479 float x = getFloat();
480 float y = getFloat();
481 SkPaint* paint = getPaint(renderer);
482 ALOGD("%s%s %.2f, %.2f, %p", (char*) indent, OP_NAMES[op], x, y, paint);
483 }
484 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700485 case DrawBitmapMesh: {
486 int verticesCount = 0;
487 uint32_t colorsCount = 0;
488 SkBitmap* bitmap = getBitmap();
489 uint32_t meshWidth = getInt();
490 uint32_t meshHeight = getInt();
491 float* vertices = getFloats(verticesCount);
492 bool hasColors = getInt();
493 int* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -0800494 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000495 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700496 }
497 break;
498 case DrawPatch: {
499 int32_t* xDivs = NULL;
500 int32_t* yDivs = NULL;
501 uint32_t* colors = NULL;
502 uint32_t xDivsCount = 0;
503 uint32_t yDivsCount = 0;
504 int8_t numColors = 0;
505 SkBitmap* bitmap = getBitmap();
506 xDivs = getInts(xDivsCount);
507 yDivs = getInts(yDivsCount);
508 colors = getUInts(numColors);
Romain Guya62f1722011-10-19 17:06:19 -0700509 float left = getFloat();
510 float top = getFloat();
511 float right = getFloat();
512 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -0700513 int alpha = getInt();
514 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000515 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", (char*) indent, OP_NAMES[op],
Romain Guya62f1722011-10-19 17:06:19 -0700516 left, top, right, bottom);
Chet Haaseed30fd82011-04-22 16:18:45 -0700517 }
518 break;
519 case DrawColor: {
520 int color = getInt();
521 int xferMode = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000522 ALOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haaseed30fd82011-04-22 16:18:45 -0700523 }
524 break;
525 case DrawRect: {
526 float f1 = getFloat();
527 float f2 = getFloat();
528 float f3 = getFloat();
529 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800530 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000531 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800532 f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700533 }
534 break;
535 case DrawRoundRect: {
536 float f1 = getFloat();
537 float f2 = getFloat();
538 float f3 = getFloat();
539 float f4 = getFloat();
540 float f5 = getFloat();
541 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800542 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000543 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800544 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700545 }
546 break;
547 case DrawCircle: {
548 float f1 = getFloat();
549 float f2 = getFloat();
550 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800551 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000552 ALOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800553 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700554 }
555 break;
556 case DrawOval: {
557 float f1 = getFloat();
558 float f2 = getFloat();
559 float f3 = getFloat();
560 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800561 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000562 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800563 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700564 }
565 break;
566 case DrawArc: {
567 float f1 = getFloat();
568 float f2 = getFloat();
569 float f3 = getFloat();
570 float f4 = getFloat();
571 float f5 = getFloat();
572 float f6 = getFloat();
573 int i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -0800574 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000575 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -0800576 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700577 }
578 break;
579 case DrawPath: {
580 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -0800581 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000582 ALOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haaseed30fd82011-04-22 16:18:45 -0700583 }
584 break;
585 case DrawLines: {
586 int count = 0;
587 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800588 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000589 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700590 }
591 break;
592 case DrawPoints: {
593 int count = 0;
594 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -0800595 SkPaint* paint = getPaint(renderer);
Steve Block5baa3a62011-12-20 16:23:08 +0000596 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700597 }
598 break;
Romain Guy325740f2012-02-24 16:48:34 -0800599 case DrawTextOnPath: {
600 getText(&text);
601 int32_t count = getInt();
602 SkPath* path = getPath();
603 float hOffset = getFloat();
604 float vOffset = getFloat();
605 SkPaint* paint = getPaint(renderer);
606 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
607 text.text(), text.length(), count, paint);
608 }
609 break;
Romain Guyeb9a5362012-01-17 17:39:26 -0800610 case DrawPosText: {
611 getText(&text);
612 int count = getInt();
613 int positionsCount = 0;
614 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -0800615 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -0800616 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800617 text.text(), text.length(), count, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -0800618 }
Raph Levien996e57c2012-07-23 15:22:52 -0700619 break;
Romain Guyc2525952012-07-27 16:41:22 -0700620 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -0700621 getText(&text);
Romain Guy18edb812012-08-03 16:06:55 -0700622 int32_t count = getInt();
623 float x = getFloat();
624 float y = getFloat();
625 int32_t positionsCount = 0;
Raph Levien996e57c2012-07-23 15:22:52 -0700626 float* positions = getFloats(positionsCount);
627 SkPaint* paint = getPaint(renderer);
Romain Guy18edb812012-08-03 16:06:55 -0700628 float length = getFloat();
Raph Levien996e57c2012-07-23 15:22:52 -0700629 ALOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
630 text.text(), text.length(), count, paint);
631 }
632 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700633 case ResetShader: {
Steve Block5baa3a62011-12-20 16:23:08 +0000634 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700635 }
636 break;
637 case SetupShader: {
638 SkiaShader* shader = getShader();
Steve Block5baa3a62011-12-20 16:23:08 +0000639 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
Chet Haaseed30fd82011-04-22 16:18:45 -0700640 }
641 break;
642 case ResetColorFilter: {
Steve Block5baa3a62011-12-20 16:23:08 +0000643 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700644 }
645 break;
646 case SetupColorFilter: {
647 SkiaColorFilter *colorFilter = getColorFilter();
Steve Block5baa3a62011-12-20 16:23:08 +0000648 ALOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
Chet Haaseed30fd82011-04-22 16:18:45 -0700649 }
650 break;
651 case ResetShadow: {
Steve Block5baa3a62011-12-20 16:23:08 +0000652 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700653 }
654 break;
655 case SetupShadow: {
656 float radius = getFloat();
657 float dx = getFloat();
658 float dy = getFloat();
659 int color = getInt();
Steve Block5baa3a62011-12-20 16:23:08 +0000660 ALOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -0800661 radius, dx, dy, color);
Chet Haaseed30fd82011-04-22 16:18:45 -0700662 }
663 break;
Romain Guy5ff9df62012-01-23 17:09:05 -0800664 case ResetPaintFilter: {
665 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
666 }
667 break;
668 case SetupPaintFilter: {
669 int clearBits = getInt();
670 int setBits = getInt();
671 ALOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op], clearBits, setBits);
672 }
673 break;
Chet Haaseed30fd82011-04-22 16:18:45 -0700674 default:
Steve Block5baa3a62011-12-20 16:23:08 +0000675 ALOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -0800676 (char*) indent, OP_NAMES[op]);
Chet Haaseed30fd82011-04-22 16:18:45 -0700677 break;
678 }
679 }
Chet Haasea1cff502012-02-21 13:43:44 -0800680 ALOGD("%sDone (%p, %s)", (char*) indent + 2, this, mName.string());
Chet Haaseed30fd82011-04-22 16:18:45 -0700681}
682
Chet Haasea1cff502012-02-21 13:43:44 -0800683void DisplayList::updateMatrix() {
684 if (mMatrixDirty) {
685 if (!mTransformMatrix) {
686 mTransformMatrix = new SkMatrix();
687 }
688 if (mMatrixFlags == 0 || mMatrixFlags == TRANSLATION) {
689 mTransformMatrix->reset();
690 } else {
691 if (!mPivotExplicitlySet) {
692 if (mWidth != mPrevWidth || mHeight != mPrevHeight) {
693 mPrevWidth = mWidth;
694 mPrevHeight = mHeight;
695 mPivotX = mPrevWidth / 2;
696 mPivotY = mPrevHeight / 2;
697 }
698 }
699 if ((mMatrixFlags & ROTATION_3D) == 0) {
700 mTransformMatrix->setTranslate(mTranslationX, mTranslationY);
701 mTransformMatrix->preRotate(mRotation, mPivotX, mPivotY);
702 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
703 } else {
704 if (!mTransformCamera) {
705 mTransformCamera = new Sk3DView();
706 mTransformMatrix3D = new SkMatrix();
707 }
708 mTransformMatrix->reset();
709 mTransformCamera->save();
710 mTransformMatrix->preScale(mScaleX, mScaleY, mPivotX, mPivotY);
711 mTransformCamera->rotateX(mRotationX);
712 mTransformCamera->rotateY(mRotationY);
713 mTransformCamera->rotateZ(-mRotation);
714 mTransformCamera->getMatrix(mTransformMatrix3D);
715 mTransformMatrix3D->preTranslate(-mPivotX, -mPivotY);
716 mTransformMatrix3D->postTranslate(mPivotX + mTranslationX,
717 mPivotY + mTranslationY);
718 mTransformMatrix->postConcat(*mTransformMatrix3D);
719 mTransformCamera->restore();
720 }
721 }
722 mMatrixDirty = false;
723 }
724}
725
726void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
Chet Haase1271e2c2012-04-20 09:54:27 -0700727 updateMatrix();
728 if (mLeft != 0 || mTop != 0) {
729 ALOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
730 }
731 if (mStaticMatrix) {
732 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
733 indent, "ConcatMatrix (static)", mStaticMatrix,
734 mStaticMatrix->get(0), mStaticMatrix->get(1),
735 mStaticMatrix->get(2), mStaticMatrix->get(3),
736 mStaticMatrix->get(4), mStaticMatrix->get(5),
737 mStaticMatrix->get(6), mStaticMatrix->get(7),
738 mStaticMatrix->get(8));
739 }
740 if (mAnimationMatrix) {
741 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
742 indent, "ConcatMatrix (animation)", mAnimationMatrix,
743 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
744 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
745 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
746 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
747 mAnimationMatrix->get(8));
748 }
749 if (mMatrixFlags != 0) {
750 if (mMatrixFlags == TRANSLATION) {
751 ALOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
752 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700753 ALOGD("%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700754 indent, "ConcatMatrix", mTransformMatrix,
755 mTransformMatrix->get(0), mTransformMatrix->get(1),
756 mTransformMatrix->get(2), mTransformMatrix->get(3),
757 mTransformMatrix->get(4), mTransformMatrix->get(5),
758 mTransformMatrix->get(6), mTransformMatrix->get(7),
759 mTransformMatrix->get(8));
Chet Haase9420abd2012-03-29 16:28:32 -0700760 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700761 }
762 if (mAlpha < 1 && !mCaching) {
763 // TODO: should be able to store the size of a DL at record time and not
764 // have to pass it into this call. In fact, this information might be in the
765 // location/size info that we store with the new native transform data.
766 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800767 if (mClipChildren) {
Chet Haase1271e2c2012-04-20 09:54:27 -0700768 flags |= SkCanvas::kClipToLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800769 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700770 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
771 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
772 mMultipliedAlpha, flags);
773 }
774 if (mClipChildren) {
775 ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
776 (float) mRight - mLeft, (float) mBottom - mTop);
Chet Haasea1cff502012-02-21 13:43:44 -0800777 }
778}
779
Chet Haase1271e2c2012-04-20 09:54:27 -0700780void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t level) {
Chet Haasea1cff502012-02-21 13:43:44 -0800781#if DEBUG_DISPLAY_LIST
782 uint32_t count = (level + 1) * 2;
783 char indent[count + 1];
784 for (uint32_t i = 0; i < count; i++) {
785 indent[i] = ' ';
786 }
787 indent[count] = '\0';
788#endif
Chet Haase1271e2c2012-04-20 09:54:27 -0700789 updateMatrix();
790 if (mLeft != 0 || mTop != 0) {
791 DISPLAY_LIST_LOGD("%s%s %d, %d", indent, "Translate (left, top)", mLeft, mTop);
792 renderer.translate(mLeft, mTop);
793 }
794 if (mStaticMatrix) {
795 DISPLAY_LIST_LOGD(
796 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
797 indent, "ConcatMatrix (static)", mStaticMatrix,
798 mStaticMatrix->get(0), mStaticMatrix->get(1),
799 mStaticMatrix->get(2), mStaticMatrix->get(3),
800 mStaticMatrix->get(4), mStaticMatrix->get(5),
801 mStaticMatrix->get(6), mStaticMatrix->get(7),
802 mStaticMatrix->get(8));
803 renderer.concatMatrix(mStaticMatrix);
804 } else if (mAnimationMatrix) {
805 DISPLAY_LIST_LOGD(
806 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
807 indent, "ConcatMatrix (animation)", mAnimationMatrix,
808 mAnimationMatrix->get(0), mAnimationMatrix->get(1),
809 mAnimationMatrix->get(2), mAnimationMatrix->get(3),
810 mAnimationMatrix->get(4), mAnimationMatrix->get(5),
811 mAnimationMatrix->get(6), mAnimationMatrix->get(7),
812 mAnimationMatrix->get(8));
813 renderer.concatMatrix(mAnimationMatrix);
814 }
815 if (mMatrixFlags != 0) {
816 if (mMatrixFlags == TRANSLATION) {
817 DISPLAY_LIST_LOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
818 renderer.translate(mTranslationX, mTranslationY);
819 } else {
Chet Haase9420abd2012-03-29 16:28:32 -0700820 DISPLAY_LIST_LOGD(
821 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
Chet Haase1271e2c2012-04-20 09:54:27 -0700822 indent, "ConcatMatrix", mTransformMatrix,
823 mTransformMatrix->get(0), mTransformMatrix->get(1),
824 mTransformMatrix->get(2), mTransformMatrix->get(3),
825 mTransformMatrix->get(4), mTransformMatrix->get(5),
826 mTransformMatrix->get(6), mTransformMatrix->get(7),
827 mTransformMatrix->get(8));
828 renderer.concatMatrix(mTransformMatrix);
Chet Haasea1cff502012-02-21 13:43:44 -0800829 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700830 }
831 if (mAlpha < 1 && !mCaching) {
832 if (!mHasOverlappingRendering) {
833 DISPLAY_LIST_LOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
834 renderer.setAlpha(mAlpha);
835 } else {
836 // TODO: should be able to store the size of a DL at record time and not
837 // have to pass it into this call. In fact, this information might be in the
838 // location/size info that we store with the new native transform data.
839 int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
840 if (mClipChildren) {
841 flags |= SkCanvas::kClipToLayer_SaveFlag;
Chet Haasea1cff502012-02-21 13:43:44 -0800842 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700843 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
844 (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
845 mMultipliedAlpha, flags);
846 renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
847 mMultipliedAlpha, flags);
Chet Haasea1cff502012-02-21 13:43:44 -0800848 }
Chet Haase1271e2c2012-04-20 09:54:27 -0700849 }
850 if (mClipChildren) {
851 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
852 (float) mRight - mLeft, (float) mBottom - mTop);
853 renderer.clipRect(0, 0, mRight - mLeft, mBottom - mTop,
854 SkRegion::kIntersect_Op);
Chet Haasea1cff502012-02-21 13:43:44 -0800855 }
856}
857
Chet Haaseed30fd82011-04-22 16:18:45 -0700858/**
859 * Changes to replay(), specifically those involving opcode or parameter changes, should be mimicked
860 * in the output() function, since that function processes the same list of opcodes for the
861 * purposes of logging display list info for a given view.
862 */
Chet Haase1271e2c2012-04-20 09:54:27 -0700863status_t DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, int32_t flags, uint32_t level) {
Chet Haase48659092012-05-31 15:21:51 -0700864 status_t drawGlStatus = DrawGlInfo::kStatusDone;
Romain Guyb051e892010-09-28 19:09:36 -0700865 TextContainer text;
866 mReader.rewind();
867
Romain Guyffac7fc2011-01-13 17:21:49 -0800868#if DEBUG_DISPLAY_LIST
869 uint32_t count = (level + 1) * 2;
870 char indent[count + 1];
871 for (uint32_t i = 0; i < count; i++) {
872 indent[i] = ' ';
873 }
874 indent[count] = '\0';
Chet Haasea23eed82012-04-12 15:19:04 -0700875 Rect* clipRect = renderer.getClipRect();
876 DISPLAY_LIST_LOGD("%sStart display list (%p, %s), clipRect: %.0f, %.f, %.0f, %.0f",
877 (char*) indent + 2, this, mName.string(), clipRect->left, clipRect->top,
878 clipRect->right, clipRect->bottom);
Romain Guyffac7fc2011-01-13 17:21:49 -0800879#endif
Romain Guyb051e892010-09-28 19:09:36 -0700880
Romain Guy13631f32012-01-30 17:41:55 -0800881 renderer.startMark(mName.string());
Romain Guy8a4ac612012-07-17 17:32:48 -0700882
Chet Haase1271e2c2012-04-20 09:54:27 -0700883 int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
884 DISPLAY_LIST_LOGD("%s%s %d %d", indent, "Save",
885 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag, restoreTo);
886 setViewProperties(renderer, level);
Romain Guy8a4ac612012-07-17 17:32:48 -0700887
888 if (renderer.quickRejectNoScissor(0, 0, mWidth, mHeight)) {
Chet Haaseb85967b2012-03-26 14:37:51 -0700889 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
890 renderer.restoreToCount(restoreTo);
891 renderer.endMark();
Chet Haase48659092012-05-31 15:21:51 -0700892 return drawGlStatus;
Chet Haaseb85967b2012-03-26 14:37:51 -0700893 }
Romain Guy13631f32012-01-30 17:41:55 -0800894
Chet Haase9c1e23b2011-03-24 10:51:31 -0700895 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
Romain Guyffac7fc2011-01-13 17:21:49 -0800896 int saveCount = renderer.getSaveCount() - 1;
Romain Guy8a4ac612012-07-17 17:32:48 -0700897
Romain Guyb051e892010-09-28 19:09:36 -0700898 while (!mReader.eof()) {
Romain Guy5b3b3522010-10-27 18:57:51 -0700899 int op = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800900 if (op & OP_MAY_BE_SKIPPED_MASK) {
Romain Guy390f8822012-03-13 18:00:10 -0700901 int32_t skip = mReader.readInt();
Romain Guy33f6beb2012-02-16 19:24:51 -0800902 if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
903 mReader.skip(skip);
904 DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,
905 OP_NAMES[op & ~OP_MAY_BE_SKIPPED_MASK], skip);
906 continue;
907 } else {
908 op &= ~OP_MAY_BE_SKIPPED_MASK;
Romain Guy33f6beb2012-02-16 19:24:51 -0800909 }
910 }
Chet Haase9c1e23b2011-03-24 10:51:31 -0700911 logBuffer.writeCommand(level, op);
Romain Guyffac7fc2011-01-13 17:21:49 -0800912
Romain Guy8a4ac612012-07-17 17:32:48 -0700913#if DEBUG_DISPLAY_LIST_OPS_AS_EVENTS
914 Caches::getInstance().eventMark(strlen(OP_NAMES[op]), OP_NAMES[op]);
915#endif
916
Romain Guy5b3b3522010-10-27 18:57:51 -0700917 switch (op) {
Chet Haasedaf98e92011-01-10 14:10:36 -0800918 case DrawGLFunction: {
919 Functor *functor = (Functor *) getInt();
920 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Romain Guy13631f32012-01-30 17:41:55 -0800921 renderer.startMark("GL functor");
Romain Guy65549432012-03-26 16:45:05 -0700922 drawGlStatus |= renderer.callDrawGLFunction(functor, dirty);
Romain Guy13631f32012-01-30 17:41:55 -0800923 renderer.endMark();
Chet Haasedaf98e92011-01-10 14:10:36 -0800924 }
925 break;
Romain Guyb051e892010-09-28 19:09:36 -0700926 case Save: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800927 int32_t rendererNum = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800928 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
929 renderer.save(rendererNum);
Romain Guyb051e892010-09-28 19:09:36 -0700930 }
931 break;
932 case Restore: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800933 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700934 renderer.restore();
935 }
936 break;
937 case RestoreToCount: {
Romain Guy33f6beb2012-02-16 19:24:51 -0800938 int32_t restoreCount = saveCount + getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800939 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
940 renderer.restoreToCount(restoreCount);
Romain Guyb051e892010-09-28 19:09:36 -0700941 }
942 break;
943 case SaveLayer: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800944 float f1 = getFloat();
945 float f2 = getFloat();
946 float f3 = getFloat();
947 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -0800948 SkPaint* paint = getPaint(renderer);
Romain Guy33f6beb2012-02-16 19:24:51 -0800949 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800950 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800951 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800952 renderer.saveLayer(f1, f2, f3, f4, paint, flags);
Romain Guyb051e892010-09-28 19:09:36 -0700953 }
954 break;
Romain Guy5b3b3522010-10-27 18:57:51 -0700955 case SaveLayerAlpha: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800956 float f1 = getFloat();
957 float f2 = getFloat();
958 float f3 = getFloat();
959 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -0800960 int32_t alpha = getInt();
961 int32_t flags = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -0800962 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
Chet Haasea1cff502012-02-21 13:43:44 -0800963 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
Chet Haasedaf98e92011-01-10 14:10:36 -0800964 renderer.saveLayerAlpha(f1, f2, f3, f4, alpha, flags);
Romain Guy5b3b3522010-10-27 18:57:51 -0700965 }
966 break;
Romain Guyb051e892010-09-28 19:09:36 -0700967 case Translate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800968 float f1 = getFloat();
969 float f2 = getFloat();
970 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
971 renderer.translate(f1, f2);
Romain Guyb051e892010-09-28 19:09:36 -0700972 }
973 break;
974 case Rotate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800975 float rotation = getFloat();
976 DISPLAY_LIST_LOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
977 renderer.rotate(rotation);
Romain Guyb051e892010-09-28 19:09:36 -0700978 }
979 break;
980 case Scale: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800981 float sx = getFloat();
982 float sy = getFloat();
983 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
984 renderer.scale(sx, sy);
Romain Guyb051e892010-09-28 19:09:36 -0700985 }
986 break;
Romain Guy807daf72011-01-18 11:19:19 -0800987 case Skew: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800988 float sx = getFloat();
989 float sy = getFloat();
990 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
991 renderer.skew(sx, sy);
Romain Guy807daf72011-01-18 11:19:19 -0800992 }
993 break;
Romain Guyb051e892010-09-28 19:09:36 -0700994 case SetMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800995 SkMatrix* matrix = getMatrix();
996 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
997 renderer.setMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -0700998 }
999 break;
1000 case ConcatMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001001 SkMatrix* matrix = getMatrix();
Chet Haasea1cff502012-02-21 13:43:44 -08001002 DISPLAY_LIST_LOGD(
1003 "%s%s %p: [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f] [%.2f, %.2f, %.2f]",
1004 (char*) indent, OP_NAMES[op], matrix,
1005 matrix->get(0), matrix->get(1), matrix->get(2),
1006 matrix->get(3), matrix->get(4), matrix->get(5),
1007 matrix->get(6), matrix->get(7), matrix->get(8));
Chet Haasedaf98e92011-01-10 14:10:36 -08001008 renderer.concatMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -07001009 }
1010 break;
1011 case ClipRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001012 float f1 = getFloat();
1013 float f2 = getFloat();
1014 float f3 = getFloat();
1015 float f4 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001016 int32_t regionOp = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001017 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001018 f1, f2, f3, f4, regionOp);
Chet Haasedaf98e92011-01-10 14:10:36 -08001019 renderer.clipRect(f1, f2, f3, f4, (SkRegion::Op) regionOp);
Romain Guyb051e892010-09-28 19:09:36 -07001020 }
1021 break;
Romain Guy0fe478e2010-11-08 12:08:41 -08001022 case DrawDisplayList: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001023 DisplayList* displayList = getDisplayList();
Romain Guy33f6beb2012-02-16 19:24:51 -08001024 int32_t flags = getInt();
1025 DISPLAY_LIST_LOGD("%s%s %p, %dx%d, 0x%x %d", (char*) indent, OP_NAMES[op],
Chet Haase1271e2c2012-04-20 09:54:27 -07001026 displayList, mWidth, mHeight, flags, level + 1);
1027 drawGlStatus |= renderer.drawDisplayList(displayList, dirty, flags, level + 1);
Romain Guy0fe478e2010-11-08 12:08:41 -08001028 }
1029 break;
Romain Guy6c319ca2011-01-11 14:29:25 -08001030 case DrawLayer: {
Chet Haased15ebf22012-09-05 11:40:29 -07001031 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001032 Layer* layer = (Layer*) getInt();
1033 float x = getFloat();
1034 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001035 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001036 if (mCaching && mMultipliedAlpha < 255) {
1037 oldAlpha = layer->getAlpha();
1038 layer->setAlpha(mMultipliedAlpha);
Chet Haasea1cff502012-02-21 13:43:44 -08001039 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001040 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001041 layer, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001042 drawGlStatus |= renderer.drawLayer(layer, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001043 if (oldAlpha >= 0) {
1044 layer->setAlpha(oldAlpha);
1045 }
Romain Guy6c319ca2011-01-11 14:29:25 -08001046 }
1047 break;
Romain Guyb051e892010-09-28 19:09:36 -07001048 case DrawBitmap: {
Chet Haased15ebf22012-09-05 11:40:29 -07001049 int oldAlpha = -1;
Chet Haasedaf98e92011-01-10 14:10:36 -08001050 SkBitmap* bitmap = getBitmap();
1051 float x = getFloat();
1052 float y = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001053 SkPaint* paint = getPaint(renderer);
Chet Haased15ebf22012-09-05 11:40:29 -07001054 if (mCaching && mMultipliedAlpha < 255) {
1055 oldAlpha = paint->getAlpha();
Chet Haaseb85967b2012-03-26 14:37:51 -07001056 paint->setAlpha(mMultipliedAlpha);
1057 }
Chet Haasedaf98e92011-01-10 14:10:36 -08001058 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001059 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001060 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Chet Haased15ebf22012-09-05 11:40:29 -07001061 if (oldAlpha >= 0) {
1062 paint->setAlpha(oldAlpha);
1063 }
Romain Guyb051e892010-09-28 19:09:36 -07001064 }
1065 break;
1066 case DrawBitmapMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001067 SkBitmap* bitmap = getBitmap();
1068 SkMatrix* matrix = getMatrix();
Romain Guy5ff9df62012-01-23 17:09:05 -08001069 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001070 DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001071 bitmap, matrix, paint);
Chet Haase48659092012-05-31 15:21:51 -07001072 drawGlStatus |= renderer.drawBitmap(bitmap, matrix, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001073 }
1074 break;
1075 case DrawBitmapRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001076 SkBitmap* bitmap = getBitmap();
1077 float f1 = getFloat();
1078 float f2 = getFloat();
1079 float f3 = getFloat();
1080 float f4 = getFloat();
1081 float f5 = getFloat();
1082 float f6 = getFloat();
1083 float f7 = getFloat();
1084 float f8 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001085 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001086 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001087 (char*) indent, OP_NAMES[op], bitmap,
1088 f1, f2, f3, f4, f5, f6, f7, f8,paint);
Chet Haase48659092012-05-31 15:21:51 -07001089 drawGlStatus |= renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001090 }
1091 break;
Romain Guye651cc62012-05-14 19:44:40 -07001092 case DrawBitmapData: {
1093 SkBitmap* bitmap = getBitmapData();
1094 float x = getFloat();
1095 float y = getFloat();
1096 SkPaint* paint = getPaint(renderer);
1097 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
1098 bitmap, x, y, paint);
Chet Haase48659092012-05-31 15:21:51 -07001099 drawGlStatus |= renderer.drawBitmap(bitmap, x, y, paint);
Romain Guye651cc62012-05-14 19:44:40 -07001100 }
1101 break;
Romain Guy5a7b4662011-01-20 19:09:30 -08001102 case DrawBitmapMesh: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001103 int32_t verticesCount = 0;
Romain Guy5a7b4662011-01-20 19:09:30 -08001104 uint32_t colorsCount = 0;
1105
1106 SkBitmap* bitmap = getBitmap();
1107 uint32_t meshWidth = getInt();
1108 uint32_t meshHeight = getInt();
1109 float* vertices = getFloats(verticesCount);
1110 bool hasColors = getInt();
Romain Guy33f6beb2012-02-16 19:24:51 -08001111 int32_t* colors = hasColors ? getInts(colorsCount) : NULL;
Romain Guy5ff9df62012-01-23 17:09:05 -08001112 SkPaint* paint = getPaint(renderer);
Romain Guy5a7b4662011-01-20 19:09:30 -08001113
Chet Haasedaf98e92011-01-10 14:10:36 -08001114 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001115 drawGlStatus |= renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices,
1116 colors, paint);
Romain Guy5a7b4662011-01-20 19:09:30 -08001117 }
Romain Guya566b7c2011-01-23 16:36:11 -08001118 break;
Romain Guyb051e892010-09-28 19:09:36 -07001119 case DrawPatch: {
1120 int32_t* xDivs = NULL;
1121 int32_t* yDivs = NULL;
Romain Guy4bb94202010-10-12 15:59:26 -07001122 uint32_t* colors = NULL;
Romain Guyb051e892010-09-28 19:09:36 -07001123 uint32_t xDivsCount = 0;
1124 uint32_t yDivsCount = 0;
Romain Guy4bb94202010-10-12 15:59:26 -07001125 int8_t numColors = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001126
1127 SkBitmap* bitmap = getBitmap();
1128
1129 xDivs = getInts(xDivsCount);
1130 yDivs = getInts(yDivsCount);
Romain Guy4bb94202010-10-12 15:59:26 -07001131 colors = getUInts(numColors);
Romain Guyb051e892010-09-28 19:09:36 -07001132
Romain Guy9ff3cb52011-06-28 14:02:11 -07001133 float left = getFloat();
1134 float top = getFloat();
1135 float right = getFloat();
1136 float bottom = getFloat();
Romain Guybe6f9dc2012-07-16 12:41:17 -07001137
1138 int alpha = getInt();
1139 SkXfermode::Mode mode = (SkXfermode::Mode) getInt();
Romain Guy9ff3cb52011-06-28 14:02:11 -07001140
Chet Haasedaf98e92011-01-10 14:10:36 -08001141 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001142 drawGlStatus |= renderer.drawPatch(bitmap, xDivs, yDivs, colors,
Romain Guybe6f9dc2012-07-16 12:41:17 -07001143 xDivsCount, yDivsCount, numColors, left, top, right, bottom,
1144 alpha, mode);
Romain Guyb051e892010-09-28 19:09:36 -07001145 }
1146 break;
1147 case DrawColor: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001148 int32_t color = getInt();
1149 int32_t xferMode = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001150 DISPLAY_LIST_LOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
Chet Haase48659092012-05-31 15:21:51 -07001151 drawGlStatus |= renderer.drawColor(color, (SkXfermode::Mode) xferMode);
Romain Guyb051e892010-09-28 19:09:36 -07001152 }
1153 break;
1154 case DrawRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001155 float f1 = getFloat();
1156 float f2 = getFloat();
1157 float f3 = getFloat();
1158 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001159 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001160 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001161 f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001162 drawGlStatus |= renderer.drawRect(f1, f2, f3, f4, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001163 }
1164 break;
Romain Guy01d58e42011-01-19 21:54:02 -08001165 case DrawRoundRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001166 float f1 = getFloat();
1167 float f2 = getFloat();
1168 float f3 = getFloat();
1169 float f4 = getFloat();
1170 float f5 = getFloat();
1171 float f6 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001172 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001173 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001174 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
Chet Haase48659092012-05-31 15:21:51 -07001175 drawGlStatus |= renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001176 }
1177 break;
1178 case DrawCircle: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001179 float f1 = getFloat();
1180 float f2 = getFloat();
1181 float f3 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001182 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001183 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001184 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
Chet Haase48659092012-05-31 15:21:51 -07001185 drawGlStatus |= renderer.drawCircle(f1, f2, f3, paint);
Romain Guy01d58e42011-01-19 21:54:02 -08001186 }
1187 break;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001188 case DrawOval: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001189 float f1 = getFloat();
1190 float f2 = getFloat();
1191 float f3 = getFloat();
1192 float f4 = getFloat();
Romain Guy5ff9df62012-01-23 17:09:05 -08001193 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001194 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001195 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
Chet Haase48659092012-05-31 15:21:51 -07001196 drawGlStatus |= renderer.drawOval(f1, f2, f3, f4, paint);
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001197 }
1198 break;
Romain Guy8b2f5262011-01-23 16:15:02 -08001199 case DrawArc: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001200 float f1 = getFloat();
1201 float f2 = getFloat();
1202 float f3 = getFloat();
1203 float f4 = getFloat();
1204 float f5 = getFloat();
1205 float f6 = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001206 int32_t i1 = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001207 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001208 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
Chet Haasea1cff502012-02-21 13:43:44 -08001209 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
Chet Haase48659092012-05-31 15:21:51 -07001210 drawGlStatus |= renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
Romain Guy8b2f5262011-01-23 16:15:02 -08001211 }
1212 break;
Romain Guyb051e892010-09-28 19:09:36 -07001213 case DrawPath: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001214 SkPath* path = getPath();
Romain Guy5ff9df62012-01-23 17:09:05 -08001215 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001216 DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
Chet Haase48659092012-05-31 15:21:51 -07001217 drawGlStatus |= renderer.drawPath(path, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001218 }
1219 break;
1220 case DrawLines: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001221 int32_t count = 0;
Romain Guyb051e892010-09-28 19:09:36 -07001222 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001223 SkPaint* paint = getPaint(renderer);
Chet Haasedaf98e92011-01-10 14:10:36 -08001224 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001225 drawGlStatus |= renderer.drawLines(points, count, paint);
Romain Guyb051e892010-09-28 19:09:36 -07001226 }
1227 break;
Romain Guyed6fcb02011-03-21 13:11:28 -07001228 case DrawPoints: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001229 int32_t count = 0;
Romain Guyed6fcb02011-03-21 13:11:28 -07001230 float* points = getFloats(count);
Romain Guy5ff9df62012-01-23 17:09:05 -08001231 SkPaint* paint = getPaint(renderer);
Romain Guyed6fcb02011-03-21 13:11:28 -07001232 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Chet Haase48659092012-05-31 15:21:51 -07001233 drawGlStatus |= renderer.drawPoints(points, count, paint);
Romain Guyed6fcb02011-03-21 13:11:28 -07001234 }
1235 break;
Romain Guy325740f2012-02-24 16:48:34 -08001236 case DrawTextOnPath: {
1237 getText(&text);
1238 int32_t count = getInt();
1239 SkPath* path = getPath();
1240 float hOffset = getFloat();
1241 float vOffset = getFloat();
1242 SkPaint* paint = getPaint(renderer);
1243 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent, OP_NAMES[op],
1244 text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001245 drawGlStatus |= renderer.drawTextOnPath(text.text(), text.length(), count, path,
Romain Guy325740f2012-02-24 16:48:34 -08001246 hOffset, vOffset, paint);
1247 }
1248 break;
Romain Guyeb9a5362012-01-17 17:39:26 -08001249 case DrawPosText: {
1250 getText(&text);
Romain Guy33f6beb2012-02-16 19:24:51 -08001251 int32_t count = getInt();
1252 int32_t positionsCount = 0;
Romain Guyeb9a5362012-01-17 17:39:26 -08001253 float* positions = getFloats(positionsCount);
Romain Guy5ff9df62012-01-23 17:09:05 -08001254 SkPaint* paint = getPaint(renderer);
Romain Guyeb9a5362012-01-17 17:39:26 -08001255 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %p", (char*) indent,
1256 OP_NAMES[op], text.text(), text.length(), count, paint);
Chet Haase48659092012-05-31 15:21:51 -07001257 drawGlStatus |= renderer.drawPosText(text.text(), text.length(), count,
1258 positions, paint);
Romain Guyeb9a5362012-01-17 17:39:26 -08001259 }
1260 break;
Romain Guyc2525952012-07-27 16:41:22 -07001261 case DrawText: {
Raph Levien996e57c2012-07-23 15:22:52 -07001262 getText(&text);
1263 int32_t count = getInt();
1264 float x = getFloat();
1265 float y = getFloat();
1266 int32_t positionsCount = 0;
1267 float* positions = getFloats(positionsCount);
1268 SkPaint* paint = getPaint(renderer);
1269 float length = getFloat();
1270 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p, %.2f", (char*) indent,
1271 OP_NAMES[op], text.text(), text.length(), count, x, y, paint, length);
Romain Guyc2525952012-07-27 16:41:22 -07001272 drawGlStatus |= renderer.drawText(text.text(), text.length(), count,
Raph Levien996e57c2012-07-23 15:22:52 -07001273 x, y, positions, paint, length);
1274 }
1275 break;
Romain Guyb051e892010-09-28 19:09:36 -07001276 case ResetShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001277 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001278 renderer.resetShader();
1279 }
1280 break;
1281 case SetupShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001282 SkiaShader* shader = getShader();
1283 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
1284 renderer.setupShader(shader);
Romain Guyb051e892010-09-28 19:09:36 -07001285 }
1286 break;
1287 case ResetColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001288 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001289 renderer.resetColorFilter();
1290 }
1291 break;
1292 case SetupColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001293 SkiaColorFilter *colorFilter = getColorFilter();
1294 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
1295 renderer.setupColorFilter(colorFilter);
Romain Guyb051e892010-09-28 19:09:36 -07001296 }
1297 break;
1298 case ResetShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001299 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -07001300 renderer.resetShadow();
1301 }
1302 break;
1303 case SetupShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -08001304 float radius = getFloat();
1305 float dx = getFloat();
1306 float dy = getFloat();
Romain Guy33f6beb2012-02-16 19:24:51 -08001307 int32_t color = getInt();
Chet Haasedaf98e92011-01-10 14:10:36 -08001308 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
Chet Haasea1cff502012-02-21 13:43:44 -08001309 radius, dx, dy, color);
Chet Haasedaf98e92011-01-10 14:10:36 -08001310 renderer.setupShadow(radius, dx, dy, color);
Romain Guyb051e892010-09-28 19:09:36 -07001311 }
1312 break;
Romain Guy5ff9df62012-01-23 17:09:05 -08001313 case ResetPaintFilter: {
1314 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
1315 renderer.resetPaintFilter();
1316 }
1317 break;
1318 case SetupPaintFilter: {
Romain Guy33f6beb2012-02-16 19:24:51 -08001319 int32_t clearBits = getInt();
1320 int32_t setBits = getInt();
Romain Guy5ff9df62012-01-23 17:09:05 -08001321 DISPLAY_LIST_LOGD("%s%s 0x%x, 0x%x", (char*) indent, OP_NAMES[op],
1322 clearBits, setBits);
1323 renderer.setupPaintFilter(clearBits, setBits);
1324 }
1325 break;
Chet Haasedaf98e92011-01-10 14:10:36 -08001326 default:
1327 DISPLAY_LIST_LOGD("Display List error: op not handled: %s%s",
Chet Haasea1cff502012-02-21 13:43:44 -08001328 (char*) indent, OP_NAMES[op]);
Chet Haasedaf98e92011-01-10 14:10:36 -08001329 break;
Romain Guyb051e892010-09-28 19:09:36 -07001330 }
1331 }
Romain Guyffac7fc2011-01-13 17:21:49 -08001332
Chet Haase1271e2c2012-04-20 09:54:27 -07001333 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, "RestoreToCount", restoreTo);
1334 renderer.restoreToCount(restoreTo);
Romain Guy13631f32012-01-30 17:41:55 -08001335 renderer.endMark();
1336
Chet Haasea1cff502012-02-21 13:43:44 -08001337 DISPLAY_LIST_LOGD("%sDone (%p, %s), returning %d", (char*) indent + 2, this, mName.string(),
Romain Guy65549432012-03-26 16:45:05 -07001338 drawGlStatus);
1339 return drawGlStatus;
Romain Guyb051e892010-09-28 19:09:36 -07001340}
1341
1342///////////////////////////////////////////////////////////////////////////////
Romain Guy4aa90572010-09-26 18:40:37 -07001343// Base structure
1344///////////////////////////////////////////////////////////////////////////////
1345
Romain Guy58ecc202012-09-07 11:58:36 -07001346DisplayListRenderer::DisplayListRenderer():
1347 mCaches(Caches::getInstance()), mWriter(MIN_WRITER_SIZE),
Romain Guy54c1a642012-09-27 17:55:46 -07001348 mTranslateX(0.0f), mTranslateY(0.0f), mHasTranslate(false),
1349 mHasDrawOps(false), mFunctorCount(0) {
Romain Guy4aa90572010-09-26 18:40:37 -07001350}
1351
1352DisplayListRenderer::~DisplayListRenderer() {
1353 reset();
1354}
1355
1356void DisplayListRenderer::reset() {
Romain Guy4aa90572010-09-26 18:40:37 -07001357 mWriter.reset();
Chet Haase5c13d892010-10-08 08:37:55 -07001358
Romain Guy58ecc202012-09-07 11:58:36 -07001359 mCaches.resourceCache.lock();
1360
Chet Haase5c13d892010-10-08 08:37:55 -07001361 for (size_t i = 0; i < mBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001362 mCaches.resourceCache.decrementRefcountLocked(mBitmapResources.itemAt(i));
Chet Haase5c13d892010-10-08 08:37:55 -07001363 }
Chet Haased98aa2d2010-10-25 15:47:32 -07001364
Romain Guy49c5fc02012-05-15 11:10:01 -07001365 for (size_t i = 0; i < mOwnedBitmapResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001366 mCaches.resourceCache.decrementRefcountLocked(mOwnedBitmapResources.itemAt(i));
Romain Guy49c5fc02012-05-15 11:10:01 -07001367 }
Romain Guy49c5fc02012-05-15 11:10:01 -07001368
Romain Guyd586ad92011-06-22 16:14:36 -07001369 for (size_t i = 0; i < mFilterResources.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001370 mCaches.resourceCache.decrementRefcountLocked(mFilterResources.itemAt(i));
Romain Guyd586ad92011-06-22 16:14:36 -07001371 }
Romain Guyd586ad92011-06-22 16:14:36 -07001372
Romain Guy43ccf462011-01-14 18:51:01 -08001373 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001374 mCaches.resourceCache.decrementRefcountLocked(mShaders.itemAt(i));
Romain Guy43ccf462011-01-14 18:51:01 -08001375 }
Romain Guy43ccf462011-01-14 18:51:01 -08001376
Chet Haased34dd712012-05-02 18:50:34 -07001377 for (size_t i = 0; i < mSourcePaths.size(); i++) {
Romain Guy58ecc202012-09-07 11:58:36 -07001378 mCaches.resourceCache.decrementRefcountLocked(mSourcePaths.itemAt(i));
Chet Haased34dd712012-05-02 18:50:34 -07001379 }
Romain Guy58ecc202012-09-07 11:58:36 -07001380
Chet Haase603f6de2012-09-14 15:31:25 -07001381 for (size_t i = 0; i < mLayers.size(); i++) {
1382 mCaches.resourceCache.decrementRefcountLocked(mLayers.itemAt(i));
1383 }
1384
Romain Guy58ecc202012-09-07 11:58:36 -07001385 mCaches.resourceCache.unlock();
1386
1387 mBitmapResources.clear();
1388 mOwnedBitmapResources.clear();
1389 mFilterResources.clear();
Chet Haased34dd712012-05-02 18:50:34 -07001390 mSourcePaths.clear();
1391
Romain Guy58ecc202012-09-07 11:58:36 -07001392 mShaders.clear();
1393 mShaderMap.clear();
1394
Romain Guy43ccf462011-01-14 18:51:01 -08001395 mPaints.clear();
1396 mPaintMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001397
Romain Guy2fc941e2011-02-03 15:06:05 -08001398 mPaths.clear();
1399 mPathMap.clear();
Romain Guyd586ad92011-06-22 16:14:36 -07001400
Chet Haased98aa2d2010-10-25 15:47:32 -07001401 mMatrices.clear();
Romain Guy04c9d8c2011-08-25 14:01:48 -07001402
Chet Haase603f6de2012-09-14 15:31:25 -07001403 mLayers.clear();
1404
Romain Guy04c9d8c2011-08-25 14:01:48 -07001405 mHasDrawOps = false;
Romain Guy54c1a642012-09-27 17:55:46 -07001406 mFunctorCount = 0;
Romain Guy4aa90572010-09-26 18:40:37 -07001407}
1408
1409///////////////////////////////////////////////////////////////////////////////
1410// Operations
1411///////////////////////////////////////////////////////////////////////////////
1412
Jeff Brown162a0212011-07-21 17:02:54 -07001413DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
1414 if (!displayList) {
1415 displayList = new DisplayList(*this);
Chet Haase5977baa2011-01-05 18:01:22 -08001416 } else {
Jeff Brown162a0212011-07-21 17:02:54 -07001417 displayList->initFromDisplayListRenderer(*this, true);
Chet Haase5977baa2011-01-05 18:01:22 -08001418 }
Romain Guy04c9d8c2011-08-25 14:01:48 -07001419 displayList->setRenderable(mHasDrawOps);
Jeff Brown162a0212011-07-21 17:02:54 -07001420 return displayList;
Chet Haase5977baa2011-01-05 18:01:22 -08001421}
1422
Romain Guy49c5fc02012-05-15 11:10:01 -07001423bool DisplayListRenderer::isDeferred() {
1424 return true;
1425}
1426
Romain Guyb051e892010-09-28 19:09:36 -07001427void DisplayListRenderer::setViewport(int width, int height) {
1428 mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
1429
1430 mWidth = width;
1431 mHeight = height;
1432}
1433
Chet Haase44b2fe32012-06-06 19:03:58 -07001434int DisplayListRenderer::prepareDirty(float left, float top,
Romain Guy7d7b5492011-01-24 16:33:45 -08001435 float right, float bottom, bool opaque) {
Romain Guyb051e892010-09-28 19:09:36 -07001436 mSnapshot = new Snapshot(mFirstSnapshot,
1437 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
1438 mSaveCount = 1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001439
Romain Guyb051e892010-09-28 19:09:36 -07001440 mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
Romain Guy45e4c3d2012-09-11 17:17:07 -07001441 mDirtyClip = opaque;
1442
Romain Guy27454a42011-01-23 12:01:41 -08001443 mRestoreSaveCount = -1;
Romain Guy45e4c3d2012-09-11 17:17:07 -07001444
Chet Haase44b2fe32012-06-06 19:03:58 -07001445 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Romain Guy27454a42011-01-23 12:01:41 -08001446}
1447
1448void DisplayListRenderer::finish() {
1449 insertRestoreToCount();
Romain Guy33f6beb2012-02-16 19:24:51 -08001450 insertTranlate();
Romain Guyb051e892010-09-28 19:09:36 -07001451}
1452
Chet Haasedaf98e92011-01-10 14:10:36 -08001453void DisplayListRenderer::interrupt() {
Chet Haasedaf98e92011-01-10 14:10:36 -08001454}
Romain Guy2b1847e2011-01-26 13:43:01 -08001455
Chet Haasedaf98e92011-01-10 14:10:36 -08001456void DisplayListRenderer::resume() {
Romain Guy4aa90572010-09-26 18:40:37 -07001457}
1458
Romain Guy65549432012-03-26 16:45:05 -07001459status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
Romain Guycabfcc12011-03-07 18:06:46 -08001460 // Ignore dirty during recording, it matters only when we replay
Chet Haasedaf98e92011-01-10 14:10:36 -08001461 addOp(DisplayList::DrawGLFunction);
1462 addInt((int) functor);
Romain Guy54c1a642012-09-27 17:55:46 -07001463 mFunctorCount++;
Romain Guy65549432012-03-26 16:45:05 -07001464 return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
Chet Haasedaf98e92011-01-10 14:10:36 -08001465}
1466
Romain Guy4aa90572010-09-26 18:40:37 -07001467int DisplayListRenderer::save(int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001468 addOp(DisplayList::Save);
Romain Guy4aa90572010-09-26 18:40:37 -07001469 addInt(flags);
1470 return OpenGLRenderer::save(flags);
1471}
1472
1473void DisplayListRenderer::restore() {
Romain Guy04c9d8c2011-08-25 14:01:48 -07001474 if (mRestoreSaveCount < 0) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001475 restoreToCount(getSaveCount() - 1);
1476 return;
Romain Guy04c9d8c2011-08-25 14:01:48 -07001477 }
Romain Guy33f6beb2012-02-16 19:24:51 -08001478
1479 mRestoreSaveCount--;
1480 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001481 OpenGLRenderer::restore();
1482}
1483
1484void DisplayListRenderer::restoreToCount(int saveCount) {
Romain Guy27454a42011-01-23 12:01:41 -08001485 mRestoreSaveCount = saveCount;
Romain Guy33f6beb2012-02-16 19:24:51 -08001486 insertTranlate();
Romain Guy4aa90572010-09-26 18:40:37 -07001487 OpenGLRenderer::restoreToCount(saveCount);
1488}
1489
1490int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001491 SkPaint* p, int flags) {
Romain Guyb051e892010-09-28 19:09:36 -07001492 addOp(DisplayList::SaveLayer);
Romain Guy4aa90572010-09-26 18:40:37 -07001493 addBounds(left, top, right, bottom);
1494 addPaint(p);
1495 addInt(flags);
Romain Guyb051e892010-09-28 19:09:36 -07001496 return OpenGLRenderer::save(flags);
Romain Guy4aa90572010-09-26 18:40:37 -07001497}
1498
Romain Guy5b3b3522010-10-27 18:57:51 -07001499int DisplayListRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
1500 int alpha, int flags) {
1501 addOp(DisplayList::SaveLayerAlpha);
1502 addBounds(left, top, right, bottom);
1503 addInt(alpha);
1504 addInt(flags);
1505 return OpenGLRenderer::save(flags);
1506}
1507
Romain Guy4aa90572010-09-26 18:40:37 -07001508void DisplayListRenderer::translate(float dx, float dy) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001509 mHasTranslate = true;
1510 mTranslateX += dx;
1511 mTranslateY += dy;
1512 insertRestoreToCount();
Romain Guy4aa90572010-09-26 18:40:37 -07001513 OpenGLRenderer::translate(dx, dy);
1514}
1515
1516void DisplayListRenderer::rotate(float degrees) {
Romain Guyb051e892010-09-28 19:09:36 -07001517 addOp(DisplayList::Rotate);
Romain Guy4aa90572010-09-26 18:40:37 -07001518 addFloat(degrees);
1519 OpenGLRenderer::rotate(degrees);
1520}
1521
1522void DisplayListRenderer::scale(float sx, float sy) {
Romain Guyb051e892010-09-28 19:09:36 -07001523 addOp(DisplayList::Scale);
Romain Guy4aa90572010-09-26 18:40:37 -07001524 addPoint(sx, sy);
1525 OpenGLRenderer::scale(sx, sy);
1526}
1527
Romain Guy807daf72011-01-18 11:19:19 -08001528void DisplayListRenderer::skew(float sx, float sy) {
1529 addOp(DisplayList::Skew);
1530 addPoint(sx, sy);
1531 OpenGLRenderer::skew(sx, sy);
1532}
1533
Romain Guy4aa90572010-09-26 18:40:37 -07001534void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001535 addOp(DisplayList::SetMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001536 addMatrix(matrix);
1537 OpenGLRenderer::setMatrix(matrix);
1538}
1539
1540void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -07001541 addOp(DisplayList::ConcatMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -07001542 addMatrix(matrix);
1543 OpenGLRenderer::concatMatrix(matrix);
1544}
1545
1546bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
1547 SkRegion::Op op) {
Romain Guyb051e892010-09-28 19:09:36 -07001548 addOp(DisplayList::ClipRect);
Romain Guy4aa90572010-09-26 18:40:37 -07001549 addBounds(left, top, right, bottom);
1550 addInt(op);
1551 return OpenGLRenderer::clipRect(left, top, right, bottom, op);
1552}
1553
Romain Guy65549432012-03-26 16:45:05 -07001554status_t DisplayListRenderer::drawDisplayList(DisplayList* displayList,
Chet Haase1271e2c2012-04-20 09:54:27 -07001555 Rect& dirty, int32_t flags, uint32_t level) {
Romain Guycabfcc12011-03-07 18:06:46 -08001556 // dirty is an out parameter and should not be recorded,
1557 // it matters only when replaying the display list
Chet Haaseb85967b2012-03-26 14:37:51 -07001558
1559 addOp(DisplayList::DrawDisplayList);
Romain Guy0fe478e2010-11-08 12:08:41 -08001560 addDisplayList(displayList);
Romain Guy33f6beb2012-02-16 19:24:51 -08001561 addInt(flags);
Romain Guy65549432012-03-26 16:45:05 -07001562 return DrawGlInfo::kStatusDone;
Romain Guy0fe478e2010-11-08 12:08:41 -08001563}
1564
Chet Haase48659092012-05-31 15:21:51 -07001565status_t DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
Romain Guy6c319ca2011-01-11 14:29:25 -08001566 addOp(DisplayList::DrawLayer);
Chet Haase603f6de2012-09-14 15:31:25 -07001567 addLayer(layer);
Romain Guyada830f2011-01-13 12:13:20 -08001568 addPoint(x, y);
Romain Guy6c319ca2011-01-11 14:29:25 -08001569 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001570 return DrawGlInfo::kStatusDone;
Romain Guy6c319ca2011-01-11 14:29:25 -08001571}
1572
Chet Haase48659092012-05-31 15:21:51 -07001573status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001574 const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
1575 uint32_t* location = addOp(DisplayList::DrawBitmap, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001576 addBitmap(bitmap);
1577 addPoint(left, top);
1578 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001579 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001580 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001581}
1582
Chet Haase48659092012-05-31 15:21:51 -07001583status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001584 Rect r(0.0f, 0.0f, bitmap->width(), bitmap->height());
1585 const mat4 transform(*matrix);
1586 transform.mapRect(r);
1587
1588 const bool reject = quickReject(r.left, r.top, r.right, r.bottom);
1589 uint32_t* location = addOp(DisplayList::DrawBitmapMatrix, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001590 addBitmap(bitmap);
1591 addMatrix(matrix);
1592 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001593 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001594 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001595}
1596
Chet Haase48659092012-05-31 15:21:51 -07001597status_t DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
Romain Guy4aa90572010-09-26 18:40:37 -07001598 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -07001599 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001600 const bool reject = quickReject(dstLeft, dstTop, dstRight, dstBottom);
1601 uint32_t* location = addOp(DisplayList::DrawBitmapRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001602 addBitmap(bitmap);
1603 addBounds(srcLeft, srcTop, srcRight, srcBottom);
1604 addBounds(dstLeft, dstTop, dstRight, dstBottom);
1605 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001606 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001607 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001608}
1609
Chet Haase48659092012-05-31 15:21:51 -07001610status_t DisplayListRenderer::drawBitmapData(SkBitmap* bitmap, float left, float top,
1611 SkPaint* paint) {
Romain Guy95c21d02012-07-17 17:46:03 -07001612 const bool reject = quickReject(left, top, left + bitmap->width(), top + bitmap->height());
Romain Guye651cc62012-05-14 19:44:40 -07001613 uint32_t* location = addOp(DisplayList::DrawBitmapData, reject);
1614 addBitmapData(bitmap);
1615 addPoint(left, top);
1616 addPaint(paint);
1617 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001618 return DrawGlInfo::kStatusDone;
Romain Guye651cc62012-05-14 19:44:40 -07001619}
1620
Chet Haase48659092012-05-31 15:21:51 -07001621status_t DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
Romain Guy5a7b4662011-01-20 19:09:30 -08001622 float* vertices, int* colors, SkPaint* paint) {
1623 addOp(DisplayList::DrawBitmapMesh);
1624 addBitmap(bitmap);
1625 addInt(meshWidth);
1626 addInt(meshHeight);
1627 addFloats(vertices, (meshWidth + 1) * (meshHeight + 1) * 2);
1628 if (colors) {
1629 addInt(1);
1630 addInts(colors, (meshWidth + 1) * (meshHeight + 1));
1631 } else {
1632 addInt(0);
1633 }
1634 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001635 return DrawGlInfo::kStatusDone;
Romain Guy5a7b4662011-01-20 19:09:30 -08001636}
1637
Chet Haase48659092012-05-31 15:21:51 -07001638status_t DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs,
1639 const int32_t* yDivs, const uint32_t* colors, uint32_t width, uint32_t height,
1640 int8_t numColors, float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guybe6f9dc2012-07-16 12:41:17 -07001641 int alpha;
1642 SkXfermode::Mode mode;
1643 OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode);
1644
Romain Guy33f6beb2012-02-16 19:24:51 -08001645 const bool reject = quickReject(left, top, right, bottom);
1646 uint32_t* location = addOp(DisplayList::DrawPatch, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001647 addBitmap(bitmap);
1648 addInts(xDivs, width);
1649 addInts(yDivs, height);
Romain Guy4bb94202010-10-12 15:59:26 -07001650 addUInts(colors, numColors);
Romain Guy4aa90572010-09-26 18:40:37 -07001651 addBounds(left, top, right, bottom);
Romain Guybe6f9dc2012-07-16 12:41:17 -07001652 addInt(alpha);
1653 addInt(mode);
Romain Guy33f6beb2012-02-16 19:24:51 -08001654 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001655 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001656}
1657
Chet Haase48659092012-05-31 15:21:51 -07001658status_t DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
Romain Guyb051e892010-09-28 19:09:36 -07001659 addOp(DisplayList::DrawColor);
Romain Guy4aa90572010-09-26 18:40:37 -07001660 addInt(color);
1661 addInt(mode);
Chet Haase48659092012-05-31 15:21:51 -07001662 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001663}
1664
Chet Haase48659092012-05-31 15:21:51 -07001665status_t DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -07001666 SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001667 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
1668 quickReject(left, top, right, bottom);
1669 uint32_t* location = addOp(DisplayList::DrawRect, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001670 addBounds(left, top, right, bottom);
1671 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001672 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001673 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001674}
1675
Chet Haase48659092012-05-31 15:21:51 -07001676status_t DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
Chet Haasea1cff502012-02-21 13:43:44 -08001677 float rx, float ry, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001678 const bool reject = paint->getStyle() == SkPaint::kFill_Style &&
1679 quickReject(left, top, right, bottom);
1680 uint32_t* location = addOp(DisplayList::DrawRoundRect, reject);
Romain Guy01d58e42011-01-19 21:54:02 -08001681 addBounds(left, top, right, bottom);
1682 addPoint(rx, ry);
1683 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001684 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001685 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001686}
1687
Chet Haase48659092012-05-31 15:21:51 -07001688status_t DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
Romain Guy01d58e42011-01-19 21:54:02 -08001689 addOp(DisplayList::DrawCircle);
1690 addPoint(x, y);
1691 addFloat(radius);
1692 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001693 return DrawGlInfo::kStatusDone;
Romain Guy01d58e42011-01-19 21:54:02 -08001694}
1695
Chet Haase48659092012-05-31 15:21:51 -07001696status_t DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001697 SkPaint* paint) {
1698 addOp(DisplayList::DrawOval);
1699 addBounds(left, top, right, bottom);
1700 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001701 return DrawGlInfo::kStatusDone;
Romain Guyc1cd9ba32011-01-23 14:18:41 -08001702}
1703
Chet Haase48659092012-05-31 15:21:51 -07001704status_t DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
Romain Guy8b2f5262011-01-23 16:15:02 -08001705 float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
Romain Guy82d41a52011-01-24 21:53:42 -08001706 addOp(DisplayList::DrawArc);
Romain Guy8b2f5262011-01-23 16:15:02 -08001707 addBounds(left, top, right, bottom);
1708 addPoint(startAngle, sweepAngle);
1709 addInt(useCenter ? 1 : 0);
1710 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001711 return DrawGlInfo::kStatusDone;
Romain Guy8b2f5262011-01-23 16:15:02 -08001712}
1713
Chet Haase48659092012-05-31 15:21:51 -07001714status_t DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
Romain Guy33f6beb2012-02-16 19:24:51 -08001715 float left, top, offset;
1716 uint32_t width, height;
1717 computePathBounds(path, paint, left, top, offset, width, height);
1718
Romain Guy95c21d02012-07-17 17:46:03 -07001719 left -= offset;
1720 top -= offset;
1721
1722 const bool reject = quickReject(left, top, left + width, top + height);
Romain Guy33f6beb2012-02-16 19:24:51 -08001723 uint32_t* location = addOp(DisplayList::DrawPath, reject);
Romain Guy4aa90572010-09-26 18:40:37 -07001724 addPath(path);
1725 addPaint(paint);
Romain Guy33f6beb2012-02-16 19:24:51 -08001726 addSkip(location);
Chet Haase48659092012-05-31 15:21:51 -07001727 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001728}
1729
Chet Haase48659092012-05-31 15:21:51 -07001730status_t DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -07001731 addOp(DisplayList::DrawLines);
Romain Guy4aa90572010-09-26 18:40:37 -07001732 addFloats(points, count);
1733 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001734 return DrawGlInfo::kStatusDone;
Romain Guy4aa90572010-09-26 18:40:37 -07001735}
1736
Chet Haase48659092012-05-31 15:21:51 -07001737status_t DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
Romain Guyed6fcb02011-03-21 13:11:28 -07001738 addOp(DisplayList::DrawPoints);
1739 addFloats(points, count);
1740 addPaint(paint);
Chet Haase48659092012-05-31 15:21:51 -07001741 return DrawGlInfo::kStatusDone;
Romain Guyed6fcb02011-03-21 13:11:28 -07001742}
1743
Chet Haase48659092012-05-31 15:21:51 -07001744status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, int count,
Romain Guy325740f2012-02-24 16:48:34 -08001745 SkPath* path, float hOffset, float vOffset, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001746 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001747 addOp(DisplayList::DrawTextOnPath);
1748 addText(text, bytesCount);
1749 addInt(count);
1750 addPath(path);
1751 addFloat(hOffset);
1752 addFloat(vOffset);
1753 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001754 SkPaint* addedPaint = addPaint(paint);
1755 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1756 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001757 return DrawGlInfo::kStatusDone;
Romain Guy325740f2012-02-24 16:48:34 -08001758}
1759
Chet Haase48659092012-05-31 15:21:51 -07001760status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int count,
Romain Guyeb9a5362012-01-17 17:39:26 -08001761 const float* positions, SkPaint* paint) {
Chet Haase48659092012-05-31 15:21:51 -07001762 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001763 addOp(DisplayList::DrawPosText);
1764 addText(text, bytesCount);
1765 addInt(count);
1766 addFloats(positions, count * 2);
1767 paint->setAntiAlias(true);
Chet Haasee816bae2012-08-09 13:39:02 -07001768 SkPaint* addedPaint = addPaint(paint);
1769 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1770 fontRenderer.precache(addedPaint, text, count);
Chet Haase48659092012-05-31 15:21:51 -07001771 return DrawGlInfo::kStatusDone;
Romain Guyeb9a5362012-01-17 17:39:26 -08001772}
1773
Romain Guyc2525952012-07-27 16:41:22 -07001774status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
Raph Levien996e57c2012-07-23 15:22:52 -07001775 float x, float y, const float* positions, SkPaint* paint, float length) {
1776 if (!text || count <= 0) return DrawGlInfo::kStatusDone;
1777
1778 // TODO: We should probably make a copy of the paint instead of modifying
1779 // it; modifying the paint will change its generationID the first
1780 // time, which might impact caches. More investigation needed to
1781 // see if it matters.
1782 // If we make a copy, then drawTextDecorations() should *not* make
1783 // its own copy as it does right now.
1784 // Beware: this needs Glyph encoding (already done on the Paint constructor)
1785 paint->setAntiAlias(true);
1786 if (length < 0.0f) length = paint->measureText(text, bytesCount);
1787
1788 bool reject = false;
1789 if (CC_LIKELY(paint->getTextAlign() == SkPaint::kLeft_Align)) {
1790 SkPaint::FontMetrics metrics;
1791 paint->getFontMetrics(&metrics, 0.0f);
1792 reject = quickReject(x, y + metrics.fTop, x + length, y + metrics.fBottom);
1793 }
1794
Romain Guyc2525952012-07-27 16:41:22 -07001795 uint32_t* location = addOp(DisplayList::DrawText, reject);
Raph Levien996e57c2012-07-23 15:22:52 -07001796 addText(text, bytesCount);
1797 addInt(count);
1798 addFloat(x);
1799 addFloat(y);
1800 addFloats(positions, count * 2);
Chet Haasee816bae2012-08-09 13:39:02 -07001801 SkPaint* addedPaint = addPaint(paint);
1802 if (!reject) {
1803 FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
1804 fontRenderer.precache(addedPaint, text, count);
1805 }
Raph Levien996e57c2012-07-23 15:22:52 -07001806 addFloat(length);
1807 addSkip(location);
1808 return DrawGlInfo::kStatusDone;
1809}
1810
Romain Guy4aa90572010-09-26 18:40:37 -07001811void DisplayListRenderer::resetShader() {
Romain Guyb051e892010-09-28 19:09:36 -07001812 addOp(DisplayList::ResetShader);
Romain Guy4aa90572010-09-26 18:40:37 -07001813}
1814
1815void DisplayListRenderer::setupShader(SkiaShader* shader) {
Chet Haase5c13d892010-10-08 08:37:55 -07001816 addOp(DisplayList::SetupShader);
1817 addShader(shader);
Romain Guy4aa90572010-09-26 18:40:37 -07001818}
1819
1820void DisplayListRenderer::resetColorFilter() {
Romain Guyb051e892010-09-28 19:09:36 -07001821 addOp(DisplayList::ResetColorFilter);
Romain Guy4aa90572010-09-26 18:40:37 -07001822}
1823
1824void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
Chet Haasead93c2b2010-10-22 16:17:12 -07001825 addOp(DisplayList::SetupColorFilter);
1826 addColorFilter(filter);
Romain Guy4aa90572010-09-26 18:40:37 -07001827}
1828
1829void DisplayListRenderer::resetShadow() {
Romain Guyb051e892010-09-28 19:09:36 -07001830 addOp(DisplayList::ResetShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001831}
1832
1833void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
Romain Guyb051e892010-09-28 19:09:36 -07001834 addOp(DisplayList::SetupShadow);
Romain Guy4aa90572010-09-26 18:40:37 -07001835 addFloat(radius);
1836 addPoint(dx, dy);
1837 addInt(color);
Romain Guy4aa90572010-09-26 18:40:37 -07001838}
1839
Romain Guy5ff9df62012-01-23 17:09:05 -08001840void DisplayListRenderer::resetPaintFilter() {
1841 addOp(DisplayList::ResetPaintFilter);
1842}
1843
1844void DisplayListRenderer::setupPaintFilter(int clearBits, int setBits) {
1845 addOp(DisplayList::SetupPaintFilter);
1846 addInt(clearBits);
1847 addInt(setBits);
1848}
1849
Romain Guy4aa90572010-09-26 18:40:37 -07001850}; // namespace uirenderer
1851}; // namespace android