Index: third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
index bbb2640ffc9a99251b33a9ec563f03d235bea0c1..497f4189d30b15ba4c4f471828adf855ec87b267 100644 |
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
@@ -35,9 +35,12 @@ |
#include "platform/geometry/FloatRect.h" |
#include "platform/geometry/LayoutRect.h" |
#include "platform/graphics/BitmapImage.h" |
+#include "platform/graphics/ColorSpaceFilter.h" |
+#include "platform/graphics/ColorSpaceProfile.h" |
#include "platform/graphics/FirstPaintInvalidationTracking.h" |
#include "platform/graphics/GraphicsContext.h" |
#include "platform/graphics/GraphicsLayerFactory.h" |
+#include "platform/graphics/GraphicsScreen.h" |
#include "platform/graphics/Image.h" |
#include "platform/graphics/LinkHighlight.h" |
#include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
@@ -1082,8 +1085,30 @@ void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum |
{ |
RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; |
- if (image && skImage && image->isBitmapImage()) { |
- if (respectImageOrientation == RespectImageOrientation) { |
+ RefPtr<SkColorFilter> colorTransform; |
+ |
+ if (skImage && image->isBitmapImage()) { |
+ RELEASE_ASSERT(currentScreenId()); // There should be an active graphics screen. |
+ |
+ if (imageColorProfilesEnabled() && toBitmapImage(image)->hasColorProfile()) { |
+ // FIXME: maybe pass the color transform filter to the layer so it gets applied on the GPU. |
+ // we now pass the colorTransform filter, which gets attached to our cc::Layer |
+ // as a cc::FilterOperation. Note: CSS filters on this <img> element excludes |
+ // this element from being in a layer. Thus, this filter passing method does |
+ // not break CSS filter style application on <img> elements. |
+ // FIXME: In an experiment, I passed a SkColorCubeFilter to the GPU and that works. But note |
+ // that SkColorCurveFilter does not: it gets dropped on floor somewhere after CC sends it to |
+ // the GPU process (maybe because SkColorCurveFilter has float-16 textures, whereas |
+ // SkColorCubeFilter does not?). |
+ // OIC, the GPU command buffer does not currently support GL_HALF_FLOAT |
+ // textures, bless their cotton socks. |
+ if (RefPtr<ColorSpaceProfile> source = toBitmapImage(image)->colorProfile()) { |
+ RefPtr<ColorSpaceProfile> target = screenColorProfile(currentScreenId()); |
+ colorTransform = createColorSpaceFilter(source.get(), target.get()); |
+ } |
+ } |
+ |
+ if (skImage && respectImageOrientation == RespectImageOrientation) { |
ImageOrientation imageOrientation = toBitmapImage(image)->currentFrameOrientation(); |
skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOrientation); |
} |
@@ -1094,7 +1119,11 @@ void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum |
m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->createImageLayer()); |
registerContentsLayer(m_imageLayer->layer()); |
} |
- m_imageLayer->setImage(skImage.get()); |
+ if (RefPtr<SkColorFilter> transform = colorSpaceFlattenableFilter(colorTransform.get())) { |
+ m_imageLayer->setImage(skImage.get(), transform.get()); |
+ } else { |
+ m_imageLayer->setImage(skImage.get(), nullptr); |
+ } |
m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); |
updateContentsRect(); |
} else { |