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

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

Issue 20011: Improved OTR avatar and popup window rendering. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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') | 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 (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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!IntersectsClipRectInt(x, y, w, h)) 211 TileImageInt(bitmap, 0, 0, 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))
212 return; 217 return;
213 218
214 SkPaint paint; 219 SkPaint paint;
215 220
216 SkShader* shader = SkShader::CreateBitmapShader(bitmap, 221 SkShader* shader = SkShader::CreateBitmapShader(bitmap,
217 SkShader::kRepeat_TileMode, 222 SkShader::kRepeat_TileMode,
218 SkShader::kRepeat_TileMode); 223 SkShader::kRepeat_TileMode);
219 paint.setShader(shader); 224 paint.setShader(shader);
220 paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode); 225 paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode);
221 226
222 // CreateBitmapShader returns a Shader with a reference count of one, we 227 // CreateBitmapShader returns a Shader with a reference count of one, we
223 // need to unref after paint takes ownership of the shader. 228 // need to unref after paint takes ownership of the shader.
224 shader->unref(); 229 shader->unref();
225 save(); 230 save();
226 translate(SkIntToScalar(x), SkIntToScalar(y)); 231 translate(SkIntToScalar(dest_x - src_x), SkIntToScalar(dest_y - src_y));
227 ClipRectInt(0, 0, w, h); 232 ClipRectInt(src_x, src_y, w, h);
228 drawPaint(paint); 233 drawPaint(paint);
229 restore(); 234 restore();
230 } 235 }
231 236
232 SkBitmap ChromeCanvas::ExtractBitmap() { 237 SkBitmap ChromeCanvas::ExtractBitmap() {
233 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); 238 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false);
234 239
235 // 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
236 // 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
237 // of the bitmap. 242 // of the bitmap.
238 SkBitmap result; 243 SkBitmap result;
239 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); 244 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
240 return result; 245 return result;
241 } 246 }
OLDNEW
« no previous file with comments | « chrome/common/gfx/chrome_canvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698