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

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

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: static allocation of DrawContext; update rest of code. Created 6 years, 10 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
OLDNEW
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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 SkPaint tmp; 349 SkPaint tmp;
350 tmp.setImageFilter(fOrigPaint.getImageFilter()); 350 tmp.setImageFilter(fOrigPaint.getImageFilter());
351 (void)canvas->internalSaveLayer(bounds, &tmp, 351 (void)canvas->internalSaveLayer(bounds, &tmp,
352 SkCanvas::kARGB_ClipLayer_SaveFlag, true); 352 SkCanvas::kARGB_ClipLayer_SaveFlag, true);
353 // we'll clear the imageFilter for the actual draws in next(), so 353 // we'll clear the imageFilter for the actual draws in next(), so
354 // it will only be applied during the restore(). 354 // it will only be applied during the restore().
355 fDoClearImageFilter = true; 355 fDoClearImageFilter = true;
356 } 356 }
357 357
358 if (fLooper) { 358 if (fLooper) {
359 fLooper->init(canvas); 359 fLooperContext = fLooper->init(canvas, fLooperContextStorage,
360 sizeof(fLooperContextStorage));
360 fIsSimple = false; 361 fIsSimple = false;
361 } else { 362 } else {
362 // can we be marked as simple? 363 // can we be marked as simple?
363 fIsSimple = !fFilter && !fDoClearImageFilter; 364 fIsSimple = !fFilter && !fDoClearImageFilter;
364 } 365 }
365 } 366 }
366 367
367 ~AutoDrawLooper() { 368 ~AutoDrawLooper() {
368 if (fDoClearImageFilter) { 369 if (fDoClearImageFilter) {
369 fCanvas->internalRestore(); 370 fCanvas->internalRestore();
370 } 371 }
371 SkASSERT(fCanvas->getSaveCount() == fSaveCount); 372 SkASSERT(fCanvas->getSaveCount() == fSaveCount);
373 if (fLooper) {
374 SkASSERT(fLooperContext);
375 fLooperContext->cleanup(fLooperContextStorage);
376 }
372 } 377 }
373 378
374 const SkPaint& paint() const { 379 const SkPaint& paint() const {
375 SkASSERT(fPaint); 380 SkASSERT(fPaint);
376 return *fPaint; 381 return *fPaint;
377 } 382 }
378 383
379 bool next(SkDrawFilter::Type drawType) { 384 bool next(SkDrawFilter::Type drawType) {
380 if (fDone) { 385 if (fDone) {
381 return false; 386 return false;
(...skipping 10 matching lines...) Expand all
392 SkLazyPaint fLazyPaint; 397 SkLazyPaint fLazyPaint;
393 SkCanvas* fCanvas; 398 SkCanvas* fCanvas;
394 const SkPaint& fOrigPaint; 399 const SkPaint& fOrigPaint;
395 SkDrawLooper* fLooper; 400 SkDrawLooper* fLooper;
396 SkDrawFilter* fFilter; 401 SkDrawFilter* fFilter;
397 const SkPaint* fPaint; 402 const SkPaint* fPaint;
398 int fSaveCount; 403 int fSaveCount;
399 bool fDoClearImageFilter; 404 bool fDoClearImageFilter;
400 bool fDone; 405 bool fDone;
401 bool fIsSimple; 406 bool fIsSimple;
407 SkDrawLooper::DrawContext* fLooperContext;
408 uint32_t fLooperContextStorage[kDrawLooperContextStorageLongCount];
402 409
403 bool doNext(SkDrawFilter::Type drawType); 410 bool doNext(SkDrawFilter::Type drawType);
404 }; 411 };
405 412
406 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) { 413 bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
407 fPaint = NULL; 414 fPaint = NULL;
408 SkASSERT(!fIsSimple); 415 SkASSERT(!fIsSimple);
409 SkASSERT(fLooper || fFilter || fDoClearImageFilter); 416 SkASSERT(fLooper || fFilter || fDoClearImageFilter);
417 SkASSERT(!fLooper || fLooperContext);
410 418
411 SkPaint* paint = fLazyPaint.set(fOrigPaint); 419 SkPaint* paint = fLazyPaint.set(fOrigPaint);
412 420
413 if (fDoClearImageFilter) { 421 if (fDoClearImageFilter) {
414 paint->setImageFilter(NULL); 422 paint->setImageFilter(NULL);
415 } 423 }
416 424
417 if (fLooper && !fLooper->next(fCanvas, paint)) { 425 if (fLooper && !fLooperContext->next(fCanvas, paint)) {
418 fDone = true; 426 fDone = true;
419 return false; 427 return false;
420 } 428 }
421 if (fFilter) { 429 if (fFilter) {
422 if (!fFilter->filter(paint, drawType)) { 430 if (!fFilter->filter(paint, drawType)) {
423 fDone = true; 431 fDone = true;
424 return false; 432 return false;
425 } 433 }
426 if (NULL == fLooper) { 434 if (NULL == fLooper) {
427 // no looper means we only draw once 435 // no looper means we only draw once
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 return *paint; 2226 return *paint;
2219 } 2227 }
2220 2228
2221 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } 2229 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); }
2222 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } 2230 int SkCanvas::LayerIter::x() const { return fImpl->getX(); }
2223 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } 2231 int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
2224 2232
2225 /////////////////////////////////////////////////////////////////////////////// 2233 ///////////////////////////////////////////////////////////////////////////////
2226 2234
2227 SkCanvas::ClipVisitor::~ClipVisitor() { } 2235 SkCanvas::ClipVisitor::~ClipVisitor() { }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698