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

Unified Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp

Issue 2349183002: Turn FilterEffectBuilder into a stack-allocated helper (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
index f69c0a7f7996765475e141ec7bf88899a148e666..e0c9c60d45b4091e7f80778664e14302a4f79af7 100644
--- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
+++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp
@@ -17,6 +17,7 @@
#include "modules/canvas2d/CanvasRenderingContext2D.h"
#include "modules/canvas2d/CanvasStyle.h"
#include "platform/graphics/DrawLooperBuilder.h"
+#include "platform/graphics/filters/FilterEffect.h"
#include "platform/graphics/filters/FilterOperation.h"
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/graphics/skia/SkiaUtils.h"
@@ -308,21 +309,23 @@ SkImageFilter* CanvasRenderingContext2DState::getFilter(Element* styleResolution
StyleBuilder::applyProperty(CSSPropertyFilter, resolverState, *m_filterValue);
resolverState.loadPendingResources();
- FilterEffectBuilder* filterEffectBuilder = FilterEffectBuilder::create();
// We can't reuse m_fillPaint and m_strokePaint for the filter, since these incorporate
// the global alpha, which isn't applicable here.
SkPaint fillPaintForFilter;
- SkPaint strokePaintForFilter;
m_fillStyle->applyToPaint(fillPaintForFilter);
- m_strokeStyle->applyToPaint(strokePaintForFilter);
fillPaintForFilter.setColor(m_fillStyle->paintColor());
+ SkPaint strokePaintForFilter;
+ m_strokeStyle->applyToPaint(strokePaintForFilter);
strokePaintForFilter.setColor(m_strokeStyle->paintColor());
- FloatRect referenceBox((FloatPoint()), FloatSize(canvasSize));
- const double effectiveZoom = 1.0; // Deliberately ignore zoom on the canvas element
- filterEffectBuilder->build(styleResolutionHost, filterStyle->filter(), effectiveZoom, referenceBox, &fillPaintForFilter, &strokePaintForFilter);
- if (FilterEffect* lastEffect = filterEffectBuilder->lastEffect()) {
+ FilterEffectBuilder filterEffectBuilder(
+ styleResolutionHost,
+ FloatRect((FloatPoint()), FloatSize(canvasSize)),
+ 1.0f, // Deliberately ignore zoom on the canvas element.
+ &fillPaintForFilter, &strokePaintForFilter);
+
+ if (FilterEffect* lastEffect = filterEffectBuilder.buildFilterEffect(filterStyle->filter())) {
m_resolvedFilter = SkiaImageFilterBuilder::build(lastEffect, ColorSpaceDeviceRGB);
if (m_resolvedFilter) {
updateFilterReferences(toHTMLCanvasElement(styleResolutionHost), context, filterStyle->filter());

Powered by Google App Engine
This is Rietveld 408576698