blob: 34dda9a71bc67a0f0e6dc4a36f1f44ad49b30551 [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
Chet Haase9c1e23b2011-03-24 10:51:31 -070019
20#include "DisplayListLogBuffer.h"
Romain Guy4aa90572010-09-26 18:40:37 -070021#include "DisplayListRenderer.h"
Chet Haase9c1e23b2011-03-24 10:51:31 -070022#include <utils/String8.h>
23#include "Caches.h"
Romain Guy4aa90572010-09-26 18:40:37 -070024
25namespace android {
26namespace uirenderer {
27
Chet Haase9c1e23b2011-03-24 10:51:31 -070028
Romain Guy4aa90572010-09-26 18:40:37 -070029///////////////////////////////////////////////////////////////////////////////
Romain Guyb051e892010-09-28 19:09:36 -070030// Display list
31///////////////////////////////////////////////////////////////////////////////
32
Romain Guyffac7fc2011-01-13 17:21:49 -080033const char* DisplayList::OP_NAMES[] = {
Romain Guyffac7fc2011-01-13 17:21:49 -080034 "Save",
35 "Restore",
36 "RestoreToCount",
37 "SaveLayer",
38 "SaveLayerAlpha",
39 "Translate",
40 "Rotate",
41 "Scale",
Romain Guy4cf6e2f2011-01-23 11:35:13 -080042 "Skew",
Romain Guyffac7fc2011-01-13 17:21:49 -080043 "SetMatrix",
44 "ConcatMatrix",
45 "ClipRect",
46 "DrawDisplayList",
47 "DrawLayer",
48 "DrawBitmap",
49 "DrawBitmapMatrix",
50 "DrawBitmapRect",
Romain Guy5a7b4662011-01-20 19:09:30 -080051 "DrawBitmapMesh",
Romain Guyffac7fc2011-01-13 17:21:49 -080052 "DrawPatch",
53 "DrawColor",
54 "DrawRect",
Romain Guy01d58e42011-01-19 21:54:02 -080055 "DrawRoundRect",
56 "DrawCircle",
Romain Guyc1cd9ba32011-01-23 14:18:41 -080057 "DrawOval",
Romain Guy8b2f5262011-01-23 16:15:02 -080058 "DrawArc",
Romain Guyffac7fc2011-01-13 17:21:49 -080059 "DrawPath",
60 "DrawLines",
Romain Guyed6fcb02011-03-21 13:11:28 -070061 "DrawPoints",
Romain Guyffac7fc2011-01-13 17:21:49 -080062 "DrawText",
63 "ResetShader",
64 "SetupShader",
65 "ResetColorFilter",
66 "SetupColorFilter",
67 "ResetShadow",
Chet Haasedaf98e92011-01-10 14:10:36 -080068 "SetupShadow",
69 "DrawGLFunction"
Romain Guyffac7fc2011-01-13 17:21:49 -080070};
71
Chet Haase9c1e23b2011-03-24 10:51:31 -070072void DisplayList::outputLogBuffer(int fd) {
73 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
74 if (logBuffer.isEmpty()) {
75 return;
76 }
77 String8 cachesLog;
78 Caches::getInstance().dumpMemoryUsage(cachesLog);
79 FILE *file = fdopen(fd, "a");
80 fprintf(file, "\nCaches:\n%s", cachesLog.string());
81 fprintf(file, "\nRecent DisplayList operations\n");
82 logBuffer.outputCommands(file, OP_NAMES);
83 fflush(file);
84}
85
Romain Guyb051e892010-09-28 19:09:36 -070086DisplayList::DisplayList(const DisplayListRenderer& recorder) {
Chet Haase5977baa2011-01-05 18:01:22 -080087 initFromDisplayListRenderer(recorder);
88}
89
90DisplayList::~DisplayList() {
Chet Haased63cbd12011-02-03 16:32:46 -080091 clearResources();
92}
93
94void DisplayList::clearResources() {
Chet Haase5977baa2011-01-05 18:01:22 -080095 sk_free((void*) mReader.base());
96
97 Caches& caches = Caches::getInstance();
98
99 for (size_t i = 0; i < mBitmapResources.size(); i++) {
100 caches.resourceCache.decrementRefcount(mBitmapResources.itemAt(i));
101 }
102 mBitmapResources.clear();
103
Romain Guy24c00212011-01-14 15:31:00 -0800104 for (size_t i = 0; i < mShaders.size(); i++) {
Romain Guy43ccf462011-01-14 18:51:01 -0800105 caches.resourceCache.decrementRefcount(mShaders.itemAt(i));
Chet Haase5977baa2011-01-05 18:01:22 -0800106 }
Romain Guy24c00212011-01-14 15:31:00 -0800107 mShaders.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800108
109 for (size_t i = 0; i < mPaints.size(); i++) {
110 delete mPaints.itemAt(i);
111 }
112 mPaints.clear();
113
Romain Guy2fc941e2011-02-03 15:06:05 -0800114 for (size_t i = 0; i < mPaths.size(); i++) {
Romain Guy1af23a32011-03-24 16:03:55 -0700115 SkPath* path = mPaths.itemAt(i);
116 caches.pathCache.remove(path);
117 delete path;
Romain Guy2fc941e2011-02-03 15:06:05 -0800118 }
119 mPaths.clear();
120
Chet Haase5977baa2011-01-05 18:01:22 -0800121 for (size_t i = 0; i < mMatrices.size(); i++) {
122 delete mMatrices.itemAt(i);
123 }
124 mMatrices.clear();
Chet Haase5977baa2011-01-05 18:01:22 -0800125}
126
Chet Haased63cbd12011-02-03 16:32:46 -0800127void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing) {
Romain Guyb051e892010-09-28 19:09:36 -0700128 const SkWriter32& writer = recorder.writeStream();
129 init();
130
131 if (writer.size() == 0) {
132 return;
133 }
134
Chet Haased63cbd12011-02-03 16:32:46 -0800135 if (reusing) {
136 // re-using display list - clear out previous allocations
137 clearResources();
138 }
139
Romain Guyb051e892010-09-28 19:09:36 -0700140 size_t size = writer.size();
141 void* buffer = sk_malloc_throw(size);
142 writer.flatten(buffer);
143 mReader.setMemory(buffer, size);
144
Chet Haase5c13d892010-10-08 08:37:55 -0700145 Caches& caches = Caches::getInstance();
Romain Guyb051e892010-09-28 19:09:36 -0700146
Chet Haase5c13d892010-10-08 08:37:55 -0700147 const Vector<SkBitmap*> &bitmapResources = recorder.getBitmapResources();
148 for (size_t i = 0; i < bitmapResources.size(); i++) {
149 SkBitmap* resource = bitmapResources.itemAt(i);
150 mBitmapResources.add(resource);
151 caches.resourceCache.incrementRefcount(resource);
Romain Guyb051e892010-09-28 19:09:36 -0700152 }
Chet Haased98aa2d2010-10-25 15:47:32 -0700153
Romain Guy24c00212011-01-14 15:31:00 -0800154 const Vector<SkiaShader*> &shaders = recorder.getShaders();
155 for (size_t i = 0; i < shaders.size(); i++) {
Romain Guy43ccf462011-01-14 18:51:01 -0800156 SkiaShader* shader = shaders.itemAt(i);
157 mShaders.add(shader);
158 caches.resourceCache.incrementRefcount(shader);
Romain Guyb051e892010-09-28 19:09:36 -0700159 }
160
Chet Haased98aa2d2010-10-25 15:47:32 -0700161 const Vector<SkPaint*> &paints = recorder.getPaints();
162 for (size_t i = 0; i < paints.size(); i++) {
163 mPaints.add(paints.itemAt(i));
164 }
165
Romain Guy2fc941e2011-02-03 15:06:05 -0800166 const Vector<SkPath*> &paths = recorder.getPaths();
167 for (size_t i = 0; i < paths.size(); i++) {
168 mPaths.add(paths.itemAt(i));
169 }
170
Chet Haased98aa2d2010-10-25 15:47:32 -0700171 const Vector<SkMatrix*> &matrices = recorder.getMatrices();
172 for (size_t i = 0; i < matrices.size(); i++) {
173 mMatrices.add(matrices.itemAt(i));
174 }
Romain Guyb051e892010-09-28 19:09:36 -0700175}
176
Romain Guyb051e892010-09-28 19:09:36 -0700177void DisplayList::init() {
Romain Guyb051e892010-09-28 19:09:36 -0700178}
179
Romain Guycabfcc12011-03-07 18:06:46 -0800180bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level) {
Chet Haasedaf98e92011-01-10 14:10:36 -0800181 bool needsInvalidate = false;
Romain Guyb051e892010-09-28 19:09:36 -0700182 TextContainer text;
183 mReader.rewind();
184
Romain Guyffac7fc2011-01-13 17:21:49 -0800185#if DEBUG_DISPLAY_LIST
186 uint32_t count = (level + 1) * 2;
187 char indent[count + 1];
188 for (uint32_t i = 0; i < count; i++) {
189 indent[i] = ' ';
190 }
191 indent[count] = '\0';
192 DISPLAY_LIST_LOGD("%sStart display list (%p)", (char*) indent + 2, this);
193#endif
Romain Guyb051e892010-09-28 19:09:36 -0700194
Chet Haase9c1e23b2011-03-24 10:51:31 -0700195 DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance();
Romain Guyffac7fc2011-01-13 17:21:49 -0800196 int saveCount = renderer.getSaveCount() - 1;
Romain Guyb051e892010-09-28 19:09:36 -0700197 while (!mReader.eof()) {
Romain Guy5b3b3522010-10-27 18:57:51 -0700198 int op = mReader.readInt();
Chet Haase9c1e23b2011-03-24 10:51:31 -0700199 logBuffer.writeCommand(level, op);
Romain Guyffac7fc2011-01-13 17:21:49 -0800200
Romain Guy5b3b3522010-10-27 18:57:51 -0700201 switch (op) {
Chet Haasedaf98e92011-01-10 14:10:36 -0800202 case DrawGLFunction: {
203 Functor *functor = (Functor *) getInt();
204 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], functor);
Romain Guycabfcc12011-03-07 18:06:46 -0800205 needsInvalidate |= renderer.callDrawGLFunction(functor, dirty);
Chet Haasedaf98e92011-01-10 14:10:36 -0800206 }
207 break;
Romain Guyb051e892010-09-28 19:09:36 -0700208 case Save: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800209 int rendererNum = getInt();
210 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], rendererNum);
211 renderer.save(rendererNum);
Romain Guyb051e892010-09-28 19:09:36 -0700212 }
213 break;
214 case Restore: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800215 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700216 renderer.restore();
217 }
218 break;
219 case RestoreToCount: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800220 int restoreCount = saveCount + getInt();
221 DISPLAY_LIST_LOGD("%s%s %d", (char*) indent, OP_NAMES[op], restoreCount);
222 renderer.restoreToCount(restoreCount);
Romain Guyb051e892010-09-28 19:09:36 -0700223 }
224 break;
225 case SaveLayer: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800226 float f1 = getFloat();
227 float f2 = getFloat();
228 float f3 = getFloat();
229 float f4 = getFloat();
230 SkPaint* paint = getPaint();
231 int flags = getInt();
232 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p, 0x%x", (char*) indent,
233 OP_NAMES[op], f1, f2, f3, f4, paint, flags);
234 renderer.saveLayer(f1, f2, f3, f4, paint, flags);
Romain Guyb051e892010-09-28 19:09:36 -0700235 }
236 break;
Romain Guy5b3b3522010-10-27 18:57:51 -0700237 case SaveLayerAlpha: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800238 float f1 = getFloat();
239 float f2 = getFloat();
240 float f3 = getFloat();
241 float f4 = getFloat();
242 int alpha = getInt();
243 int flags = getInt();
244 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", (char*) indent,
245 OP_NAMES[op], f1, f2, f3, f4, alpha, flags);
246 renderer.saveLayerAlpha(f1, f2, f3, f4, alpha, flags);
Romain Guy5b3b3522010-10-27 18:57:51 -0700247 }
248 break;
Romain Guyb051e892010-09-28 19:09:36 -0700249 case Translate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800250 float f1 = getFloat();
251 float f2 = getFloat();
252 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], f1, f2);
253 renderer.translate(f1, f2);
Romain Guyb051e892010-09-28 19:09:36 -0700254 }
255 break;
256 case Rotate: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800257 float rotation = getFloat();
258 DISPLAY_LIST_LOGD("%s%s %.2f", (char*) indent, OP_NAMES[op], rotation);
259 renderer.rotate(rotation);
Romain Guyb051e892010-09-28 19:09:36 -0700260 }
261 break;
262 case Scale: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800263 float sx = getFloat();
264 float sy = getFloat();
265 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
266 renderer.scale(sx, sy);
Romain Guyb051e892010-09-28 19:09:36 -0700267 }
268 break;
Romain Guy807daf72011-01-18 11:19:19 -0800269 case Skew: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800270 float sx = getFloat();
271 float sy = getFloat();
272 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f", (char*) indent, OP_NAMES[op], sx, sy);
273 renderer.skew(sx, sy);
Romain Guy807daf72011-01-18 11:19:19 -0800274 }
275 break;
Romain Guyb051e892010-09-28 19:09:36 -0700276 case SetMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800277 SkMatrix* matrix = getMatrix();
278 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
279 renderer.setMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -0700280 }
281 break;
282 case ConcatMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800283 SkMatrix* matrix = getMatrix();
284 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], matrix);
285 renderer.concatMatrix(matrix);
Romain Guyb051e892010-09-28 19:09:36 -0700286 }
287 break;
288 case ClipRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800289 float f1 = getFloat();
290 float f2 = getFloat();
291 float f3 = getFloat();
292 float f4 = getFloat();
293 int regionOp = getInt();
294 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d", (char*) indent, OP_NAMES[op],
295 f1, f2, f3, f4, regionOp);
296 renderer.clipRect(f1, f2, f3, f4, (SkRegion::Op) regionOp);
Romain Guyb051e892010-09-28 19:09:36 -0700297 }
298 break;
Romain Guy0fe478e2010-11-08 12:08:41 -0800299 case DrawDisplayList: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800300 DisplayList* displayList = getDisplayList();
Romain Guy7b5b6ab2011-03-14 18:05:08 -0700301 uint32_t width = getUInt();
302 uint32_t height = getUInt();
303 DISPLAY_LIST_LOGD("%s%s %p, %dx%d, %d", (char*) indent, OP_NAMES[op],
304 displayList, width, height, level + 1);
305 needsInvalidate |= renderer.drawDisplayList(displayList, width, height,
306 dirty, level + 1);
Romain Guy0fe478e2010-11-08 12:08:41 -0800307 }
308 break;
Romain Guy6c319ca2011-01-11 14:29:25 -0800309 case DrawLayer: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800310 Layer* layer = (Layer*) getInt();
311 float x = getFloat();
312 float y = getFloat();
313 SkPaint* paint = getPaint();
314 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
315 layer, x, y, paint);
316 renderer.drawLayer(layer, x, y, paint);
Romain Guy6c319ca2011-01-11 14:29:25 -0800317 }
318 break;
Romain Guyb051e892010-09-28 19:09:36 -0700319 case DrawBitmap: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800320 SkBitmap* bitmap = getBitmap();
321 float x = getFloat();
322 float y = getFloat();
323 SkPaint* paint = getPaint();
324 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
325 bitmap, x, y, paint);
326 renderer.drawBitmap(bitmap, x, y, paint);
Romain Guyb051e892010-09-28 19:09:36 -0700327 }
328 break;
329 case DrawBitmapMatrix: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800330 SkBitmap* bitmap = getBitmap();
331 SkMatrix* matrix = getMatrix();
332 SkPaint* paint = getPaint();
333 DISPLAY_LIST_LOGD("%s%s %p, %p, %p", (char*) indent, OP_NAMES[op],
334 bitmap, matrix, paint);
335 renderer.drawBitmap(bitmap, matrix, paint);
Romain Guyb051e892010-09-28 19:09:36 -0700336 }
337 break;
338 case DrawBitmapRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800339 SkBitmap* bitmap = getBitmap();
340 float f1 = getFloat();
341 float f2 = getFloat();
342 float f3 = getFloat();
343 float f4 = getFloat();
344 float f5 = getFloat();
345 float f6 = getFloat();
346 float f7 = getFloat();
347 float f8 = getFloat();
348 SkPaint* paint = getPaint();
349 DISPLAY_LIST_LOGD("%s%s %p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
350 (char*) indent, OP_NAMES[op], bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
351 renderer.drawBitmap(bitmap, f1, f2, f3, f4, f5, f6, f7, f8, paint);
Romain Guyb051e892010-09-28 19:09:36 -0700352 }
353 break;
Romain Guy5a7b4662011-01-20 19:09:30 -0800354 case DrawBitmapMesh: {
355 int verticesCount = 0;
356 uint32_t colorsCount = 0;
357
358 SkBitmap* bitmap = getBitmap();
359 uint32_t meshWidth = getInt();
360 uint32_t meshHeight = getInt();
361 float* vertices = getFloats(verticesCount);
362 bool hasColors = getInt();
363 int* colors = hasColors ? getInts(colorsCount) : NULL;
364
Chet Haasedaf98e92011-01-10 14:10:36 -0800365 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guy5a7b4662011-01-20 19:09:30 -0800366 renderer.drawBitmapMesh(bitmap, meshWidth, meshHeight, vertices, colors, getPaint());
367 }
Romain Guya566b7c2011-01-23 16:36:11 -0800368 break;
Romain Guyb051e892010-09-28 19:09:36 -0700369 case DrawPatch: {
370 int32_t* xDivs = NULL;
371 int32_t* yDivs = NULL;
Romain Guy4bb94202010-10-12 15:59:26 -0700372 uint32_t* colors = NULL;
Romain Guyb051e892010-09-28 19:09:36 -0700373 uint32_t xDivsCount = 0;
374 uint32_t yDivsCount = 0;
Romain Guy4bb94202010-10-12 15:59:26 -0700375 int8_t numColors = 0;
Romain Guyb051e892010-09-28 19:09:36 -0700376
377 SkBitmap* bitmap = getBitmap();
378
379 xDivs = getInts(xDivsCount);
380 yDivs = getInts(yDivsCount);
Romain Guy4bb94202010-10-12 15:59:26 -0700381 colors = getUInts(numColors);
Romain Guyb051e892010-09-28 19:09:36 -0700382
Chet Haasedaf98e92011-01-10 14:10:36 -0800383 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guy4bb94202010-10-12 15:59:26 -0700384 renderer.drawPatch(bitmap, xDivs, yDivs, colors, xDivsCount, yDivsCount,
385 numColors, getFloat(), getFloat(), getFloat(), getFloat(), getPaint());
Romain Guyb051e892010-09-28 19:09:36 -0700386 }
387 break;
388 case DrawColor: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800389 int color = getInt();
390 int xferMode = getInt();
391 DISPLAY_LIST_LOGD("%s%s 0x%x %d", (char*) indent, OP_NAMES[op], color, xferMode);
392 renderer.drawColor(color, (SkXfermode::Mode) xferMode);
Romain Guyb051e892010-09-28 19:09:36 -0700393 }
394 break;
395 case DrawRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800396 float f1 = getFloat();
397 float f2 = getFloat();
398 float f3 = getFloat();
399 float f4 = getFloat();
400 SkPaint* paint = getPaint();
401 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
402 f1, f2, f3, f4, paint);
403 renderer.drawRect(f1, f2, f3, f4, paint);
Romain Guyb051e892010-09-28 19:09:36 -0700404 }
405 break;
Romain Guy01d58e42011-01-19 21:54:02 -0800406 case DrawRoundRect: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800407 float f1 = getFloat();
408 float f2 = getFloat();
409 float f3 = getFloat();
410 float f4 = getFloat();
411 float f5 = getFloat();
412 float f6 = getFloat();
413 SkPaint* paint = getPaint();
414 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p",
415 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, paint);
416 renderer.drawRoundRect(f1, f2, f3, f4, f5, f6, paint);
Romain Guy01d58e42011-01-19 21:54:02 -0800417 }
418 break;
419 case DrawCircle: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800420 float f1 = getFloat();
421 float f2 = getFloat();
422 float f3 = getFloat();
423 SkPaint* paint = getPaint();
424 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %p",
425 (char*) indent, OP_NAMES[op], f1, f2, f3, paint);
426 renderer.drawCircle(f1, f2, f3, paint);
Romain Guy01d58e42011-01-19 21:54:02 -0800427 }
428 break;
Romain Guyc1cd9ba32011-01-23 14:18:41 -0800429 case DrawOval: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800430 float f1 = getFloat();
431 float f2 = getFloat();
432 float f3 = getFloat();
433 float f4 = getFloat();
434 SkPaint* paint = getPaint();
435 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %p",
436 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, paint);
437 renderer.drawOval(f1, f2, f3, f4, paint);
Romain Guyc1cd9ba32011-01-23 14:18:41 -0800438 }
439 break;
Romain Guy8b2f5262011-01-23 16:15:02 -0800440 case DrawArc: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800441 float f1 = getFloat();
442 float f2 = getFloat();
443 float f3 = getFloat();
444 float f4 = getFloat();
445 float f5 = getFloat();
446 float f6 = getFloat();
447 int i1 = getInt();
448 SkPaint* paint = getPaint();
449 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %p",
450 (char*) indent, OP_NAMES[op], f1, f2, f3, f4, f5, f6, i1, paint);
451 renderer.drawArc(f1, f2, f3, f4, f5, f6, i1 == 1, paint);
Romain Guy8b2f5262011-01-23 16:15:02 -0800452 }
453 break;
Romain Guyb051e892010-09-28 19:09:36 -0700454 case DrawPath: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800455 SkPath* path = getPath();
456 SkPaint* paint = getPaint();
457 DISPLAY_LIST_LOGD("%s%s %p, %p", (char*) indent, OP_NAMES[op], path, paint);
458 renderer.drawPath(path, paint);
Romain Guyb051e892010-09-28 19:09:36 -0700459 }
460 break;
461 case DrawLines: {
462 int count = 0;
463 float* points = getFloats(count);
Chet Haasedaf98e92011-01-10 14:10:36 -0800464 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700465 renderer.drawLines(points, count, getPaint());
466 }
467 break;
Romain Guyed6fcb02011-03-21 13:11:28 -0700468 case DrawPoints: {
469 int count = 0;
470 float* points = getFloats(count);
471 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
472 renderer.drawPoints(points, count, getPaint());
473 }
474 break;
Romain Guyb051e892010-09-28 19:09:36 -0700475 case DrawText: {
476 getText(&text);
Chet Haasedaf98e92011-01-10 14:10:36 -0800477 int count = getInt();
478 float x = getFloat();
479 float y = getFloat();
480 SkPaint* paint = getPaint();
481 DISPLAY_LIST_LOGD("%s%s %s, %d, %d, %.2f, %.2f, %p", (char*) indent, OP_NAMES[op],
482 text.text(), text.length(), count, x, y, paint);
483 renderer.drawText(text.text(), text.length(), count, x, y, paint);
Romain Guyb051e892010-09-28 19:09:36 -0700484 }
485 break;
486 case ResetShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800487 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700488 renderer.resetShader();
489 }
490 break;
491 case SetupShader: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800492 SkiaShader* shader = getShader();
493 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], shader);
494 renderer.setupShader(shader);
Romain Guyb051e892010-09-28 19:09:36 -0700495 }
496 break;
497 case ResetColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800498 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700499 renderer.resetColorFilter();
500 }
501 break;
502 case SetupColorFilter: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800503 SkiaColorFilter *colorFilter = getColorFilter();
504 DISPLAY_LIST_LOGD("%s%s %p", (char*) indent, OP_NAMES[op], colorFilter);
505 renderer.setupColorFilter(colorFilter);
Romain Guyb051e892010-09-28 19:09:36 -0700506 }
507 break;
508 case ResetShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800509 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
Romain Guyb051e892010-09-28 19:09:36 -0700510 renderer.resetShadow();
511 }
512 break;
513 case SetupShadow: {
Chet Haasedaf98e92011-01-10 14:10:36 -0800514 float radius = getFloat();
515 float dx = getFloat();
516 float dy = getFloat();
517 int color = getInt();
518 DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, 0x%x", (char*) indent, OP_NAMES[op],
519 radius, dx, dy, color);
520 renderer.setupShadow(radius, dx, dy, color);
Romain Guyb051e892010-09-28 19:09:36 -0700521 }
522 break;
Chet Haasedaf98e92011-01-10 14:10:36 -0800523 default:
524 DISPLAY_LIST_LOGD("Display List error: op not handled: %s%s",
525 (char*) indent, OP_NAMES[op]);
526 break;
Romain Guyb051e892010-09-28 19:09:36 -0700527 }
528 }
Romain Guyffac7fc2011-01-13 17:21:49 -0800529
Chet Haasedaf98e92011-01-10 14:10:36 -0800530 DISPLAY_LIST_LOGD("%sDone, returning %d", (char*) indent + 2, needsInvalidate);
531 return needsInvalidate;
Romain Guyb051e892010-09-28 19:09:36 -0700532}
533
534///////////////////////////////////////////////////////////////////////////////
Romain Guy4aa90572010-09-26 18:40:37 -0700535// Base structure
536///////////////////////////////////////////////////////////////////////////////
537
Romain Guy2fc941e2011-02-03 15:06:05 -0800538DisplayListRenderer::DisplayListRenderer(): mWriter(MIN_WRITER_SIZE) {
Chet Haase5977baa2011-01-05 18:01:22 -0800539 mDisplayList = NULL;
Romain Guy4aa90572010-09-26 18:40:37 -0700540}
541
542DisplayListRenderer::~DisplayListRenderer() {
543 reset();
544}
545
546void DisplayListRenderer::reset() {
Romain Guy4aa90572010-09-26 18:40:37 -0700547 mWriter.reset();
Chet Haase5c13d892010-10-08 08:37:55 -0700548
549 Caches& caches = Caches::getInstance();
550 for (size_t i = 0; i < mBitmapResources.size(); i++) {
551 SkBitmap* resource = mBitmapResources.itemAt(i);
552 caches.resourceCache.decrementRefcount(resource);
553 }
554 mBitmapResources.clear();
Chet Haased98aa2d2010-10-25 15:47:32 -0700555
Romain Guy43ccf462011-01-14 18:51:01 -0800556 for (size_t i = 0; i < mShaders.size(); i++) {
557 caches.resourceCache.decrementRefcount(mShaders.itemAt(i));
558 }
Romain Guy24c00212011-01-14 15:31:00 -0800559 mShaders.clear();
560 mShaderMap.clear();
Romain Guy43ccf462011-01-14 18:51:01 -0800561
562 mPaints.clear();
563 mPaintMap.clear();
Romain Guy2fc941e2011-02-03 15:06:05 -0800564 mPaths.clear();
565 mPathMap.clear();
Chet Haased98aa2d2010-10-25 15:47:32 -0700566 mMatrices.clear();
Romain Guy4aa90572010-09-26 18:40:37 -0700567}
568
569///////////////////////////////////////////////////////////////////////////////
570// Operations
571///////////////////////////////////////////////////////////////////////////////
572
Chet Haase5977baa2011-01-05 18:01:22 -0800573DisplayList* DisplayListRenderer::getDisplayList() {
574 if (mDisplayList == NULL) {
575 mDisplayList = new DisplayList(*this);
576 } else {
Chet Haased63cbd12011-02-03 16:32:46 -0800577 mDisplayList->initFromDisplayListRenderer(*this, true);
Chet Haase5977baa2011-01-05 18:01:22 -0800578 }
579 return mDisplayList;
580}
581
Romain Guyb051e892010-09-28 19:09:36 -0700582void DisplayListRenderer::setViewport(int width, int height) {
583 mOrthoMatrix.loadOrtho(0, width, height, 0, -1, 1);
584
585 mWidth = width;
586 mHeight = height;
587}
588
Romain Guy7d7b5492011-01-24 16:33:45 -0800589void DisplayListRenderer::prepareDirty(float left, float top,
590 float right, float bottom, bool opaque) {
Romain Guyb051e892010-09-28 19:09:36 -0700591 mSnapshot = new Snapshot(mFirstSnapshot,
592 SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
593 mSaveCount = 1;
594 mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
Romain Guy27454a42011-01-23 12:01:41 -0800595 mRestoreSaveCount = -1;
596}
597
598void DisplayListRenderer::finish() {
599 insertRestoreToCount();
600 OpenGLRenderer::finish();
Romain Guyb051e892010-09-28 19:09:36 -0700601}
602
Chet Haasedaf98e92011-01-10 14:10:36 -0800603void DisplayListRenderer::interrupt() {
Chet Haasedaf98e92011-01-10 14:10:36 -0800604}
Romain Guy2b1847e2011-01-26 13:43:01 -0800605
Chet Haasedaf98e92011-01-10 14:10:36 -0800606void DisplayListRenderer::resume() {
Romain Guy4aa90572010-09-26 18:40:37 -0700607}
608
Romain Guycabfcc12011-03-07 18:06:46 -0800609bool DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
610 // Ignore dirty during recording, it matters only when we replay
Chet Haasedaf98e92011-01-10 14:10:36 -0800611 addOp(DisplayList::DrawGLFunction);
612 addInt((int) functor);
613 return false; // No invalidate needed at record-time
614}
615
Romain Guy4aa90572010-09-26 18:40:37 -0700616int DisplayListRenderer::save(int flags) {
Romain Guyb051e892010-09-28 19:09:36 -0700617 addOp(DisplayList::Save);
Romain Guy4aa90572010-09-26 18:40:37 -0700618 addInt(flags);
619 return OpenGLRenderer::save(flags);
620}
621
622void DisplayListRenderer::restore() {
Romain Guyb051e892010-09-28 19:09:36 -0700623 addOp(DisplayList::Restore);
Romain Guy4aa90572010-09-26 18:40:37 -0700624 OpenGLRenderer::restore();
625}
626
627void DisplayListRenderer::restoreToCount(int saveCount) {
Romain Guy27454a42011-01-23 12:01:41 -0800628 mRestoreSaveCount = saveCount;
Romain Guy4aa90572010-09-26 18:40:37 -0700629 OpenGLRenderer::restoreToCount(saveCount);
630}
631
632int DisplayListRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -0700633 SkPaint* p, int flags) {
Romain Guyb051e892010-09-28 19:09:36 -0700634 addOp(DisplayList::SaveLayer);
Romain Guy4aa90572010-09-26 18:40:37 -0700635 addBounds(left, top, right, bottom);
636 addPaint(p);
637 addInt(flags);
Romain Guyb051e892010-09-28 19:09:36 -0700638 return OpenGLRenderer::save(flags);
Romain Guy4aa90572010-09-26 18:40:37 -0700639}
640
Romain Guy5b3b3522010-10-27 18:57:51 -0700641int DisplayListRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
642 int alpha, int flags) {
643 addOp(DisplayList::SaveLayerAlpha);
644 addBounds(left, top, right, bottom);
645 addInt(alpha);
646 addInt(flags);
647 return OpenGLRenderer::save(flags);
648}
649
Romain Guy4aa90572010-09-26 18:40:37 -0700650void DisplayListRenderer::translate(float dx, float dy) {
Romain Guyb051e892010-09-28 19:09:36 -0700651 addOp(DisplayList::Translate);
Romain Guy4aa90572010-09-26 18:40:37 -0700652 addPoint(dx, dy);
653 OpenGLRenderer::translate(dx, dy);
654}
655
656void DisplayListRenderer::rotate(float degrees) {
Romain Guyb051e892010-09-28 19:09:36 -0700657 addOp(DisplayList::Rotate);
Romain Guy4aa90572010-09-26 18:40:37 -0700658 addFloat(degrees);
659 OpenGLRenderer::rotate(degrees);
660}
661
662void DisplayListRenderer::scale(float sx, float sy) {
Romain Guyb051e892010-09-28 19:09:36 -0700663 addOp(DisplayList::Scale);
Romain Guy4aa90572010-09-26 18:40:37 -0700664 addPoint(sx, sy);
665 OpenGLRenderer::scale(sx, sy);
666}
667
Romain Guy807daf72011-01-18 11:19:19 -0800668void DisplayListRenderer::skew(float sx, float sy) {
669 addOp(DisplayList::Skew);
670 addPoint(sx, sy);
671 OpenGLRenderer::skew(sx, sy);
672}
673
Romain Guy4aa90572010-09-26 18:40:37 -0700674void DisplayListRenderer::setMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -0700675 addOp(DisplayList::SetMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -0700676 addMatrix(matrix);
677 OpenGLRenderer::setMatrix(matrix);
678}
679
680void DisplayListRenderer::concatMatrix(SkMatrix* matrix) {
Romain Guyb051e892010-09-28 19:09:36 -0700681 addOp(DisplayList::ConcatMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -0700682 addMatrix(matrix);
683 OpenGLRenderer::concatMatrix(matrix);
684}
685
686bool DisplayListRenderer::clipRect(float left, float top, float right, float bottom,
687 SkRegion::Op op) {
Romain Guyb051e892010-09-28 19:09:36 -0700688 addOp(DisplayList::ClipRect);
Romain Guy4aa90572010-09-26 18:40:37 -0700689 addBounds(left, top, right, bottom);
690 addInt(op);
691 return OpenGLRenderer::clipRect(left, top, right, bottom, op);
692}
693
Romain Guy7b5b6ab2011-03-14 18:05:08 -0700694bool DisplayListRenderer::drawDisplayList(DisplayList* displayList,
695 uint32_t width, uint32_t height, Rect& dirty, uint32_t level) {
Romain Guycabfcc12011-03-07 18:06:46 -0800696 // dirty is an out parameter and should not be recorded,
697 // it matters only when replaying the display list
Romain Guy0fe478e2010-11-08 12:08:41 -0800698 addOp(DisplayList::DrawDisplayList);
699 addDisplayList(displayList);
Romain Guy7b5b6ab2011-03-14 18:05:08 -0700700 addSize(width, height);
Chet Haasedaf98e92011-01-10 14:10:36 -0800701 return false;
Romain Guy0fe478e2010-11-08 12:08:41 -0800702}
703
Romain Guyada830f2011-01-13 12:13:20 -0800704void DisplayListRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
Romain Guy6c319ca2011-01-11 14:29:25 -0800705 addOp(DisplayList::DrawLayer);
Romain Guyada830f2011-01-13 12:13:20 -0800706 addInt((int) layer);
707 addPoint(x, y);
Romain Guy6c319ca2011-01-11 14:29:25 -0800708 addPaint(paint);
709}
710
Romain Guy4aa90572010-09-26 18:40:37 -0700711void DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top,
Chet Haase5c13d892010-10-08 08:37:55 -0700712 SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700713 addOp(DisplayList::DrawBitmap);
Romain Guy4aa90572010-09-26 18:40:37 -0700714 addBitmap(bitmap);
715 addPoint(left, top);
716 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700717}
718
Chet Haase5c13d892010-10-08 08:37:55 -0700719void DisplayListRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix,
720 SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700721 addOp(DisplayList::DrawBitmapMatrix);
Romain Guy4aa90572010-09-26 18:40:37 -0700722 addBitmap(bitmap);
723 addMatrix(matrix);
724 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700725}
726
727void DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
728 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -0700729 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700730 addOp(DisplayList::DrawBitmapRect);
Romain Guy4aa90572010-09-26 18:40:37 -0700731 addBitmap(bitmap);
732 addBounds(srcLeft, srcTop, srcRight, srcBottom);
733 addBounds(dstLeft, dstTop, dstRight, dstBottom);
734 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700735}
736
Romain Guy5a7b4662011-01-20 19:09:30 -0800737void DisplayListRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHeight,
738 float* vertices, int* colors, SkPaint* paint) {
739 addOp(DisplayList::DrawBitmapMesh);
740 addBitmap(bitmap);
741 addInt(meshWidth);
742 addInt(meshHeight);
743 addFloats(vertices, (meshWidth + 1) * (meshHeight + 1) * 2);
744 if (colors) {
745 addInt(1);
746 addInts(colors, (meshWidth + 1) * (meshHeight + 1));
747 } else {
748 addInt(0);
749 }
750 addPaint(paint);
751}
752
Romain Guy4aa90572010-09-26 18:40:37 -0700753void DisplayListRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
Romain Guy4bb94202010-10-12 15:59:26 -0700754 const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
Chet Haase5c13d892010-10-08 08:37:55 -0700755 float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700756 addOp(DisplayList::DrawPatch);
Romain Guy4aa90572010-09-26 18:40:37 -0700757 addBitmap(bitmap);
758 addInts(xDivs, width);
759 addInts(yDivs, height);
Romain Guy4bb94202010-10-12 15:59:26 -0700760 addUInts(colors, numColors);
Romain Guy4aa90572010-09-26 18:40:37 -0700761 addBounds(left, top, right, bottom);
762 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700763}
764
765void DisplayListRenderer::drawColor(int color, SkXfermode::Mode mode) {
Romain Guyb051e892010-09-28 19:09:36 -0700766 addOp(DisplayList::DrawColor);
Romain Guy4aa90572010-09-26 18:40:37 -0700767 addInt(color);
768 addInt(mode);
Romain Guy4aa90572010-09-26 18:40:37 -0700769}
770
771void DisplayListRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -0700772 SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700773 addOp(DisplayList::DrawRect);
Romain Guy4aa90572010-09-26 18:40:37 -0700774 addBounds(left, top, right, bottom);
775 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700776}
777
Romain Guy01d58e42011-01-19 21:54:02 -0800778void DisplayListRenderer::drawRoundRect(float left, float top, float right, float bottom,
779 float rx, float ry, SkPaint* paint) {
780 addOp(DisplayList::DrawRoundRect);
781 addBounds(left, top, right, bottom);
782 addPoint(rx, ry);
783 addPaint(paint);
784}
785
786void DisplayListRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
787 addOp(DisplayList::DrawCircle);
788 addPoint(x, y);
789 addFloat(radius);
790 addPaint(paint);
791}
792
Romain Guyc1cd9ba32011-01-23 14:18:41 -0800793void DisplayListRenderer::drawOval(float left, float top, float right, float bottom,
794 SkPaint* paint) {
795 addOp(DisplayList::DrawOval);
796 addBounds(left, top, right, bottom);
797 addPaint(paint);
798}
799
Romain Guy8b2f5262011-01-23 16:15:02 -0800800void DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
801 float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
Romain Guy82d41a52011-01-24 21:53:42 -0800802 addOp(DisplayList::DrawArc);
Romain Guy8b2f5262011-01-23 16:15:02 -0800803 addBounds(left, top, right, bottom);
804 addPoint(startAngle, sweepAngle);
805 addInt(useCenter ? 1 : 0);
806 addPaint(paint);
807}
808
Romain Guy4aa90572010-09-26 18:40:37 -0700809void DisplayListRenderer::drawPath(SkPath* path, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700810 addOp(DisplayList::DrawPath);
Romain Guy4aa90572010-09-26 18:40:37 -0700811 addPath(path);
812 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700813}
814
Chet Haase5c13d892010-10-08 08:37:55 -0700815void DisplayListRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700816 addOp(DisplayList::DrawLines);
Romain Guy4aa90572010-09-26 18:40:37 -0700817 addFloats(points, count);
818 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700819}
820
Romain Guyed6fcb02011-03-21 13:11:28 -0700821void DisplayListRenderer::drawPoints(float* points, int count, SkPaint* paint) {
822 addOp(DisplayList::DrawPoints);
823 addFloats(points, count);
824 addPaint(paint);
825}
826
Romain Guy4aa90572010-09-26 18:40:37 -0700827void DisplayListRenderer::drawText(const char* text, int bytesCount, int count,
828 float x, float y, SkPaint* paint) {
Romain Guyb051e892010-09-28 19:09:36 -0700829 addOp(DisplayList::DrawText);
Romain Guy4aa90572010-09-26 18:40:37 -0700830 addText(text, bytesCount);
831 addInt(count);
832 addPoint(x, y);
833 addPaint(paint);
Romain Guy4aa90572010-09-26 18:40:37 -0700834}
835
836void DisplayListRenderer::resetShader() {
Romain Guyb051e892010-09-28 19:09:36 -0700837 addOp(DisplayList::ResetShader);
Romain Guy4aa90572010-09-26 18:40:37 -0700838}
839
840void DisplayListRenderer::setupShader(SkiaShader* shader) {
Chet Haase5c13d892010-10-08 08:37:55 -0700841 addOp(DisplayList::SetupShader);
842 addShader(shader);
Romain Guy4aa90572010-09-26 18:40:37 -0700843}
844
845void DisplayListRenderer::resetColorFilter() {
Romain Guyb051e892010-09-28 19:09:36 -0700846 addOp(DisplayList::ResetColorFilter);
Romain Guy4aa90572010-09-26 18:40:37 -0700847}
848
849void DisplayListRenderer::setupColorFilter(SkiaColorFilter* filter) {
Chet Haasead93c2b2010-10-22 16:17:12 -0700850 addOp(DisplayList::SetupColorFilter);
851 addColorFilter(filter);
Romain Guy4aa90572010-09-26 18:40:37 -0700852}
853
854void DisplayListRenderer::resetShadow() {
Romain Guyb051e892010-09-28 19:09:36 -0700855 addOp(DisplayList::ResetShadow);
Romain Guy4aa90572010-09-26 18:40:37 -0700856}
857
858void DisplayListRenderer::setupShadow(float radius, float dx, float dy, int color) {
Romain Guyb051e892010-09-28 19:09:36 -0700859 addOp(DisplayList::SetupShadow);
Romain Guy4aa90572010-09-26 18:40:37 -0700860 addFloat(radius);
861 addPoint(dx, dy);
862 addInt(color);
Romain Guy4aa90572010-09-26 18:40:37 -0700863}
864
Romain Guy4aa90572010-09-26 18:40:37 -0700865}; // namespace uirenderer
866}; // namespace android