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

Unified Diff: third_party/WebKit/Source/platform/graphics/Color.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/Color.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Color.cpp b/third_party/WebKit/Source/platform/graphics/Color.cpp
index dc9364edbde2bea1f7c0a43392244b658f961551..2d4a6cb474efed653ad3c038051d28be3aaa9d7b 100644
--- a/third_party/WebKit/Source/platform/graphics/Color.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Color.cpp
@@ -26,6 +26,11 @@
#include "platform/graphics/Color.h"
#include "platform/Decimal.h"
+#include "platform/graphics/ColorSpaceFilter.h"
+#include "platform/graphics/ColorSpaceProfile.h"
+#include "platform/graphics/GraphicsScreen.h"
+#include "platform/graphics/skia/SkiaUtils.h"
+#include "third_party/skia/include/core/SkColorFilter.h"
#include "wtf/Assertions.h"
#include "wtf/HexNumber.h"
#include "wtf/MathExtras.h"
@@ -454,4 +459,28 @@ RGBA32 premultipliedARGBFromColor(const Color& color)
return pixelColor;
}
+Color Color::toDeviceColor(const Color& color)
+{
+ if (!imageColorProfilesEnabled())
+ return color;
+
+ 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)
+ return Color::asDeviceColor(color);
+
+ RELEASE_ASSERT(!color.isDeviceColor());
+
+ SkColor skColor = colorTransform->filterColor(SkColorSetARGB(color.alpha(), color.red(), color.green(), color.blue()));
+ int r = SkColorGetR(skColor);
+ int g = SkColorGetG(skColor);
+ int b = SkColorGetB(skColor);
+ int a = SkColorGetA(skColor);
+
+ return Color::asDeviceColor(Color(r, g, b, a));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Color.h ('k') | third_party/WebKit/Source/platform/graphics/ColorSpaceFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698