Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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); |
|
danakj
2014/10/18 18:40:06
uint8?
Peter Kasting
2014/10/20 23:38:56
Same reply as before; they're equivalent but SkAlp
| |
| 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 |
| OLD | NEW |