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

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

Issue 649203003: Type conversion fixes, ui/gfx/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SkIntToMScalar Created 6 years, 1 month 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/skia_util.h" 5 #include "ui/gfx/skia_util.h"
6 6
7 #include "third_party/skia/include/core/SkBitmap.h" 7 #include "third_party/skia/include/core/SkBitmap.h"
8 #include "third_party/skia/include/core/SkColorFilter.h" 8 #include "third_party/skia/include/core/SkColorFilter.h"
9 #include "third_party/skia/include/core/SkColorPriv.h" 9 #include "third_party/skia/include/core/SkColorPriv.h"
10 #include "third_party/skia/include/core/SkUnPreMultiply.h" 10 #include "third_party/skia/include/core/SkUnPreMultiply.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 void ConvertSkiaToRGBA(const unsigned char* skia, 169 void ConvertSkiaToRGBA(const unsigned char* skia,
170 int pixel_width, 170 int pixel_width,
171 unsigned char* rgba) { 171 unsigned char* rgba) {
172 int total_length = pixel_width * 4; 172 int total_length = pixel_width * 4;
173 for (int i = 0; i < total_length; i += 4) { 173 for (int i = 0; i < total_length; i += 4) {
174 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]); 174 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]);
175 175
176 // Pack the components here. 176 // Pack the components here.
177 int alpha = SkGetPackedA32(pixel_in); 177 SkAlpha alpha = SkGetPackedA32(pixel_in);
178 if (alpha != 0 && alpha != 255) { 178 if (alpha != 0 && alpha != 255) {
179 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in); 179 SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel_in);
180 rgba[i + 0] = SkColorGetR(unmultiplied); 180 rgba[i + 0] = SkColorGetR(unmultiplied);
181 rgba[i + 1] = SkColorGetG(unmultiplied); 181 rgba[i + 1] = SkColorGetG(unmultiplied);
182 rgba[i + 2] = SkColorGetB(unmultiplied); 182 rgba[i + 2] = SkColorGetB(unmultiplied);
183 rgba[i + 3] = alpha; 183 rgba[i + 3] = alpha;
184 } else { 184 } else {
185 rgba[i + 0] = SkGetPackedR32(pixel_in); 185 rgba[i + 0] = SkGetPackedR32(pixel_in);
186 rgba[i + 1] = SkGetPackedG32(pixel_in); 186 rgba[i + 1] = SkGetPackedG32(pixel_in);
187 rgba[i + 2] = SkGetPackedB32(pixel_in); 187 rgba[i + 2] = SkGetPackedB32(pixel_in);
188 rgba[i + 3] = alpha; 188 rgba[i + 3] = alpha;
189 } 189 }
190 } 190 }
191 } 191 }
192 192
193 } // namespace gfx 193 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698