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

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

Issue 18392: Fix some problems with scaled icons. This allows the TabIconView to automati... (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
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 // Make a bitmap shader that contains the bitmap we want to draw. This is 184 // Make a bitmap shader that contains the bitmap we want to draw. This is
185 // basically what SkCanvas.drawBitmap does internally, but it gives us 185 // basically what SkCanvas.drawBitmap does internally, but it gives us
186 // more control over quality and will use the mipmap in the source image if 186 // more control over quality and will use the mipmap in the source image if
187 // it has one, whereas drawBitmap won't. 187 // it has one, whereas drawBitmap won't.
188 SkShader* shader = SkShader::CreateBitmapShader(bitmap, 188 SkShader* shader = SkShader::CreateBitmapShader(bitmap,
189 SkShader::kRepeat_TileMode, 189 SkShader::kRepeat_TileMode,
190 SkShader::kRepeat_TileMode); 190 SkShader::kRepeat_TileMode);
191 SkMatrix shader_scale; 191 SkMatrix shader_scale;
192 shader_scale.setScale( 192 shader_scale.setScale(SkFloatToScalar(static_cast<float>(dest_w) / src_w),
193 SkFloatToScalar(static_cast<float>(dest_w) / src_w), 193 SkFloatToScalar(static_cast<float>(dest_h) / src_h));
194 SkFloatToScalar(static_cast<float>(dest_h) / src_h)); 194 shader_scale.preTranslate(SkIntToScalar(-src_x), SkIntToScalar(-src_y));
195 shader_scale.postTranslate(SkIntToScalar(dest_x - src_x), 195 shader_scale.postTranslate(SkIntToScalar(dest_x), SkIntToScalar(dest_y));
sky 2009/01/21 00:53:22 I've no idea on this code, I'm assuming you know w
Peter Kasting 2009/01/21 01:00:36 Pre-translate means "do this before the existing m
196 SkIntToScalar(dest_y - src_y));
197 shader->setLocalMatrix(shader_scale); 196 shader->setLocalMatrix(shader_scale);
198 197
199 // Set up our paint to use the shader & release our reference (now just owned 198 // Set up our paint to use the shader & release our reference (now just owned
200 // by the paint). 199 // by the paint).
201 SkPaint p(paint); 200 SkPaint p(paint);
202 p.setFilterBitmap(filter); 201 p.setFilterBitmap(filter);
203 p.setShader(shader); 202 p.setShader(shader);
204 shader->unref(); 203 shader->unref();
205 204
206 // The rect will be filled by the bitmap. 205 // The rect will be filled by the bitmap.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 SkBitmap ChromeCanvas::ExtractBitmap() { 238 SkBitmap ChromeCanvas::ExtractBitmap() {
240 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); 239 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false);
241 240
242 // Make a bitmap to return, and a canvas to draw into it. We don't just want 241 // Make a bitmap to return, and a canvas to draw into it. We don't just want
243 // to call extractSubset or the copy constuctor, since we want an actual copy 242 // to call extractSubset or the copy constuctor, since we want an actual copy
244 // of the bitmap. 243 // of the bitmap.
245 SkBitmap result; 244 SkBitmap result;
246 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); 245 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config);
247 return result; 246 return result;
248 } 247 }
OLDNEW
« chrome/browser/views/tab_icon_view.cc ('K') | « chrome/browser/views/tabs/tab_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698