OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 class SkDrawIter : public SkDraw { | 229 class SkDrawIter : public SkDraw { |
230 public: | 230 public: |
231 SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) { | 231 SkDrawIter(SkCanvas* canvas, bool skipEmptyClips = true) { |
232 canvas = canvas->canvasForDrawIter(); | 232 canvas = canvas->canvasForDrawIter(); |
233 fCanvas = canvas; | 233 fCanvas = canvas; |
234 canvas->updateDeviceCMCache(); | 234 canvas->updateDeviceCMCache(); |
235 | 235 |
236 fClipStack = canvas->fClipStack.get(); | 236 fClipStack = canvas->fClipStack.get(); |
237 fCurrLayer = canvas->fMCRec->fTopLayer; | 237 fCurrLayer = canvas->fMCRec->fTopLayer; |
238 fSkipEmptyClips = skipEmptyClips; | 238 fSkipEmptyClips = skipEmptyClips; |
239 | |
240 fDrawFilter = fCanvas->getDrawFilter(); | |
reed1
2015/03/03 21:26:22
nit: cavas-> instead of fCanvas, just to match the
| |
239 } | 241 } |
240 | 242 |
241 bool next() { | 243 bool next() { |
242 // skip over recs with empty clips | 244 // skip over recs with empty clips |
243 if (fSkipEmptyClips) { | 245 if (fSkipEmptyClips) { |
244 while (fCurrLayer && fCurrLayer->fClip.isEmpty()) { | 246 while (fCurrLayer && fCurrLayer->fClip.isEmpty()) { |
245 fCurrLayer = fCurrLayer->fNext; | 247 fCurrLayer = fCurrLayer->fNext; |
246 } | 248 } |
247 } | 249 } |
248 | 250 |
(...skipping 30 matching lines...) Expand all Loading... | |
279 SkBool8 fSkipEmptyClips; | 281 SkBool8 fSkipEmptyClips; |
280 | 282 |
281 typedef SkDraw INHERITED; | 283 typedef SkDraw INHERITED; |
282 }; | 284 }; |
283 | 285 |
284 ///////////////////////////////////////////////////////////////////////////// | 286 ///////////////////////////////////////////////////////////////////////////// |
285 | 287 |
286 class AutoDrawLooper { | 288 class AutoDrawLooper { |
287 public: | 289 public: |
288 AutoDrawLooper(SkCanvas* canvas, const SkSurfaceProps& props, const SkPaint& paint, | 290 AutoDrawLooper(SkCanvas* canvas, const SkSurfaceProps& props, const SkPaint& paint, |
289 bool skipLayerForImageFilter = false, | 291 bool skipLayerForImageFilter, bool skipDrawFilter, |
290 const SkRect* bounds = NULL) : fOrigPaint(paint) { | 292 const SkRect* bounds = NULL) |
291 fCanvas = canvas; | 293 : fCanvas(canvas) |
292 fFilter = canvas->getDrawFilter(); | 294 , fOrigPaint(paint) |
293 fPaint = &fOrigPaint; | 295 , fFilter(skipDrawFilter ? NULL : canvas->getDrawFilter()) |
294 fSaveCount = canvas->getSaveCount(); | 296 , fPaint(&fOrigPaint) |
295 fDoClearImageFilter = false; | 297 , fSaveCount(canvas->getSaveCount()) |
296 fDone = false; | 298 , fDoClearImageFilter(false) |
299 , fDone(false) { | |
297 | 300 |
298 if (!skipLayerForImageFilter && fOrigPaint.getImageFilter()) { | 301 if (!skipLayerForImageFilter && fOrigPaint.getImageFilter()) { |
299 SkPaint tmp; | 302 SkPaint tmp; |
300 tmp.setImageFilter(fOrigPaint.getImageFilter()); | 303 tmp.setImageFilter(fOrigPaint.getImageFilter()); |
301 (void)canvas->internalSaveLayer(bounds, &tmp, SkCanvas::kARGB_ClipLa yer_SaveFlag, | 304 (void)canvas->internalSaveLayer(bounds, &tmp, SkCanvas::kARGB_ClipLa yer_SaveFlag, |
302 true, SkCanvas::kFullLayer_SaveLayer Strategy); | 305 true, SkCanvas::kFullLayer_SaveLayer Strategy); |
303 // we'll clear the imageFilter for the actual draws in next(), so | 306 // we'll clear the imageFilter for the actual draws in next(), so |
304 // it will only be applied during the restore(). | 307 // it will only be applied during the restore(). |
305 fDoClearImageFilter = true; | 308 fDoClearImageFilter = true; |
306 } | 309 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 fPaint = NULL; | 407 fPaint = NULL; |
405 return false; | 408 return false; |
406 } | 409 } |
407 return true; | 410 return true; |
408 } | 411 } |
409 | 412 |
410 ////////// macros to place around the internal draw calls ////////////////// | 413 ////////// macros to place around the internal draw calls ////////////////// |
411 | 414 |
412 #define LOOPER_BEGIN_DRAWDEVICE(paint, type) \ | 415 #define LOOPER_BEGIN_DRAWDEVICE(paint, type) \ |
413 this->predrawNotify(); \ | 416 this->predrawNotify(); \ |
414 AutoDrawLooper looper(this, fProps, paint, true); \ | 417 AutoDrawLooper looper(this, fProps, paint, true, false); \ |
415 while (looper.next(type)) { \ | 418 while (looper.next(type)) { \ |
416 SkDrawIter iter(this); | 419 SkDrawIter iter(this); |
417 | 420 |
418 #define LOOPER_BEGIN(paint, type, bounds) \ | 421 #define LOOPER_BEGIN(paint, type, bounds) \ |
419 this->predrawNotify(); \ | 422 this->predrawNotify(); \ |
420 AutoDrawLooper looper(this, fProps, paint, false, bounds); \ | 423 AutoDrawLooper looper(this, fProps, paint, false, false, bounds); \ |
421 while (looper.next(type)) { \ | 424 while (looper.next(type)) { \ |
422 SkDrawIter iter(this); | 425 SkDrawIter iter(this); |
423 | 426 |
427 #define LOOPER_BEGIN_UNFILTERED(paint, type, bounds) \ | |
428 this->predrawNotify(); \ | |
429 AutoDrawLooper looper(this, fProps, paint, false, true, bounds); \ | |
430 while (looper.next(type)) { \ | |
431 SkDrawIter iter(this); | |
432 | |
424 #define LOOPER_END } | 433 #define LOOPER_END } |
425 | 434 |
426 //////////////////////////////////////////////////////////////////////////// | 435 //////////////////////////////////////////////////////////////////////////// |
427 | 436 |
428 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { | 437 SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) { |
429 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ; | 438 fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag) ; |
430 fCachedLocalClipBounds.setEmpty(); | 439 fCachedLocalClipBounds.setEmpty(); |
431 fCachedLocalClipBoundsDirty = true; | 440 fCachedLocalClipBoundsDirty = true; |
432 fAllowSoftClip = true; | 441 fAllowSoftClip = true; |
433 fAllowSimplifyClip = false; | 442 fAllowSimplifyClip = false; |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2154 const SkPaint& paint) { | 2163 const SkPaint& paint) { |
2155 | 2164 |
2156 if (paint.canComputeFastBounds()) { | 2165 if (paint.canComputeFastBounds()) { |
2157 SkRect storage; | 2166 SkRect storage; |
2158 | 2167 |
2159 if (this->quickReject(paint.computeFastBounds(blob->bounds().makeOffset( x, y), &storage))) { | 2168 if (this->quickReject(paint.computeFastBounds(blob->bounds().makeOffset( x, y), &storage))) { |
2160 return; | 2169 return; |
2161 } | 2170 } |
2162 } | 2171 } |
2163 | 2172 |
2164 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) | 2173 // Skip draw filters because the actual paint depends on run font info. Draw filters |
2174 // are applied at the device level, where we have access to the complete pai nt. | |
2175 LOOPER_BEGIN_UNFILTERED(paint, SkDrawFilter::kText_Type, NULL) | |
2165 | 2176 |
2166 while (iter.next()) { | 2177 while (iter.next()) { |
2167 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); | 2178 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); |
2168 iter.fDevice->drawTextBlob(iter, blob, x, y, dfp.paint()); | 2179 iter.fDevice->drawTextBlob(iter, blob, x, y, dfp.paint()); |
2169 } | 2180 } |
2170 | 2181 |
2171 LOOPER_END | 2182 LOOPER_END |
2172 } | 2183 } |
2173 | 2184 |
2174 // These will become non-virtual, so they always call the (virtual) onDraw... me thod | 2185 // These will become non-virtual, so they always call the (virtual) onDraw... me thod |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2513 } | 2524 } |
2514 | 2525 |
2515 if (matrix) { | 2526 if (matrix) { |
2516 canvas->concat(*matrix); | 2527 canvas->concat(*matrix); |
2517 } | 2528 } |
2518 } | 2529 } |
2519 | 2530 |
2520 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2531 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2521 fCanvas->restoreToCount(fSaveCount); | 2532 fCanvas->restoreToCount(fSaveCount); |
2522 } | 2533 } |
OLD | NEW |