Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
| 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 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 SkPaint tmp; | 348 SkPaint tmp; |
| 349 tmp.setImageFilter(fOrigPaint.getImageFilter()); | 349 tmp.setImageFilter(fOrigPaint.getImageFilter()); |
| 350 (void)canvas->internalSaveLayer(bounds, &tmp, | 350 (void)canvas->internalSaveLayer(bounds, &tmp, |
| 351 SkCanvas::kARGB_ClipLayer_SaveFlag, true); | 351 SkCanvas::kARGB_ClipLayer_SaveFlag, true); |
| 352 // we'll clear the imageFilter for the actual draws in next(), so | 352 // we'll clear the imageFilter for the actual draws in next(), so |
| 353 // it will only be applied during the restore(). | 353 // it will only be applied during the restore(). |
| 354 fDoClearImageFilter = true; | 354 fDoClearImageFilter = true; |
| 355 } | 355 } |
| 356 | 356 |
| 357 if (fLooper) { | 357 if (fLooper) { |
| 358 fLooper->init(canvas); | 358 fLooperContext = fLooper->init(canvas, &fLooperContextAllocator); |
| 359 fIsSimple = false; | 359 fIsSimple = false; |
| 360 } else { | 360 } else { |
| 361 // can we be marked as simple? | 361 // can we be marked as simple? |
| 362 fIsSimple = !fFilter && !fDoClearImageFilter; | 362 fIsSimple = !fFilter && !fDoClearImageFilter; |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 ~AutoDrawLooper() { | 366 ~AutoDrawLooper() { |
| 367 if (fDoClearImageFilter) { | 367 if (fDoClearImageFilter) { |
| 368 fCanvas->internalRestore(); | 368 fCanvas->internalRestore(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 384 return !fPaint->nothingToDraw(); | 384 return !fPaint->nothingToDraw(); |
| 385 } else { | 385 } else { |
| 386 return this->doNext(drawType); | 386 return this->doNext(drawType); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 private: | 390 private: |
| 391 SkLazyPaint fLazyPaint; | 391 SkLazyPaint fLazyPaint; |
| 392 SkCanvas* fCanvas; | 392 SkCanvas* fCanvas; |
| 393 const SkPaint& fOrigPaint; | 393 const SkPaint& fOrigPaint; |
| 394 SkDrawLooper* fLooper; | 394 SkDrawLooper* fLooper; |
|
scroggo
2014/03/10 19:41:32
After initialization, fLooper is only used to chec
Dominik Grewe
2014/03/11 11:53:54
Done.
| |
| 395 SkDrawFilter* fFilter; | 395 SkDrawFilter* fFilter; |
| 396 const SkPaint* fPaint; | 396 const SkPaint* fPaint; |
| 397 int fSaveCount; | 397 int fSaveCount; |
| 398 bool fDoClearImageFilter; | 398 bool fDoClearImageFilter; |
| 399 bool fDone; | 399 bool fDone; |
| 400 bool fIsSimple; | 400 bool fIsSimple; |
| 401 SkDrawLooper::Context* fLooperContext; | |
| 402 SkDrawLooper::ContextAllocator fLooperContextAllocator; | |
| 401 | 403 |
| 402 bool doNext(SkDrawFilter::Type drawType); | 404 bool doNext(SkDrawFilter::Type drawType); |
| 403 }; | 405 }; |
| 404 | 406 |
| 405 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { | 407 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { |
| 406 fPaint = NULL; | 408 fPaint = NULL; |
| 407 SkASSERT(!fIsSimple); | 409 SkASSERT(!fIsSimple); |
| 408 SkASSERT(fLooper || fFilter || fDoClearImageFilter); | 410 SkASSERT(fLooper || fFilter || fDoClearImageFilter); |
| 411 SkASSERT(!fLooper || fLooperContext); | |
| 409 | 412 |
| 410 SkPaint* paint = fLazyPaint.set(fOrigPaint); | 413 SkPaint* paint = fLazyPaint.set(fOrigPaint); |
| 411 | 414 |
| 412 if (fDoClearImageFilter) { | 415 if (fDoClearImageFilter) { |
| 413 paint->setImageFilter(NULL); | 416 paint->setImageFilter(NULL); |
| 414 } | 417 } |
| 415 | 418 |
| 416 if (fLooper && !fLooper->next(fCanvas, paint)) { | 419 if (fLooper && !fLooperContext->next(fCanvas, paint)) { |
| 417 fDone = true; | 420 fDone = true; |
| 418 return false; | 421 return false; |
| 419 } | 422 } |
| 420 if (fFilter) { | 423 if (fFilter) { |
| 421 if (!fFilter->filter(paint, drawType)) { | 424 if (!fFilter->filter(paint, drawType)) { |
| 422 fDone = true; | 425 fDone = true; |
| 423 return false; | 426 return false; |
| 424 } | 427 } |
| 425 if (NULL == fLooper) { | 428 if (NULL == fLooper) { |
| 426 // no looper means we only draw once | 429 // no looper means we only draw once |
| (...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2451 if (!bitmap.allocPixels(info)) { | 2454 if (!bitmap.allocPixels(info)) { |
| 2452 return NULL; | 2455 return NULL; |
| 2453 } | 2456 } |
| 2454 | 2457 |
| 2455 // should this functionality be moved into allocPixels()? | 2458 // should this functionality be moved into allocPixels()? |
| 2456 if (!bitmap.info().isOpaque()) { | 2459 if (!bitmap.info().isOpaque()) { |
| 2457 bitmap.eraseColor(0); | 2460 bitmap.eraseColor(0); |
| 2458 } | 2461 } |
| 2459 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2462 return SkNEW_ARGS(SkCanvas, (bitmap)); |
| 2460 } | 2463 } |
| OLD | NEW |