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

Side by Side Diff: ui/gfx/skbitmap_operations.cc

Issue 12257016: (Not ready for review!) Toolbar and views high dpi support. Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Cleaned up more useless diffs. Created 7 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
« no previous file with comments | « ui/gfx/screen_win.cc ('k') | ui/views/controls/button/image_button.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/skbitmap_operations.h" 5 #include "ui/gfx/skbitmap_operations.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 dst_row[x] = SkColorSetARGB(a, r, g, b); 126 dst_row[x] = SkColorSetARGB(a, r, g, b);
127 } 127 }
128 } 128 }
129 129
130 return blended; 130 return blended;
131 } 131 }
132 132
133 // static 133 // static
134 SkBitmap SkBitmapOperations::CreateMaskedBitmap(const SkBitmap& rgb, 134 SkBitmap SkBitmapOperations::CreateMaskedBitmap(const SkBitmap& rgb,
135 const SkBitmap& alpha) { 135 const SkBitmap& alpha) {
136 DCHECK(rgb.width() == alpha.width()); 136 // DCHECK(rgb.width() == alpha.width());
137 DCHECK(rgb.height() == alpha.height()); 137 // DCHECK(rgb.height() == alpha.height());
138 DCHECK(rgb.bytesPerPixel() == alpha.bytesPerPixel()); 138 DCHECK(rgb.bytesPerPixel() == alpha.bytesPerPixel());
139 DCHECK(rgb.config() == SkBitmap::kARGB_8888_Config); 139 DCHECK(rgb.config() == SkBitmap::kARGB_8888_Config);
140 DCHECK(alpha.config() == SkBitmap::kARGB_8888_Config); 140 DCHECK(alpha.config() == SkBitmap::kARGB_8888_Config);
141 141
142 SkBitmap masked; 142 SkBitmap masked;
143 masked.setConfig(SkBitmap::kARGB_8888_Config, rgb.width(), rgb.height(), 0); 143 masked.setConfig(SkBitmap::kARGB_8888_Config,
144 std::min(rgb.width(), alpha.width()),
145 std::min(rgb.height(), alpha.height()), 0);
144 masked.allocPixels(); 146 masked.allocPixels();
145 masked.eraseARGB(0, 0, 0, 0); 147 masked.eraseARGB(0, 0, 0, 0);
146 148
147 SkAutoLockPixels lock_rgb(rgb); 149 SkAutoLockPixels lock_rgb(rgb);
148 SkAutoLockPixels lock_alpha(alpha); 150 SkAutoLockPixels lock_alpha(alpha);
149 SkAutoLockPixels lock_masked(masked); 151 SkAutoLockPixels lock_masked(masked);
150 152
151 for (int y = 0; y < masked.height(); ++y) { 153 for (int y = 0; y < masked.height(); ++y) {
152 uint32* rgb_row = rgb.getAddr32(0, y); 154 uint32* rgb_row = rgb.getAddr32(0, y);
153 uint32* alpha_row = alpha.getAddr32(0, y); 155 uint32* alpha_row = alpha.getAddr32(0, y);
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 canvas.translate(SkFloatToScalar(result.width() * 0.5f), 844 canvas.translate(SkFloatToScalar(result.width() * 0.5f),
843 SkFloatToScalar(result.height() * 0.5f)); 845 SkFloatToScalar(result.height() * 0.5f));
844 canvas.rotate(angle); 846 canvas.rotate(angle);
845 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), 847 canvas.translate(-SkFloatToScalar(source.width() * 0.5f),
846 -SkFloatToScalar(source.height() * 0.5f)); 848 -SkFloatToScalar(source.height() * 0.5f));
847 canvas.drawBitmap(source, 0, 0); 849 canvas.drawBitmap(source, 0, 0);
848 canvas.flush(); 850 canvas.flush();
849 851
850 return result; 852 return result;
851 } 853 }
OLDNEW
« no previous file with comments | « ui/gfx/screen_win.cc ('k') | ui/views/controls/button/image_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698