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

Side by Side Diff: skia/ext/canvas_paint_mac.h

Issue 10545050: mac: Use NSWidth() and friends in a few more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 8 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
« no previous file with comments | « chrome/browser/ui/cocoa/image_button_cell.mm ('k') | skia/ext/skia_utils_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #ifndef SKIA_EXT_CANVAS_PAINT_MAC_H_ 6 #ifndef SKIA_EXT_CANVAS_PAINT_MAC_H_
7 #define SKIA_EXT_CANVAS_PAINT_MAC_H_ 7 #define SKIA_EXT_CANVAS_PAINT_MAC_H_
8 #pragma once 8 #pragma once
9 9
10 #include "skia/ext/canvas_paint_common.h" 10 #include "skia/ext/canvas_paint_common.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // If true, the data painted into the CanvasPaintT is blended onto the current 68 // If true, the data painted into the CanvasPaintT is blended onto the current
69 // context, else it is copied. 69 // context, else it is copied.
70 void set_composite_alpha(bool composite_alpha) { 70 void set_composite_alpha(bool composite_alpha) {
71 composite_alpha_ = composite_alpha; 71 composite_alpha_ = composite_alpha;
72 } 72 }
73 73
74 // Returns true if the invalid region is empty. The caller should call this 74 // Returns true if the invalid region is empty. The caller should call this
75 // function to determine if anything needs painting. 75 // function to determine if anything needs painting.
76 bool is_empty() const { 76 bool is_empty() const {
77 return rectangle_.size.width == 0 || rectangle_.size.height == 0; 77 return NSIsEmptyRect(rectangle_);
78 } 78 }
79 79
80 const NSRect& rectangle() const { 80 const NSRect& rectangle() const {
81 return rectangle_; 81 return rectangle_;
82 } 82 }
83 83
84 private: 84 private:
85 void init(bool opaque) { 85 void init(bool opaque) {
86 PlatformCanvas* canvas = GetPlatformCanvas(this); 86 PlatformCanvas* canvas = GetPlatformCanvas(this);
87 if (!canvas->initialize(rectangle_.size.width, 87 if (!canvas->initialize(NSWidth(rectangle_),
88 rectangle_.size.height, 88 NSHeight(rectangle_),
89 opaque, NULL)) { 89 opaque, NULL)) {
90 // Cause a deliberate crash; 90 // Cause a deliberate crash;
91 *(volatile char*) 0 = 0; 91 *(volatile char*) 0 = 0;
92 } 92 }
93 canvas->clear(SkColorSetARGB(0, 0, 0, 0)); 93 canvas->clear(SkColorSetARGB(0, 0, 0, 0));
94 94
95 // Need to translate so that the dirty region appears at the origin of the 95 // Need to translate so that the dirty region appears at the origin of the
96 // surface. 96 // surface.
97 canvas->translate(-SkDoubleToScalar(rectangle_.origin.x), 97 canvas->translate(-SkDoubleToScalar(NSMinX(rectangle_)),
98 -SkDoubleToScalar(rectangle_.origin.y)); 98 -SkDoubleToScalar(NSMinY(rectangle_)));
99 99
100 context_ = GetBitmapContext(GetTopDevice(*canvas)); 100 context_ = GetBitmapContext(GetTopDevice(*canvas));
101 } 101 }
102 102
103 CGContext* context_; 103 CGContext* context_;
104 NSRect rectangle_; 104 NSRect rectangle_;
105 // See description above setter. 105 // See description above setter.
106 bool composite_alpha_; 106 bool composite_alpha_;
107 107
108 // Disallow copy and assign. 108 // Disallow copy and assign.
109 CanvasPaintT(const CanvasPaintT&); 109 CanvasPaintT(const CanvasPaintT&);
110 CanvasPaintT& operator=(const CanvasPaintT&); 110 CanvasPaintT& operator=(const CanvasPaintT&);
111 }; 111 };
112 112
113 typedef CanvasPaintT<PlatformCanvas> PlatformCanvasPaint; 113 typedef CanvasPaintT<PlatformCanvas> PlatformCanvasPaint;
114 114
115 } // namespace skia 115 } // namespace skia
116 116
117 117
118 #endif // SKIA_EXT_CANVAS_PAINT_MAC_H_ 118 #endif // SKIA_EXT_CANVAS_PAINT_MAC_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/image_button_cell.mm ('k') | skia/ext/skia_utils_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698