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

Side by Side Diff: Source/platform/graphics/GraphicsLayer.cpp

Issue 352873002: [wip] image color correction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "platform/graphics/GraphicsLayer.h" 28 #include "platform/graphics/GraphicsLayer.h"
29 29
30 #include "SkImageFilter.h" 30 #include "SkImageFilter.h"
31 #include "SkMatrix44.h" 31 #include "SkMatrix44.h"
32 #include "platform/geometry/FloatRect.h" 32 #include "platform/geometry/FloatRect.h"
33 #include "platform/geometry/LayoutRect.h" 33 #include "platform/geometry/LayoutRect.h"
34 #include "platform/graphics/BitmapImage.h"
35 #include "platform/graphics/GraphicsContext.h"
34 #include "platform/graphics/GraphicsLayerFactory.h" 36 #include "platform/graphics/GraphicsLayerFactory.h"
35 #include "platform/graphics/Image.h" 37 #include "platform/graphics/Image.h"
38 #include "platform/graphics/ImageBuffer.h"
36 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" 39 #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
37 #include "platform/graphics/skia/NativeImageSkia.h" 40 #include "platform/graphics/skia/NativeImageSkia.h"
38 #include "platform/scroll/ScrollableArea.h" 41 #include "platform/scroll/ScrollableArea.h"
39 #include "platform/text/TextStream.h" 42 #include "platform/text/TextStream.h"
40 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
41 #include "public/platform/WebAnimation.h" 44 #include "public/platform/WebAnimation.h"
42 #include "public/platform/WebCompositorSupport.h" 45 #include "public/platform/WebCompositorSupport.h"
43 #include "public/platform/WebFilterOperations.h" 46 #include "public/platform/WebFilterOperations.h"
44 #include "public/platform/WebFloatPoint.h" 47 #include "public/platform/WebFloatPoint.h"
45 #include "public/platform/WebFloatRect.h" 48 #include "public/platform/WebFloatRect.h"
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 } 1005 }
1003 1006
1004 void GraphicsLayer::setContentsToImage(Image* image) 1007 void GraphicsLayer::setContentsToImage(Image* image)
1005 { 1008 {
1006 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : nullptr; 1009 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : nullptr;
1007 if (nativeImage) { 1010 if (nativeImage) {
1008 if (!m_imageLayer) { 1011 if (!m_imageLayer) {
1009 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateImageLayer()); 1012 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateImageLayer());
1010 registerContentsLayer(m_imageLayer->layer()); 1013 registerContentsLayer(m_imageLayer->layer());
1011 } 1014 }
1012 m_imageLayer->setBitmap(nativeImage->bitmap()); 1015 bool opaque = image->currentFrameKnownToBeOpaque();
1013 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); 1016 if (image->isBitmapImage() && toBitmapImage(image)->colorProfile()) {
1017 // FIXME: paint-time color-correction is assumed here, and note that image
1018 // layers are the pathway to the GPU-based color correction.
1019 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(image->size(), opaq ue ? Opaque : NonOpaque);
Stephen White 2014/07/03 18:38:17 Rather than create an ImageBuffer here (incurring
1020 buffer->context()->drawImage(image, IntPoint());
1021 m_imageLayer->setBitmap(buffer->bitmap());
1022 } else {
1023 m_imageLayer->setBitmap(nativeImage->bitmap());
1024 }
1025 m_imageLayer->layer()->setOpaque(opaque);
1014 updateContentsRect(); 1026 updateContentsRect();
1027 setContentsTo(m_imageLayer->layer());
1015 } else { 1028 } else {
1016 if (m_imageLayer) { 1029 if (m_imageLayer) {
1017 unregisterContentsLayer(m_imageLayer->layer()); 1030 unregisterContentsLayer(m_imageLayer->layer());
1018 m_imageLayer.clear(); 1031 m_imageLayer.clear();
1032 setContentsTo(0);
1019 } 1033 }
1020 } 1034 }
1021
1022 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0);
1023 } 1035 }
1024 1036
1025 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture ) 1037 void GraphicsLayer::setContentsToNinePatch(Image* image, const IntRect& aperture )
1026 { 1038 {
1027 if (m_ninePatchLayer) { 1039 if (m_ninePatchLayer) {
1028 unregisterContentsLayer(m_ninePatchLayer->layer()); 1040 unregisterContentsLayer(m_ninePatchLayer->layer());
1029 m_ninePatchLayer.clear(); 1041 m_ninePatchLayer.clear();
1030 } 1042 }
1031 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : nullptr; 1043 RefPtr<NativeImageSkia> nativeImage = image ? image->nativeImageForCurrentFr ame() : nullptr;
1032 if (nativeImage) { 1044 if (nativeImage) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 m_layer->layer()->setScrollClient(0); 1211 m_layer->layer()->setScrollClient(0);
1200 else 1212 else
1201 m_layer->layer()->setScrollClient(this); 1213 m_layer->layer()->setScrollClient(this);
1202 } 1214 }
1203 1215
1204 void GraphicsLayer::paint(GraphicsContext& context, const IntRect& clip) 1216 void GraphicsLayer::paint(GraphicsContext& context, const IntRect& clip)
1205 { 1217 {
1206 paintGraphicsLayerContents(context, clip); 1218 paintGraphicsLayerContents(context, clip);
1207 } 1219 }
1208 1220
1209
1210 void GraphicsLayer::notifyAnimationStarted(double monotonicTime, WebAnimation::T argetProperty) 1221 void GraphicsLayer::notifyAnimationStarted(double monotonicTime, WebAnimation::T argetProperty)
1211 { 1222 {
1212 if (m_client) 1223 if (m_client)
1213 m_client->notifyAnimationStarted(this, monotonicTime); 1224 m_client->notifyAnimationStarted(this, monotonicTime);
1214 } 1225 }
1215 1226
1216 void GraphicsLayer::notifyAnimationFinished(double, WebAnimation::TargetProperty ) 1227 void GraphicsLayer::notifyAnimationFinished(double, WebAnimation::TargetProperty )
1217 { 1228 {
1218 // Do nothing. 1229 // Do nothing.
1219 } 1230 }
1220 1231
1221 void GraphicsLayer::didScroll() 1232 void GraphicsLayer::didScroll()
1222 { 1233 {
1223 if (m_scrollableArea) 1234 if (m_scrollableArea)
1224 m_scrollableArea->scrollToOffsetWithoutAnimation(m_scrollableArea->minim umScrollPosition() + toIntSize(m_layer->layer()->scrollPosition())); 1235 m_scrollableArea->scrollToOffsetWithoutAnimation(m_scrollableArea->minim umScrollPosition() + toIntSize(m_layer->layer()->scrollPosition()));
1225 } 1236 }
1226 1237
1227 } // namespace WebCore 1238 } // namespace WebCore
1228 1239
1229 #ifndef NDEBUG 1240 #ifndef NDEBUG
1230 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) 1241 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
1231 { 1242 {
1232 if (!layer) 1243 if (!layer)
1233 return; 1244 return;
1234 1245
1235 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); 1246 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo);
1236 fprintf(stderr, "%s\n", output.utf8().data()); 1247 fprintf(stderr, "%s\n", output.utf8().data());
1237 } 1248 }
1238 #endif 1249 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698