| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Request.h" | 8 #include "Request.h" |
| 9 | 9 |
| 10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 struct ColorAndProfile { | 161 struct ColorAndProfile { |
| 162 SkColorType fColorType; | 162 SkColorType fColorType; |
| 163 bool fSRGB; | 163 bool fSRGB; |
| 164 bool fGammaCorrect; | 164 bool fGammaCorrect; |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 ColorAndProfile ColorModes[] = { | 167 ColorAndProfile ColorModes[] = { |
| 168 { kN32_SkColorType, false, false }, | 168 { kN32_SkColorType, false, false }, |
| 169 { kN32_SkColorType, true, true }, | 169 { kN32_SkColorType, true, true }, |
| 170 { kRGBA_F16_SkColorType, false, true }, | 170 { kRGBA_F16_SkColorType, true, true }, |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 } | 173 } |
| 174 | 174 |
| 175 SkSurface* Request::createCPUSurface() { | 175 SkSurface* Request::createCPUSurface() { |
| 176 SkIRect bounds = this->getBounds(); | 176 SkIRect bounds = this->getBounds(); |
| 177 ColorAndProfile cap = ColorModes[fColorMode]; | 177 ColorAndProfile cap = ColorModes[fColorMode]; |
| 178 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 178 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); |
| 179 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC
olorType, | 179 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC
olorType, |
| 180 kPremul_SkAlphaType, cap.fSRGB ? srgbCo
lorSpace : nullptr); | 180 kPremul_SkAlphaType, cap.fSRGB ? srgbCo
lorSpace : nullptr); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 SkASSERT(bitmap); | 300 SkASSERT(bitmap); |
| 301 | 301 |
| 302 // Convert to format suitable for inspection | 302 // Convert to format suitable for inspection |
| 303 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); | 303 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); |
| 304 SkASSERT(encodedBitmap.get()); | 304 SkASSERT(encodedBitmap.get()); |
| 305 | 305 |
| 306 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); | 306 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); |
| 307 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); | 307 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); |
| 308 return result; | 308 return result; |
| 309 } | 309 } |
| OLD | NEW |