Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/core/SkBBoxRecord.cpp

Issue 12545009: Adding option in SkPicture to record device-space bounds of draw commands. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBBoxRecord.h" 9 #include "SkBBoxRecord.h"
10 10
11 void SkBBoxRecord::drawOval(const SkRect& rect, const SkPaint& paint) { 11 void SkBBoxRecord::drawOval(const SkRect& rect, const SkPaint& paint) {
12 #if SK_RECORD_BOUNDS_IN_PICTURE
13 uint32_t offset = this->writeStream().size();
14 INHERITED::drawOval(rect, paint);
15 this->handleBBox(offset);
16 #else
12 if (this->transformBounds(rect, &paint)) { 17 if (this->transformBounds(rect, &paint)) {
13 INHERITED::drawOval(rect, paint); 18 INHERITED::drawOval(rect, paint);
14 } 19 }
20 #endif
15 } 21 }
16 22
17 void SkBBoxRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) { 23 void SkBBoxRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
24 #if SK_RECORD_BOUNDS_IN_PICTURE
25 uint32_t offset = this->writeStream().size();
26 INHERITED::drawRRect(rrect, paint);
27 this->handleBBox(offset);
28 #else
18 if (this->transformBounds(rrect.rect(), &paint)) { 29 if (this->transformBounds(rrect.rect(), &paint)) {
19 INHERITED::drawRRect(rrect, paint); 30 INHERITED::drawRRect(rrect, paint);
20 } 31 }
32 #endif
21 } 33 }
22 34
23 void SkBBoxRecord::drawRect(const SkRect& rect, const SkPaint& paint) { 35 void SkBBoxRecord::drawRect(const SkRect& rect, const SkPaint& paint) {
36 #if SK_RECORD_BOUNDS_IN_PICTURE
37 uint32_t offset = this->writeStream().size();
38 INHERITED::drawRect(rect, paint);
39 this->handleBBox(offset);
40 #else
24 if (this->transformBounds(rect, &paint)) { 41 if (this->transformBounds(rect, &paint)) {
25 INHERITED::drawRect(rect, paint); 42 INHERITED::drawRect(rect, paint);
26 } 43 }
44 #endif
27 } 45 }
28 46
29 void SkBBoxRecord::drawPath(const SkPath& path, const SkPaint& paint) { 47 void SkBBoxRecord::drawPath(const SkPath& path, const SkPaint& paint) {
48 #if SK_RECORD_BOUNDS_IN_PICTURE
49 uint32_t offset = this->writeStream().size();
50 INHERITED::drawPath(path, paint);
51 this->handleBBox(offset);
52 #else
30 if (path.isInverseFillType()) { 53 if (path.isInverseFillType()) {
31 // If path is inverse filled, use the current clip bounds as the 54 // If path is inverse filled, use the current clip bounds as the
32 // path's device-space bounding box. 55 // path's device-space bounding box.
33 SkIRect clipBounds; 56 SkIRect clipBounds;
34 if (this->getClipDeviceBounds(&clipBounds)) { 57 if (this->getClipDeviceBounds(&clipBounds)) {
35 this->handleBBox(SkRect::MakeFromIRect(clipBounds)); 58 this->handleBBox(SkRect::MakeFromIRect(clipBounds));
36 INHERITED::drawPath(path, paint); 59 INHERITED::drawPath(path, paint);
37 } 60 }
38 } else if (this->transformBounds(path.getBounds(), &paint)) { 61 } else if (this->transformBounds(path.getBounds(), &paint)) {
39 INHERITED::drawPath(path, paint); 62 INHERITED::drawPath(path, paint);
40 } 63 }
64 #endif
41 } 65 }
42 66
43 void SkBBoxRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts[], 67 void SkBBoxRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts[],
44 const SkPaint& paint) { 68 const SkPaint& paint) {
69 #if SK_RECORD_BOUNDS_IN_PICTURE
70 uint32_t offset = this->writeStream().size();
71 INHERITED::drawPoints(mode, count, pts, paint);
Tom Hudson 2013/05/14 17:00:49 I like the way this file starts losing special cas
72 this->handleBBox(offset);
73 #else
45 SkRect bbox; 74 SkRect bbox;
46 bbox.set(pts, count); 75 bbox.set(pts, count);
47 // Small min width value, just to ensure hairline point bounding boxes aren' t empty. 76 // Small min width value, just to ensure hairline point bounding boxes aren' t empty.
48 // Even though we know hairline primitives are drawn one pixel wide, we do n ot use a 77 // Even though we know hairline primitives are drawn one pixel wide, we do n ot use a
49 // minimum of 1 because the playback scale factor is unknown at record time. Later 78 // minimum of 1 because the playback scale factor is unknown at record time. Later
50 // outsets will take care of adding additional padding for antialiasing and rounding out 79 // outsets will take care of adding additional padding for antialiasing and rounding out
51 // to integer device coordinates, guaranteeing that the rasterized pixels wi ll be included 80 // to integer device coordinates, guaranteeing that the rasterized pixels wi ll be included
52 // in the computed bounds. 81 // in the computed bounds.
53 // Note: The device coordinate outset in SkBBoxHierarchyRecord::handleBBox i s currently 82 // Note: The device coordinate outset in SkBBoxHierarchyRecord::handleBBox i s currently
54 // done in the recording coordinate space, which is wrong. 83 // done in the recording coordinate space, which is wrong.
55 // http://code.google.com/p/skia/issues/detail?id=1021 84 // http://code.google.com/p/skia/issues/detail?id=1021
56 static const SkScalar kMinWidth = SkFloatToScalar(0.01f); 85 static const SkScalar kMinWidth = SkFloatToScalar(0.01f);
57 SkScalar halfStrokeWidth = SkMaxScalar(paint.getStrokeWidth(), kMinWidth) / 2; 86 SkScalar halfStrokeWidth = SkMaxScalar(paint.getStrokeWidth(), kMinWidth) / 2;
58 bbox.outset(halfStrokeWidth, halfStrokeWidth); 87 bbox.outset(halfStrokeWidth, halfStrokeWidth);
59 if (this->transformBounds(bbox, &paint)) { 88 if (this->transformBounds(bbox, &paint)) {
60 INHERITED::drawPoints(mode, count, pts, paint); 89 INHERITED::drawPoints(mode, count, pts, paint);
61 } 90 }
91 #endif
62 } 92 }
63 93
64 void SkBBoxRecord::drawPaint(const SkPaint& paint) { 94 void SkBBoxRecord::drawPaint(const SkPaint& paint) {
95 #if SK_RECORD_BOUNDS_IN_PICTURE
96 uint32_t offset = this->writeStream().size();
97 INHERITED::drawPaint(paint);
98 this->handleBBox(offset);
99 #else
65 SkRect bbox; 100 SkRect bbox;
66 if (this->getClipBounds(&bbox)) { 101 if (this->getClipBounds(&bbox)) {
67 if (this->transformBounds(bbox, &paint)) { 102 if (this->transformBounds(bbox, &paint)) {
68 INHERITED::drawPaint(paint); 103 INHERITED::drawPaint(paint);
69 } 104 }
70 } 105 }
106 #endif
71 } 107 }
72 108
73 void SkBBoxRecord::clear(SkColor color) { 109 void SkBBoxRecord::clear(SkColor color) {
110 #if SK_RECORD_BOUNDS_IN_PICTURE
111 uint32_t offset = this->writeStream().size();
112 INHERITED::clear(color);
113 this->handleBBox(offset);
114 #else
74 SkISize size = this->getDeviceSize(); 115 SkISize size = this->getDeviceSize();
75 SkRect bbox = {0, 0, SkIntToScalar(size.width()), SkIntToScalar(size.height( ))}; 116 SkRect bbox = {0, 0, SkIntToScalar(size.width()), SkIntToScalar(size.height( ))};
76 this->handleBBox(bbox); 117 this->handleBBox(bbox);
77 INHERITED::clear(color); 118 INHERITED::clear(color);
119 #endif
78 } 120 }
79 121
80 void SkBBoxRecord::drawText(const void* text, size_t byteLength, SkScalar x, SkS calar y, 122 void SkBBoxRecord::drawText(const void* text, size_t byteLength, SkScalar x, SkS calar y,
81 const SkPaint& paint) { 123 const SkPaint& paint) {
124 #if SK_RECORD_BOUNDS_IN_PICTURE
125 uint32_t offset = this->writeStream().size();
126 INHERITED::drawText(text, byteLength, x, y, paint);
127 this->handleBBox(offset);
128 #else
82 SkRect bbox; 129 SkRect bbox;
83 paint.measureText(text, byteLength, &bbox); 130 paint.measureText(text, byteLength, &bbox);
84 SkPaint::FontMetrics metrics; 131 SkPaint::FontMetrics metrics;
85 paint.getFontMetrics(&metrics); 132 paint.getFontMetrics(&metrics);
86 133
87 // Vertical and aligned text need to be offset 134 // Vertical and aligned text need to be offset
88 if (paint.isVerticalText()) { 135 if (paint.isVerticalText()) {
89 SkScalar h = bbox.fBottom - bbox.fTop; 136 SkScalar h = bbox.fBottom - bbox.fTop;
90 if (paint.getTextAlign() == SkPaint::kCenter_Align) { 137 if (paint.getTextAlign() == SkPaint::kCenter_Align) {
91 bbox.fTop -= h / 2; 138 bbox.fTop -= h / 2;
(...skipping 24 matching lines...) Expand all
116 bbox.fLeft -= pad; 163 bbox.fLeft -= pad;
117 bbox.fRight += pad; 164 bbox.fRight += pad;
118 165
119 bbox.fLeft += x; 166 bbox.fLeft += x;
120 bbox.fRight += x; 167 bbox.fRight += x;
121 bbox.fTop += y; 168 bbox.fTop += y;
122 bbox.fBottom += y; 169 bbox.fBottom += y;
123 if (this->transformBounds(bbox, &paint)) { 170 if (this->transformBounds(bbox, &paint)) {
124 INHERITED::drawText(text, byteLength, x, y, paint); 171 INHERITED::drawText(text, byteLength, x, y, paint);
125 } 172 }
173 #endif
126 } 174 }
127 175
128 void SkBBoxRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar to p, 176 void SkBBoxRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar to p,
129 const SkPaint* paint) { 177 const SkPaint* paint) {
178 #if SK_RECORD_BOUNDS_IN_PICTURE
179 uint32_t offset = this->writeStream().size();
180 INHERITED::drawBitmap(bitmap, left, top, paint);
181 this->handleBBox(offset);
182 #else
130 SkRect bbox = {left, top, left + bitmap.width(), top + bitmap.height()}; 183 SkRect bbox = {left, top, left + bitmap.width(), top + bitmap.height()};
131 if (this->transformBounds(bbox, paint)) { 184 if (this->transformBounds(bbox, paint)) {
132 INHERITED::drawBitmap(bitmap, left, top, paint); 185 INHERITED::drawBitmap(bitmap, left, top, paint);
133 } 186 }
187 #endif
134 } 188 }
135 189
136 void SkBBoxRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* sr c, 190 void SkBBoxRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* sr c,
137 const SkRect& dst, const SkPaint* paint) { 191 const SkRect& dst, const SkPaint* paint) {
192 #if SK_RECORD_BOUNDS_IN_PICTURE
193 uint32_t offset = this->writeStream().size();
194 INHERITED::drawBitmapRectToRect(bitmap, src, dst, paint);
195 this->handleBBox(offset);
196 #else
138 if (this->transformBounds(dst, paint)) { 197 if (this->transformBounds(dst, paint)) {
139 INHERITED::drawBitmapRectToRect(bitmap, src, dst, paint); 198 INHERITED::drawBitmapRectToRect(bitmap, src, dst, paint);
140 } 199 }
200 #endif
141 } 201 }
142 202
143 void SkBBoxRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat, 203 void SkBBoxRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat,
144 const SkPaint* paint) { 204 const SkPaint* paint) {
205 #if SK_RECORD_BOUNDS_IN_PICTURE
206 uint32_t offset = this->writeStream().size();
207 INHERITED::drawBitmapMatrix(bitmap, mat, paint);
208 this->handleBBox(offset);
209 #else
145 SkMatrix m = mat; 210 SkMatrix m = mat;
146 SkRect bbox = {0, 0, SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.hei ght())}; 211 SkRect bbox = {0, 0, SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.hei ght())};
147 m.mapRect(&bbox); 212 m.mapRect(&bbox);
148 if (this->transformBounds(bbox, paint)) { 213 if (this->transformBounds(bbox, paint)) {
149 INHERITED::drawBitmapMatrix(bitmap, mat, paint); 214 INHERITED::drawBitmapMatrix(bitmap, mat, paint);
150 } 215 }
216 #endif
151 } 217 }
152 218
153 void SkBBoxRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 219 void SkBBoxRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
154 const SkRect& dst, const SkPaint* paint) { 220 const SkRect& dst, const SkPaint* paint) {
221 #if SK_RECORD_BOUNDS_IN_PICTURE
222 uint32_t offset = this->writeStream().size();
223 INHERITED::drawBitmapNine(bitmap, center, dst, paint);
224 this->handleBBox(offset);
225 #else
155 if (this->transformBounds(dst, paint)) { 226 if (this->transformBounds(dst, paint)) {
156 INHERITED::drawBitmapNine(bitmap, center, dst, paint); 227 INHERITED::drawBitmapNine(bitmap, center, dst, paint);
157 } 228 }
229 #endif
158 } 230 }
159 231
160 void SkBBoxRecord::drawPosText(const void* text, size_t byteLength, 232 void SkBBoxRecord::drawPosText(const void* text, size_t byteLength,
161 const SkPoint pos[], const SkPaint& paint) { 233 const SkPoint pos[], const SkPaint& paint) {
234 #if SK_RECORD_BOUNDS_IN_PICTURE
235 uint32_t offset = this->writeStream().size();
236 INHERITED::drawPosText(text, byteLength, pos, paint);
237 this->handleBBox(offset);
238 #else
162 SkRect bbox; 239 SkRect bbox;
163 bbox.set(pos, paint.countText(text, byteLength)); 240 bbox.set(pos, paint.countText(text, byteLength));
164 SkPaint::FontMetrics metrics; 241 SkPaint::FontMetrics metrics;
165 paint.getFontMetrics(&metrics); 242 paint.getFontMetrics(&metrics);
166 bbox.fTop += metrics.fTop; 243 bbox.fTop += metrics.fTop;
167 bbox.fBottom += metrics.fBottom; 244 bbox.fBottom += metrics.fBottom;
168 245
169 // pad on left and right by half of max vertical glyph extents 246 // pad on left and right by half of max vertical glyph extents
170 SkScalar pad = (metrics.fTop - metrics.fBottom) / 2; 247 SkScalar pad = (metrics.fTop - metrics.fBottom) / 2;
171 bbox.fLeft += pad; 248 bbox.fLeft += pad;
172 bbox.fRight -= pad; 249 bbox.fRight -= pad;
173 250
174 if (this->transformBounds(bbox, &paint)) { 251 if (this->transformBounds(bbox, &paint)) {
175 INHERITED::drawPosText(text, byteLength, pos, paint); 252 INHERITED::drawPosText(text, byteLength, pos, paint);
176 } 253 }
254 #endif
177 } 255 }
178 256
179 void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[], 257 void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca lar xpos[],
180 SkScalar constY, const SkPaint& paint) { 258 SkScalar constY, const SkPaint& paint) {
259 #if SK_RECORD_BOUNDS_IN_PICTURE
260 uint32_t offset = this->writeStream().size();
261 INHERITED::drawPosTextH(text, byteLength, xpos, constY, paint);
262 this->handleBBox(offset);
263 #else
181 SkRect bbox; 264 SkRect bbox;
182 size_t numChars = paint.countText(text, byteLength); 265 size_t numChars = paint.countText(text, byteLength);
183 if (numChars > 0) { 266 if (numChars > 0) {
184 bbox.fLeft = xpos[0]; 267 bbox.fLeft = xpos[0];
185 bbox.fRight = xpos[numChars - 1]; 268 bbox.fRight = xpos[numChars - 1];
186 // if we had a guarantee that these will be monotonically increasing, th is could be sped up 269 // if we had a guarantee that these will be monotonically increasing, th is could be sped up
187 for (size_t i = 1; i < numChars; ++i) { 270 for (size_t i = 1; i < numChars; ++i) {
188 if (xpos[i] < bbox.fLeft) { 271 if (xpos[i] < bbox.fLeft) {
189 bbox.fLeft = xpos[i]; 272 bbox.fLeft = xpos[i];
190 } 273 }
191 if (xpos[i] > bbox.fRight) { 274 if (xpos[i] > bbox.fRight) {
192 bbox.fRight = xpos[i]; 275 bbox.fRight = xpos[i];
193 } 276 }
194 } 277 }
195 SkPaint::FontMetrics metrics; 278 SkPaint::FontMetrics metrics;
196 paint.getFontMetrics(&metrics); 279 paint.getFontMetrics(&metrics);
197 280
198 // pad horizontally by max glyph height 281 // pad horizontally by max glyph height
199 SkScalar pad = (metrics.fTop - metrics.fBottom); 282 SkScalar pad = (metrics.fTop - metrics.fBottom);
200 bbox.fLeft += pad; 283 bbox.fLeft += pad;
201 bbox.fRight -= pad; 284 bbox.fRight -= pad;
202 285
203 bbox.fTop = metrics.fTop + constY; 286 bbox.fTop = metrics.fTop + constY;
204 bbox.fBottom = metrics.fBottom + constY; 287 bbox.fBottom = metrics.fBottom + constY;
205 if (!this->transformBounds(bbox, &paint)) { 288 if (!this->transformBounds(bbox, &paint)) {
206 return; 289 return;
207 } 290 }
208 } 291 }
209 INHERITED::drawPosTextH(text, byteLength, xpos, constY, paint); 292 INHERITED::drawPosTextH(text, byteLength, xpos, constY, paint);
293 #endif
210 } 294 }
211 295
212 void SkBBoxRecord::drawSprite(const SkBitmap& bitmap, int left, int top, 296 void SkBBoxRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
213 const SkPaint* paint) { 297 const SkPaint* paint) {
298 #if SK_RECORD_BOUNDS_IN_PICTURE
299 uint32_t offset = this->writeStream().size();
300 INHERITED::drawSprite(bitmap, left, top, paint);
301 this->handleBBox(offset);
302 #else
214 SkRect bbox; 303 SkRect bbox;
215 bbox.set(SkIRect::MakeXYWH(left, top, bitmap.width(), bitmap.height())); 304 bbox.set(SkIRect::MakeXYWH(left, top, bitmap.width(), bitmap.height()));
216 this->handleBBox(bbox); // directly call handleBBox, matrix is ignored 305 this->handleBBox(bbox); // directly call handleBBox, matrix is ignored
217 INHERITED::drawSprite(bitmap, left, top, paint); 306 INHERITED::drawSprite(bitmap, left, top, paint);
307 #endif
218 } 308 }
219 309
220 void SkBBoxRecord::drawTextOnPath(const void* text, size_t byteLength, 310 void SkBBoxRecord::drawTextOnPath(const void* text, size_t byteLength,
221 const SkPath& path, const SkMatrix* matrix, 311 const SkPath& path, const SkMatrix* matrix,
222 const SkPaint& paint) { 312 const SkPaint& paint) {
313 #if SK_RECORD_BOUNDS_IN_PICTURE
314 uint32_t offset = this->writeStream().size();
315 INHERITED::drawTextOnPath(text, byteLength, path, matrix, paint);
316 this->handleBBox(offset);
317 #else
223 SkRect bbox = path.getBounds(); 318 SkRect bbox = path.getBounds();
224 SkPaint::FontMetrics metrics; 319 SkPaint::FontMetrics metrics;
225 paint.getFontMetrics(&metrics); 320 paint.getFontMetrics(&metrics);
226 321
227 // pad out all sides by the max glyph height above baseline 322 // pad out all sides by the max glyph height above baseline
228 SkScalar pad = metrics.fTop; 323 SkScalar pad = metrics.fTop;
229 bbox.fLeft += pad; 324 bbox.fLeft += pad;
230 bbox.fRight -= pad; 325 bbox.fRight -= pad;
231 bbox.fTop += pad; 326 bbox.fTop += pad;
232 bbox.fBottom -= pad; 327 bbox.fBottom -= pad;
233 328
234 if (this->transformBounds(bbox, &paint)) { 329 if (this->transformBounds(bbox, &paint)) {
235 INHERITED::drawTextOnPath(text, byteLength, path, matrix, paint); 330 INHERITED::drawTextOnPath(text, byteLength, path, matrix, paint);
236 } 331 }
332 #endif
237 } 333 }
238 334
239 void SkBBoxRecord::drawVertices(VertexMode mode, int vertexCount, 335 void SkBBoxRecord::drawVertices(VertexMode mode, int vertexCount,
240 const SkPoint vertices[], const SkPoint texs[], 336 const SkPoint vertices[], const SkPoint texs[],
241 const SkColor colors[], SkXfermode* xfer, 337 const SkColor colors[], SkXfermode* xfer,
242 const uint16_t indices[], int indexCount, 338 const uint16_t indices[], int indexCount,
243 const SkPaint& paint) { 339 const SkPaint& paint) {
340 #if SK_RECORD_BOUNDS_IN_PICTURE
341 uint32_t offset = this->writeStream().size();
342 INHERITED::drawVertices(mode, vertexCount, vertices, texs,
343 colors, xfer, indices, indexCount, paint);
344 this->handleBBox(offset);
345 #else
244 SkRect bbox; 346 SkRect bbox;
245 bbox.set(vertices, vertexCount); 347 bbox.set(vertices, vertexCount);
246 if (this->transformBounds(bbox, &paint)) { 348 if (this->transformBounds(bbox, &paint)) {
247 INHERITED::drawVertices(mode, vertexCount, vertices, texs, 349 INHERITED::drawVertices(mode, vertexCount, vertices, texs,
248 colors, xfer, indices, indexCount, paint); 350 colors, xfer, indices, indexCount, paint);
249 } 351 }
352 #endif
250 } 353 }
251 354
252 void SkBBoxRecord::drawPicture(SkPicture& picture) { 355 void SkBBoxRecord::drawPicture(SkPicture& picture) {
356 #if SK_RECORD_BOUNDS_IN_PICTURE
357 uint32_t offset = this->writeStream().size();
358 INHERITED::drawPicture(picture);
359 this->handleBBox(offset);
360 #else
253 if (picture.width() > 0 && picture.height() > 0 && 361 if (picture.width() > 0 && picture.height() > 0 &&
254 this->transformBounds(SkRect::MakeWH(picture.width(), picture.height()), NULL)) { 362 this->transformBounds(SkRect::MakeWH(picture.width(), picture.height()), NULL)) {
255 INHERITED::drawPicture(picture); 363 INHERITED::drawPicture(picture);
256 } 364 }
365 #endif
257 } 366 }
258 367
259 bool SkBBoxRecord::transformBounds(const SkRect& bounds, const SkPaint* paint) { 368 bool SkBBoxRecord::transformBounds(const SkRect& bounds, const SkPaint* paint) {
369 #if !(SK_RECORD_BOUNDS_IN_PICTURE)
260 SkRect outBounds = bounds; 370 SkRect outBounds = bounds;
261 outBounds.sort(); 371 outBounds.sort();
262 372
263 if (paint) { 373 if (paint) {
264 // account for stroking, path effects, shadows, etc 374 // account for stroking, path effects, shadows, etc
265 if (paint->canComputeFastBounds()) { 375 if (paint->canComputeFastBounds()) {
266 SkRect temp; 376 SkRect temp;
267 outBounds = paint->computeFastBounds(outBounds, &temp); 377 outBounds = paint->computeFastBounds(outBounds, &temp);
268 } else { 378 } else {
269 // set bounds to current clip 379 // set bounds to current clip
270 if (!this->getClipBounds(&outBounds)) { 380 if (!this->getClipBounds(&outBounds)) {
271 // current clip is empty 381 // current clip is empty
272 return false; 382 return false;
273 } 383 }
274 } 384 }
275 } 385 }
276 386
277 if (!outBounds.isEmpty() && !this->quickReject(outBounds)) { 387 if (!outBounds.isEmpty() && !this->quickReject(outBounds)) {
278 this->getTotalMatrix().mapRect(&outBounds); 388 this->getTotalMatrix().mapRect(&outBounds);
279 this->handleBBox(outBounds); 389 this->handleBBox(outBounds);
280 return true; 390 return true;
281 } 391 }
282 392 #else
393 SkASSERT(0);
394 #endif
283 return false; 395 return false;
284 } 396 }
OLDNEW
« no previous file with comments | « src/core/SkBBoxRecord.h ('k') | src/core/SkCanvas.cpp » ('j') | src/core/SkCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698