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

Side by Side Diff: third_party/WebKit/Source/platform/mac/GraphicsContextCanvas.mm

Issue 2873333002: mac color: Use sRGB for native controls instead of device RGB (Closed)
Patch Set: And roll in the image decode bit Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeMac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/mac/GraphicsContextCanvas.h" 5 #include "platform/mac/GraphicsContextCanvas.h"
6 6
7 #import <AppKit/AppKit.h> 7 #import <AppKit/AppKit.h>
8 #import <CoreGraphics/CoreGraphics.h> 8 #import <CoreGraphics/CoreGraphics.h>
9 9
10 #include "platform/RuntimeEnabledFeatures.h"
10 #include "platform/wtf/RetainPtr.h" 11 #include "platform/wtf/RetainPtr.h"
11 #include "skia/ext/skia_utils_mac.h" 12 #include "skia/ext/skia_utils_mac.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 GraphicsContextCanvas::GraphicsContextCanvas(PaintCanvas* canvas, 16 GraphicsContextCanvas::GraphicsContextCanvas(PaintCanvas* canvas,
16 const SkIRect& user_clip_rect, 17 const SkIRect& user_clip_rect,
17 SkScalar bitmap_scale_factor) 18 SkScalar bitmap_scale_factor)
18 : canvas_(canvas), 19 : canvas_(canvas),
19 cg_context_(0), 20 cg_context_(0),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // non-NULL CGContext to use. 70 // non-NULL CGContext to use.
70 bitmap_is_dummy_ = true; 71 bitmap_is_dummy_ = true;
71 clip_bounds = SkIRect::MakeXYWH(0, 0, 1, 1); 72 clip_bounds = SkIRect::MakeXYWH(0, 0, 1, 1);
72 } 73 }
73 74
74 // remember the top/left, in case we need to compose this later 75 // remember the top/left, in case we need to compose this later
75 bitmap_offset_.set(clip_bounds.x(), clip_bounds.y()); 76 bitmap_offset_.set(clip_bounds.x(), clip_bounds.y());
76 77
77 // Allocate an offscreen and draw into that, relying on the 78 // Allocate an offscreen and draw into that, relying on the
78 // compositing step to apply skia's clip. 79 // compositing step to apply skia's clip.
79 WTF::RetainPtr<CGColorSpace> color_space(CGColorSpaceCreateDeviceRGB()); 80 WTF::RetainPtr<CGColorSpace> color_space(
81 RuntimeEnabledFeatures::colorCorrectRenderingEnabled()
82 ? CGColorSpaceCreateWithName(kCGColorSpaceSRGB)
83 : CGColorSpaceCreateDeviceRGB());
80 84
81 bool result = offscreen_.tryAllocN32Pixels( 85 bool result = offscreen_.tryAllocN32Pixels(
82 SkScalarCeilToInt(bitmap_scale_factor_ * clip_bounds.width()), 86 SkScalarCeilToInt(bitmap_scale_factor_ * clip_bounds.width()),
83 SkScalarCeilToInt(bitmap_scale_factor_ * clip_bounds.height())); 87 SkScalarCeilToInt(bitmap_scale_factor_ * clip_bounds.height()));
84 DCHECK(result); 88 DCHECK(result);
85 if (!result) 89 if (!result)
86 return 0; 90 return 0;
87 offscreen_.eraseColor(0); 91 offscreen_.eraseColor(0);
88 int display_height = offscreen_.height(); 92 int display_height = offscreen_.height();
89 cg_context_ = CGBitmapContextCreate( 93 cg_context_ = CGBitmapContextCreate(
(...skipping 11 matching lines...) Expand all
101 CGContextConcatCTM(cg_context_, skia::SkMatrixToCGAffineTransform(matrix)); 105 CGContextConcatCTM(cg_context_, skia::SkMatrixToCGAffineTransform(matrix));
102 106
103 return cg_context_; 107 return cg_context_;
104 } 108 }
105 109
106 bool GraphicsContextCanvas::HasEmptyClipRegion() const { 110 bool GraphicsContextCanvas::HasEmptyClipRegion() const {
107 return canvas_->isClipEmpty(); 111 return canvas_->isClipEmpty();
108 } 112 }
109 113
110 } // namespace blink 114 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeMac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698