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 5cf79cc4b3e8a823731a10f01098d1bae7ce2f38..0bd9f2ca8f536e5f211b12ebddc2c2f18559034f 100644 |
--- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp |
@@ -36,10 +36,14 @@ |
#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/ImageBuffer.h" |
#include "platform/graphics/LinkHighlight.h" |
#include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
#include "platform/graphics/paint/DrawingRecorder.h" |
@@ -1065,7 +1069,58 @@ void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum |
RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; |
if (image && skImage && image->isBitmapImage()) { |
- if (respectImageOrientation == RespectImageOrientation) { |
+ 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. |
+ // FIXME: alternative is to somehow cache this local drawing on this GraphicsLayer, which would |
+ // save having to plumb transform SkColorFilters through to the GPU process, or else have BitmapImage |
+ // cache color corrected images and provide the appropriate image here. |
+ // 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?). |
+ |
+ /* |
+ bool opaque = image->currentFrameKnownToBeOpaque(); |
+ OwnPtr<ImageBuffer> buffer = ImageBuffer::create(image->size(), opaque ? Opaque : NonOpaque); |
+ IntRect source = IntRect(IntPoint(), image->size()); |
+ image->draw(buffer->canvas(), SkPaint(), source, source, DoNotRespectImageOrientation, Image::ClampImageToSourceRect); |
+ skImage = buffer->newSkImageSnapshot(PreferNoAcceleration); |
+ */ |
+ |
+ OwnPtr<PaintController> paintController = PaintController::create(); |
+ GraphicsContext context(*paintController); |
+ |
+ FloatRect bounds(0, 0, image->size().width(), image->size().width()); |
+ context.beginRecording(bounds); |
+ context.drawImage(image, IntRect(0, 0, image->size().width(), image->size().width())); |
+ RefPtr<const SkPicture> picture = context.endRecording(); |
+ |
+ SkISize skISize = SkISize::Make(image->size().width(), image->size().width()); |
+ skImage = SkImage::NewFromPicture(picture.get(), skISize, nullptr, nullptr); |
+ |
+ /* |
+ FIXME: SkRef counting on the SkImage counting ASSERTs on the Mac Release try: find out why. |
Noel Gordon
2015/12/01 03:15:47
Need an adoptRef at the end:
skImage = adoptRef
Noel Gordon
2015/12/01 03:18:09
And similarly for the skImage created @ line 1100
|
+ SkPictureRecorder recorder; |
+ SkRect bounds = SkRect::MakeIWH(skImage->width(), skImage->height()); |
+ SkCanvas* canvas = recorder.beginRecording(bounds, nullptr, 0); |
+ |
+ SkPaint defaultPaint; |
+ canvas->drawImageRect(skImage.get(), bounds, bounds, &defaultPaint, SkCanvas::kStrict_SrcRectConstraint); |
+ RefPtr<SkPicture> picture = adoptRef(recorder.endRecording()); |
+ |
+ SkPaint transformPaint; |
+ RefPtr<ColorSpaceProfile> screen = screenColorProfile(currentScreenId()); |
+ RefPtr<ColorSpaceProfile> source = toBitmapImage(image)->colorProfile(); |
+ if (RefPtr<SkColorFilter> colorTransform = createColorSpaceFilter(source.get(), screen.get())) |
+ transformPaint.setColorFilter(colorTransform.get()); |
+ |
+ SkISize skISize = SkISize::Make(skImage->width(), skImage->height()); |
+ skImage = SkImage::NewFromPicture(picture.get(), skISize, nullptr, &transformPaint); |
+ */ |
+ } |
+ |
+ if (skImage && respectImageOrientation == RespectImageOrientation) { |
ImageOrientation imageOrientation = toBitmapImage(image)->currentFrameOrientation(); |
skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOrientation); |
} |