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

Side by Side Diff: chrome/common/gfx/chrome_canvas.cc

Issue 18804: OpaqueNonClientView cleanup (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 11 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/common/gfx/chrome_canvas.h ('k') | chrome/views/custom_frame_window.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/common/gfx/chrome_canvas.h" 5 #include "chrome/common/gfx/chrome_canvas.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/gfx/rect.h" 9 #include "base/gfx/rect.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 SkPaint p(paint); 200 SkPaint p(paint);
201 p.setFilterBitmap(filter); 201 p.setFilterBitmap(filter);
202 p.setShader(shader); 202 p.setShader(shader);
203 shader->unref(); 203 shader->unref();
204 204
205 // The rect will be filled by the bitmap. 205 // The rect will be filled by the bitmap.
206 drawRect(dest_rect, p); 206 drawRect(dest_rect, p);
207 } 207 }
208 208
209 void ChromeCanvas::TileImageInt(const SkBitmap& bitmap, 209 void ChromeCanvas::TileImageInt(const SkBitmap& bitmap,
210 int x, int y, int w, int h, 210 int x, int y, int w, int h) {
211 SkPorterDuff::Mode mode) { 211 TileImageInt(bitmap, 0, 0, x, y, w, h);
212 if (!IntersectsClipRectInt(x, y, w, h)) 212 }
213
214 void ChromeCanvas::TileImageInt(const SkBitmap& bitmap, int src_x, int src_y,
215 int dest_x, int dest_y, int w, int h) {
216 if (!IntersectsClipRectInt(dest_x, dest_y, w, h))
213 return; 217 return;
214 218
215 SkPaint paint; 219 SkPaint paint;
216 220
217 SkShader* shader = SkShader::CreateBitmapShader(bitmap, 221 SkShader* shader = SkShader::CreateBitmapShader(bitmap,
218 SkShader::kRepeat_TileMode, 222 SkShader::kRepeat_TileMode,
219 SkShader::kRepeat_TileMode); 223 SkShader::kRepeat_TileMode);
220 paint.setShader(shader); 224 paint.setShader(shader);
221 paint.setPorterDuffXfermode(mode); 225 paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode);
222 226
223 // CreateBitmapShader returns a Shader with a reference count of one, we 227 // CreateBitmapShader returns a Shader with a reference count of one, we
224 // need to unref after paint takes ownership of the shader. 228 // need to unref after paint takes ownership of the shader.
225 shader->unref(); 229 shader->unref();
226 save(); 230 save();
227 translate(SkIntToScalar(x), SkIntToScalar(y)); 231 translate(SkIntToScalar(dest_x - src_x), SkIntToScalar(dest_y - src_y));
228 ClipRectInt(0, 0, w, h); 232 ClipRectInt(src_x, src_y, w, h);
229 drawPaint(paint); 233 drawPaint(paint);
230 restore(); 234 restore();
231 } 235 }
232 236
233 void ChromeCanvas::TileImageInt(const SkBitmap& bitmap,
234 int x, int y, int w, int h) {
235 TileImageInt(bitmap, x, y, w, h, SkPorterDuff::kSrcOver_Mode);
236 }
237
238 SkBitmap ChromeCanvas::ExtractBitmap() { 237 SkBitmap ChromeCanvas::ExtractBitmap() {
239 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); 238 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false);
240 239
241 // Make a bitmap to return, and a canvas to draw into it. We don't just want 240 // Make a bitmap to return, and a canvas to draw into it. We don't just want
242 // to call extractSubset or the copy constuctor, since we want an actual copy 241 // to call extractSubset or the copy constuctor, since we want an actual copy
243 // of the bitmap. 242 // of the bitmap.
244 SkBitmap result; 243 SkBitmap result;
245 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); 244 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
246 return result; 245 return result;
247 } 246 }
OLDNEW
« no previous file with comments | « chrome/common/gfx/chrome_canvas.h ('k') | chrome/views/custom_frame_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698