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

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

Issue 1331533002: [poc] curve-filter Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Ensure screen device profiles are matrix Created 4 years, 12 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
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 17 matching lines...) Expand all
28 #include "SkImageFilter.h" 28 #include "SkImageFilter.h"
29 #include "SkMatrix44.h" 29 #include "SkMatrix44.h"
30 #include "base/trace_event/trace_event_argument.h" 30 #include "base/trace_event/trace_event_argument.h"
31 #include "cc/layers/layer.h" 31 #include "cc/layers/layer.h"
32 #include "platform/DragImage.h" 32 #include "platform/DragImage.h"
33 #include "platform/JSONValues.h" 33 #include "platform/JSONValues.h"
34 #include "platform/TraceEvent.h" 34 #include "platform/TraceEvent.h"
35 #include "platform/geometry/FloatRect.h" 35 #include "platform/geometry/FloatRect.h"
36 #include "platform/geometry/LayoutRect.h" 36 #include "platform/geometry/LayoutRect.h"
37 #include "platform/graphics/BitmapImage.h" 37 #include "platform/graphics/BitmapImage.h"
38 #include "platform/graphics/ColorSpaceFilter.h"
39 #include "platform/graphics/ColorSpaceProfile.h"
38 #include "platform/graphics/FirstPaintInvalidationTracking.h" 40 #include "platform/graphics/FirstPaintInvalidationTracking.h"
39 #include "platform/graphics/GraphicsContext.h" 41 #include "platform/graphics/GraphicsContext.h"
40 #include "platform/graphics/GraphicsLayerFactory.h" 42 #include "platform/graphics/GraphicsLayerFactory.h"
43 #include "platform/graphics/GraphicsScreen.h"
41 #include "platform/graphics/Image.h" 44 #include "platform/graphics/Image.h"
42 #include "platform/graphics/LinkHighlight.h" 45 #include "platform/graphics/LinkHighlight.h"
43 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" 46 #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
44 #include "platform/graphics/paint/DrawingRecorder.h" 47 #include "platform/graphics/paint/DrawingRecorder.h"
45 #include "platform/graphics/paint/PaintController.h" 48 #include "platform/graphics/paint/PaintController.h"
46 #include "platform/scroll/ScrollableArea.h" 49 #include "platform/scroll/ScrollableArea.h"
47 #include "platform/text/TextStream.h" 50 #include "platform/text/TextStream.h"
48 #include "public/platform/Platform.h" 51 #include "public/platform/Platform.h"
49 #include "public/platform/WebCompositorAnimation.h" 52 #include "public/platform/WebCompositorAnimation.h"
50 #include "public/platform/WebCompositorSupport.h" 53 #include "public/platform/WebCompositorSupport.h"
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 return; 1078 return;
1076 1079
1077 m_contentsRect = rect; 1080 m_contentsRect = rect;
1078 updateContentsRect(); 1081 updateContentsRect();
1079 } 1082 }
1080 1083
1081 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum respectImageOrientation) 1084 void GraphicsLayer::setContentsToImage(Image* image, RespectImageOrientationEnum respectImageOrientation)
1082 { 1085 {
1083 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr; 1086 RefPtr<SkImage> skImage = image ? image->imageForCurrentFrame() : nullptr;
1084 1087
1085 if (image && skImage && image->isBitmapImage()) { 1088 RefPtr<SkColorFilter> colorTransform;
1086 if (respectImageOrientation == RespectImageOrientation) { 1089
1090 if (skImage && image->isBitmapImage()) {
1091 RELEASE_ASSERT(currentScreenId()); // There should be an active graphics screen.
1092
1093 if (imageColorProfilesEnabled() && toBitmapImage(image)->hasColorProfile ()) {
1094 // FIXME: maybe pass the color transform filter to the layer so it g ets applied on the GPU.
1095 // we now pass the colorTransform filter, which gets attached to o ur cc::Layer
1096 // as a cc::FilterOperation. Note: CSS filters on this <img> eleme nt excludes
1097 // this element from being in a layer. Thus, this filter passing m ethod does
1098 // not break CSS filter style application on <img> elements.
1099 // FIXME: In an experiment, I passed a SkColorCubeFilter to the GPU and that works. But note
1100 // that SkColorCurveFilter does not: it gets dropped on floor somewh ere after CC sends it to
1101 // the GPU process (maybe because SkColorCurveFilter has float-16 te xtures, whereas
1102 // SkColorCubeFilter does not?).
1103 // OIC, the GPU command buffer does not currently support GL_HALF_ FLOAT
1104 // textures, bless their cotton socks.
1105 if (RefPtr<ColorSpaceProfile> source = toBitmapImage(image)->colorPr ofile()) {
1106 RefPtr<ColorSpaceProfile> target = screenColorProfile(currentScr eenId());
1107 colorTransform = createColorSpaceFilter(source.get(), target.get ());
1108 }
1109 }
1110
1111 if (skImage && respectImageOrientation == RespectImageOrientation) {
1087 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation(); 1112 ImageOrientation imageOrientation = toBitmapImage(image)->currentFra meOrientation();
1088 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr ientation); 1113 skImage = DragImage::resizeAndOrientImage(skImage.release(), imageOr ientation);
1089 } 1114 }
1090 } 1115 }
1091 1116
1092 if (image && skImage) { 1117 if (image && skImage) {
1093 if (!m_imageLayer) { 1118 if (!m_imageLayer) {
1094 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateImageLayer()); 1119 m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->cr eateImageLayer());
1095 registerContentsLayer(m_imageLayer->layer()); 1120 registerContentsLayer(m_imageLayer->layer());
1096 } 1121 }
1097 m_imageLayer->setImage(skImage.get()); 1122 if (RefPtr<SkColorFilter> transform = colorSpaceFlattenableFilter(colorT ransform.get())) {
1123 m_imageLayer->setImage(skImage.get(), transform.get());
1124 } else {
1125 m_imageLayer->setImage(skImage.get(), nullptr);
1126 }
1098 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque()); 1127 m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque());
1099 updateContentsRect(); 1128 updateContentsRect();
1100 } else { 1129 } else {
1101 if (m_imageLayer) { 1130 if (m_imageLayer) {
1102 unregisterContentsLayer(m_imageLayer->layer()); 1131 unregisterContentsLayer(m_imageLayer->layer());
1103 m_imageLayer.clear(); 1132 m_imageLayer.clear();
1104 } 1133 }
1105 } 1134 }
1106 1135
1107 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0); 1136 setContentsTo(m_imageLayer ? m_imageLayer->layer() : 0);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 { 1287 {
1259 if (!layer) { 1288 if (!layer) {
1260 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1289 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1261 return; 1290 return;
1262 } 1291 }
1263 1292
1264 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1293 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1265 fprintf(stderr, "%s\n", output.utf8().data()); 1294 fprintf(stderr, "%s\n", output.utf8().data());
1266 } 1295 }
1267 #endif 1296 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698