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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.h

Issue 2625403002: Prefer newly added SkPaint::refFoo() over getFoo() (Closed)
Patch Set: inline SkComposeImageFilter construction Created 3 years, 11 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BaseRenderingContext2D_h 5 #ifndef BaseRenderingContext2D_h
6 #define BaseRenderingContext2D_h 6 #define BaseRenderingContext2D_h
7 7
8 #include "bindings/modules/v8/CSSImageValueOrHTMLImageElementOrHTMLVideoElementO rHTMLCanvasElementOrImageBitmapOrOffscreenCanvas.h" 8 #include "bindings/modules/v8/CSSImageValueOrHTMLImageElementOrHTMLVideoElementO rHTMLCanvasElementOrImageBitmapOrOffscreenCanvas.h"
9 #include "bindings/modules/v8/StringOrCanvasGradientOrCanvasPattern.h" 9 #include "bindings/modules/v8/StringOrCanvasGradientOrCanvasPattern.h"
10 #include "core/html/ImageData.h" 10 #include "core/html/ImageData.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 SkPaint compositePaint; 436 SkPaint compositePaint;
437 compositePaint.setBlendMode((SkBlendMode)state().globalComposite()); 437 compositePaint.setBlendMode((SkBlendMode)state().globalComposite());
438 if (state().shouldDrawShadows()) { 438 if (state().shouldDrawShadows()) {
439 // unroll into two independently composited passes if drawing shadows 439 // unroll into two independently composited passes if drawing shadows
440 SkPaint shadowPaint = 440 SkPaint shadowPaint =
441 *state().getPaint(paintType, DrawShadowOnly, imageType); 441 *state().getPaint(paintType, DrawShadowOnly, imageType);
442 int saveCount = c->getSaveCount(); 442 int saveCount = c->getSaveCount();
443 if (filter) { 443 if (filter) {
444 SkPaint foregroundPaint = 444 SkPaint foregroundPaint =
445 *state().getPaint(paintType, DrawForegroundOnly, imageType); 445 *state().getPaint(paintType, DrawForegroundOnly, imageType);
446 sk_sp<SkImageFilter> composedFilter = 446 foregroundPaint.setImageFilter(SkComposeImageFilter::Make(
447 sk_ref_sp(foregroundPaint.getImageFilter()); 447 SkComposeImageFilter::Make(foregroundPaint.refImageFilter(),
448 composedFilter = SkComposeImageFilter::Make( 448 shadowPaint.refImageFilter()),
449 std::move(composedFilter), sk_ref_sp(shadowPaint.getImageFilter())); 449 filter));
450 composedFilter =
451 SkComposeImageFilter::Make(std::move(composedFilter), filter);
452 foregroundPaint.setImageFilter(std::move(composedFilter));
453 c->setMatrix(ctm); 450 c->setMatrix(ctm);
454 drawFunc(c, &foregroundPaint); 451 drawFunc(c, &foregroundPaint);
455 } else { 452 } else {
456 ASSERT(isFullCanvasCompositeMode(state().globalComposite())); 453 ASSERT(isFullCanvasCompositeMode(state().globalComposite()));
457 c->saveLayer(nullptr, &compositePaint); 454 c->saveLayer(nullptr, &compositePaint);
458 shadowPaint.setBlendMode(SkBlendMode::kSrcOver); 455 shadowPaint.setBlendMode(SkBlendMode::kSrcOver);
459 c->setMatrix(ctm); 456 c->setMatrix(ctm);
460 drawFunc(c, &shadowPaint); 457 drawFunc(c, &shadowPaint);
461 } 458 }
462 c->restoreToCount(saveCount); 459 c->restoreToCount(saveCount);
463 } 460 }
464 461
465 compositePaint.setImageFilter(std::move(filter)); 462 compositePaint.setImageFilter(std::move(filter));
466 c->saveLayer(nullptr, &compositePaint); 463 c->saveLayer(nullptr, &compositePaint);
467 SkPaint foregroundPaint = 464 SkPaint foregroundPaint =
468 *state().getPaint(paintType, DrawForegroundOnly, imageType); 465 *state().getPaint(paintType, DrawForegroundOnly, imageType);
469 foregroundPaint.setBlendMode(SkBlendMode::kSrcOver); 466 foregroundPaint.setBlendMode(SkBlendMode::kSrcOver);
470 c->setMatrix(ctm); 467 c->setMatrix(ctm);
471 drawFunc(c, &foregroundPaint); 468 drawFunc(c, &foregroundPaint);
472 c->restore(); 469 c->restore();
473 c->setMatrix(ctm); 470 c->setMatrix(ctm);
474 } 471 }
475 472
476 } // namespace blink 473 } // namespace blink
477 474
478 #endif // BaseRenderingContext2D_h 475 #endif // BaseRenderingContext2D_h
OLDNEW
« no previous file with comments | « cc/output/software_renderer.cc ('k') | third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698