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

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

Issue 14348033: NOT FOR SUBMIT - Windows Views HiDPI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rollback empty changes. Created 7 years, 8 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
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 #if !defined(ENABLE_HIDPI)
kevers 2013/04/19 20:31:42 These changes should not be necessary. The roundi
136 DCHECK(rgb.width() == alpha.width()); 137 DCHECK(rgb.width() == alpha.width());
137 DCHECK(rgb.height() == alpha.height()); 138 DCHECK(rgb.height() == alpha.height());
139 #endif
138 DCHECK(rgb.bytesPerPixel() == alpha.bytesPerPixel()); 140 DCHECK(rgb.bytesPerPixel() == alpha.bytesPerPixel());
139 DCHECK(rgb.config() == SkBitmap::kARGB_8888_Config); 141 DCHECK(rgb.config() == SkBitmap::kARGB_8888_Config);
140 DCHECK(alpha.config() == SkBitmap::kARGB_8888_Config); 142 DCHECK(alpha.config() == SkBitmap::kARGB_8888_Config);
141 143
142 SkBitmap masked; 144 SkBitmap masked;
143 masked.setConfig(SkBitmap::kARGB_8888_Config, rgb.width(), rgb.height(), 0); 145 masked.setConfig(SkBitmap::kARGB_8888_Config,
146 std::min(rgb.width(), alpha.width()),
147 std::min(rgb.height(), alpha.height()), 0);
144 masked.allocPixels(); 148 masked.allocPixels();
145 masked.eraseARGB(0, 0, 0, 0); 149 masked.eraseARGB(0, 0, 0, 0);
146 150
147 SkAutoLockPixels lock_rgb(rgb); 151 SkAutoLockPixels lock_rgb(rgb);
148 SkAutoLockPixels lock_alpha(alpha); 152 SkAutoLockPixels lock_alpha(alpha);
149 SkAutoLockPixels lock_masked(masked); 153 SkAutoLockPixels lock_masked(masked);
150 154
151 for (int y = 0; y < masked.height(); ++y) { 155 for (int y = 0; y < masked.height(); ++y) {
152 uint32* rgb_row = rgb.getAddr32(0, y); 156 uint32* rgb_row = rgb.getAddr32(0, y);
153 uint32* alpha_row = alpha.getAddr32(0, y); 157 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), 846 canvas.translate(SkFloatToScalar(result.width() * 0.5f),
843 SkFloatToScalar(result.height() * 0.5f)); 847 SkFloatToScalar(result.height() * 0.5f));
844 canvas.rotate(angle); 848 canvas.rotate(angle);
845 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), 849 canvas.translate(-SkFloatToScalar(source.width() * 0.5f),
846 -SkFloatToScalar(source.height() * 0.5f)); 850 -SkFloatToScalar(source.height() * 0.5f));
847 canvas.drawBitmap(source, 0, 0); 851 canvas.drawBitmap(source, 0, 0);
848 canvas.flush(); 852 canvas.flush();
849 853
850 return result; 854 return result;
851 } 855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698