| 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
|
|
|