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

Unified Diff: third_party/WebKit/Source/platform/graphics/Gradient.cpp

Issue 1331533002: [poc] curve-filter Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix CanvasRenderingContext2D::createPattern crash for #40 Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/Gradient.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Gradient.cpp b/third_party/WebKit/Source/platform/graphics/Gradient.cpp
index 9736e023b34a5b6db7b8510a48288c9f8ecedcb6..74a2c25f1289f9770ff843b62d10c96172d98904 100644
--- a/third_party/WebKit/Source/platform/graphics/Gradient.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Gradient.cpp
@@ -28,9 +28,13 @@
#include "platform/graphics/Gradient.h"
#include "platform/geometry/FloatRect.h"
+#include "platform/graphics/ColorSpaceFilter.h"
+#include "platform/graphics/ColorSpaceProfile.h"
#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/GraphicsScreen.h"
#include "platform/graphics/skia/SkiaUtils.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkShader.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include <algorithm>
@@ -251,14 +255,35 @@ SkShader* Gradient::shader()
// use last color, since our "geometry" was degenerate (e.g. radius==0)
m_gradient = adoptRef(SkShader::CreateColorShader(colors[countUsed - 1]));
}
+
return m_gradient.get();
}
void Gradient::applyToPaint(SkPaint& paint)
{
- paint.setShader(shader());
+ if (!imageColorProfilesEnabled()) {
+ applyShaderToPaintInternal(shader(), paint);
+ return;
+ }
+
+ RELEASE_ASSERT(currentScreenId());
+
+ // FIXME: the default color transform sRGB->screen is hot: Find a way to cache it. Add API to retrieve it.
+
+ RefPtr<SkColorFilter> colorTransform = createColorSpaceFilter(screenColorProfile(ScreenDevice::sRGB).get(), screenColorProfile(currentScreenId()).get());
+ if (!colorTransform) {
+ applyShaderToPaintInternal(shader(), paint);
+ return;
+ }
+
+ RefPtr<SkShader> transformShader = adoptRef(shader()->newWithColorFilter(colorTransform.get()));
+ if (!transformShader) {
+ applyShaderToPaintInternal(shader(), paint);
+ return;
+ }
- // Legacy behavior: gradients are always dithered.
- paint.setDither(true);
+ // Optionally, find a way to cache the color transformed paint shader too.
+ applyShaderToPaintInternal(transformShader.get(), paint);
}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698