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

Side by Side Diff: ui/gfx/canvas_skia.h

Issue 8383028: ui/gfx: Convert Canvas::ClipRectInt() to use gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 9 years, 1 month 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 | « ui/gfx/canvas_direct2d_unittest.cc ('k') | ui/gfx/canvas_skia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef UI_GFX_CANVAS_SKIA_H_ 5 #ifndef UI_GFX_CANVAS_SKIA_H_
6 #define UI_GFX_CANVAS_SKIA_H_ 6 #define UI_GFX_CANVAS_SKIA_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/string16.h" 12 #include "base/string16.h"
12 #include "skia/ext/platform_canvas.h" 13 #include "skia/ext/platform_canvas.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 15
15 #if defined(TOOLKIT_USES_GTK) 16 #if defined(TOOLKIT_USES_GTK)
16 typedef struct _GdkPixbuf GdkPixbuf; 17 typedef struct _GdkPixbuf GdkPixbuf;
17 #endif 18 #endif
18 19
19 namespace gfx { 20 namespace gfx {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const SkColor& text_color, 88 const SkColor& text_color,
88 const SkColor& halo_color, 89 const SkColor& halo_color,
89 int x, int y, int w, int h, 90 int x, int y, int w, int h,
90 int flags); 91 int flags);
91 #endif 92 #endif
92 93
93 // Extracts a bitmap from the contents of this canvas. 94 // Extracts a bitmap from the contents of this canvas.
94 SkBitmap ExtractBitmap() const; 95 SkBitmap ExtractBitmap() const;
95 96
96 // Overridden from Canvas: 97 // Overridden from Canvas:
97 virtual void Save(); 98 virtual void Save() OVERRIDE;
98 virtual void SaveLayerAlpha(uint8 alpha); 99 virtual void SaveLayerAlpha(uint8 alpha) OVERRIDE;
99 virtual void SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds); 100 virtual void SaveLayerAlpha(uint8 alpha,
100 virtual void Restore(); 101 const gfx::Rect& layer_bounds) OVERRIDE;
101 virtual bool ClipRectInt(int x, int y, int w, int h); 102 virtual void Restore() OVERRIDE;
102 virtual void TranslateInt(int x, int y); 103 virtual bool ClipRectInt(const gfx::Rect& rect) OVERRIDE;
103 virtual void ScaleInt(int x, int y); 104 virtual void TranslateInt(int x, int y) OVERRIDE;
104 virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h); 105 virtual void ScaleInt(int x, int y) OVERRIDE;
105 virtual void FillRectInt(const SkColor& color, int x, int y, int w, int h, 106 virtual void FillRectInt(const SkColor& color,
106 SkXfermode::Mode mode); 107 int x, int y, int w, int h) OVERRIDE;
107 virtual void FillRectInt(const gfx::Brush* brush, int x, int y, int w, int h); 108 virtual void FillRectInt(const SkColor& color,
108 virtual void DrawRectInt(const SkColor& color, int x, int y, int w, int h); 109 int x, int y, int w, int h,
110 SkXfermode::Mode mode) OVERRIDE;
111 virtual void FillRectInt(const gfx::Brush* brush,
112 int x, int y, int w, int h) OVERRIDE;
113 virtual void DrawRectInt(const SkColor& color,
114 int x, int y, int w, int h) OVERRIDE;
109 virtual void DrawRectInt(const SkColor& color, 115 virtual void DrawRectInt(const SkColor& color,
110 int x, int y, int w, int h, 116 int x, int y, int w, int h,
111 SkXfermode::Mode mode); 117 SkXfermode::Mode mode) OVERRIDE;
112 virtual void DrawRectInt(int x, int y, int w, int h, const SkPaint& paint); 118 virtual void DrawRectInt(int x, int y, int w, int h,
119 const SkPaint& paint) OVERRIDE;
113 virtual void DrawLineInt(const SkColor& color, 120 virtual void DrawLineInt(const SkColor& color,
114 int x1, int y1, 121 int x1, int y1,
115 int x2, int y2); 122 int x2, int y2) OVERRIDE;
116 virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y); 123 virtual void DrawBitmapInt(const SkBitmap& bitmap, int x, int y) OVERRIDE;
117 virtual void DrawBitmapInt(const SkBitmap& bitmap, 124 virtual void DrawBitmapInt(const SkBitmap& bitmap,
118 int x, int y, 125 int x, int y,
119 const SkPaint& paint); 126 const SkPaint& paint) OVERRIDE;
120 virtual void DrawBitmapInt(const SkBitmap& bitmap, 127 virtual void DrawBitmapInt(const SkBitmap& bitmap,
121 int src_x, int src_y, int src_w, int src_h, 128 int src_x, int src_y, int src_w, int src_h,
122 int dest_x, int dest_y, int dest_w, int dest_h, 129 int dest_x, int dest_y, int dest_w, int dest_h,
123 bool filter); 130 bool filter) OVERRIDE;
124 virtual void DrawBitmapInt(const SkBitmap& bitmap, 131 virtual void DrawBitmapInt(const SkBitmap& bitmap,
125 int src_x, int src_y, int src_w, int src_h, 132 int src_x, int src_y, int src_w, int src_h,
126 int dest_x, int dest_y, int dest_w, int dest_h, 133 int dest_x, int dest_y, int dest_w, int dest_h,
127 bool filter, 134 bool filter,
128 const SkPaint& paint); 135 const SkPaint& paint) OVERRIDE;
129 virtual void DrawStringInt(const string16& text, 136 virtual void DrawStringInt(const string16& text,
130 const gfx::Font& font, 137 const gfx::Font& font,
131 const SkColor& color, 138 const SkColor& color,
132 int x, int y, int w, int h); 139 int x, int y, int w, int h) OVERRIDE;
133 virtual void DrawStringInt(const string16& text, 140 virtual void DrawStringInt(const string16& text,
134 const gfx::Font& font, 141 const gfx::Font& font,
135 const SkColor& color, 142 const SkColor& color,
136 const gfx::Rect& display_rect); 143 const gfx::Rect& display_rect) OVERRIDE;
137 virtual void DrawStringInt(const string16& text, 144 virtual void DrawStringInt(const string16& text,
138 const gfx::Font& font, 145 const gfx::Font& font,
139 const SkColor& color, 146 const SkColor& color,
140 int x, int y, int w, int h, 147 int x, int y, int w, int h,
141 int flags); 148 int flags) OVERRIDE;
142 #if defined(OS_WIN) 149 #if defined(OS_WIN)
143 // Draws the given string with the beginning and/or the end using a fade 150 // Draws the given string with the beginning and/or the end using a fade
144 // gradient. When truncating the head 151 // gradient. When truncating the head
145 // |desired_characters_to_truncate_from_head| specifies the maximum number of 152 // |desired_characters_to_truncate_from_head| specifies the maximum number of
146 // characters that can be truncated. 153 // characters that can be truncated.
147 virtual void DrawFadeTruncatingString( 154 virtual void DrawFadeTruncatingString(
148 const string16& text, 155 const string16& text,
149 TruncateFadeMode truncate_mode, 156 TruncateFadeMode truncate_mode,
150 size_t desired_characters_to_truncate_from_head, 157 size_t desired_characters_to_truncate_from_head,
151 const gfx::Font& font, 158 const gfx::Font& font,
152 const SkColor& color, 159 const SkColor& color,
153 const gfx::Rect& display_rect); 160 const gfx::Rect& display_rect);
154 #endif 161 #endif
155 virtual void DrawFocusRect(const gfx::Rect& rect); 162 virtual void DrawFocusRect(const gfx::Rect& rect) OVERRIDE;
156 virtual void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h); 163 virtual void TileImageInt(const SkBitmap& bitmap,
164 int x, int y, int w, int h) OVERRIDE;
157 virtual void TileImageInt(const SkBitmap& bitmap, 165 virtual void TileImageInt(const SkBitmap& bitmap,
158 int src_x, int src_y, 166 int src_x, int src_y,
159 int dest_x, int dest_y, int w, int h); 167 int dest_x, int dest_y, int w, int h) OVERRIDE;
160 virtual gfx::NativeDrawingContext BeginPlatformPaint(); 168 virtual gfx::NativeDrawingContext BeginPlatformPaint() OVERRIDE;
161 virtual void EndPlatformPaint(); 169 virtual void EndPlatformPaint() OVERRIDE;
162 #if !defined(OS_MACOSX) 170 #if !defined(OS_MACOSX)
163 virtual void Transform(const ui::Transform& transform); 171 virtual void Transform(const ui::Transform& transform) OVERRIDE;
164 #endif 172 #endif
165 virtual ui::TextureID GetTextureID(); 173 virtual ui::TextureID GetTextureID() OVERRIDE;
166 virtual CanvasSkia* AsCanvasSkia(); 174 virtual CanvasSkia* AsCanvasSkia() OVERRIDE;
167 virtual const CanvasSkia* AsCanvasSkia() const; 175 virtual const CanvasSkia* AsCanvasSkia() const OVERRIDE;
168 virtual SkCanvas* GetSkCanvas(); 176 virtual SkCanvas* GetSkCanvas() OVERRIDE;
169 virtual const SkCanvas* GetSkCanvas() const; 177 virtual const SkCanvas* GetSkCanvas() const OVERRIDE;
178
170 SkCanvas* sk_canvas() const { return canvas_; } 179 SkCanvas* sk_canvas() const { return canvas_; }
171 skia::PlatformCanvas* platform_canvas() const { return owned_canvas_.get(); } 180 skia::PlatformCanvas* platform_canvas() const { return owned_canvas_.get(); }
172 181
173 private: 182 private:
174 // Test whether the provided rectangle intersects the current clip rect. 183 // Test whether the provided rectangle intersects the current clip rect.
175 bool IntersectsClipRectInt(int x, int y, int w, int h); 184 bool IntersectsClipRectInt(int x, int y, int w, int h);
176 185
177 #if defined(OS_WIN) 186 #if defined(OS_WIN)
178 // Draws text with the specified color, font and location. The text is 187 // Draws text with the specified color, font and location. The text is
179 // aligned to the left, vertically centered, clipped to the region. If the 188 // aligned to the left, vertically centered, clipped to the region. If the
180 // text is too big, it is truncated and '...' is added to the end. 189 // text is too big, it is truncated and '...' is added to the end.
181 void DrawStringInt(const string16& text, 190 void DrawStringInt(const string16& text,
182 HFONT font, 191 HFONT font,
183 const SkColor& color, 192 const SkColor& color,
184 int x, int y, int w, int h, 193 int x, int y, int w, int h,
185 int flags); 194 int flags);
186 #endif 195 #endif
187 196
188 scoped_ptr<skia::PlatformCanvas> owned_canvas_; 197 scoped_ptr<skia::PlatformCanvas> owned_canvas_;
189 SkCanvas* canvas_; 198 SkCanvas* canvas_;
190 DISALLOW_COPY_AND_ASSIGN(CanvasSkia); 199 DISALLOW_COPY_AND_ASSIGN(CanvasSkia);
191 }; 200 };
192 201
193 } // namespace gfx; 202 } // namespace gfx;
194 203
195 #endif // UI_GFX_CANVAS_SKIA_H_ 204 #endif // UI_GFX_CANVAS_SKIA_H_
OLDNEW
« no previous file with comments | « ui/gfx/canvas_direct2d_unittest.cc ('k') | ui/gfx/canvas_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698