OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkSurface_Base.h" | 8 #include "SkSurface_Base.h" |
9 #include "SkImagePriv.h" | 9 #include "SkImagePriv.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { | 42 bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { |
43 if (info.isEmpty()) { | 43 if (info.isEmpty()) { |
44 return false; | 44 return false; |
45 } | 45 } |
46 | 46 |
47 static const size_t kMaxTotalSize = SK_MaxS32; | 47 static const size_t kMaxTotalSize = SK_MaxS32; |
48 | 48 |
49 int shift = 0; | 49 int shift = 0; |
50 switch (info.colorType()) { | 50 switch (info.colorType()) { |
51 case kAlpha_8_SkColorType: | 51 case kAlpha_8_SkColorType: |
| 52 if (info.colorSpace()) { |
| 53 return false; |
| 54 } |
52 shift = 0; | 55 shift = 0; |
53 break; | 56 break; |
54 case kRGB_565_SkColorType: | 57 case kRGB_565_SkColorType: |
| 58 if (info.colorSpace()) { |
| 59 return false; |
| 60 } |
55 shift = 1; | 61 shift = 1; |
56 break; | 62 break; |
57 case kN32_SkColorType: | 63 case kN32_SkColorType: |
| 64 if (info.colorSpace() && !info.colorSpace()->gammaCloseToSRGB()) { |
| 65 return false; |
| 66 } |
58 shift = 2; | 67 shift = 2; |
59 break; | 68 break; |
60 case kRGBA_F16_SkColorType: | 69 case kRGBA_F16_SkColorType: |
| 70 if (!info.colorSpace() || |
| 71 SkColorSpace::kLinear_GammaNamed != info.colorSpace()->gammaName
d()) { |
| 72 return false; |
| 73 } |
61 shift = 3; | 74 shift = 3; |
62 break; | 75 break; |
63 default: | 76 default: |
64 return false; | 77 return false; |
65 } | 78 } |
66 | 79 |
67 if (kIgnoreRowBytesValue == rowBytes) { | 80 if (kIgnoreRowBytesValue == rowBytes) { |
68 return true; | 81 return true; |
69 } | 82 } |
70 | 83 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 211 |
199 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, null
ptr)); | 212 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, null
ptr)); |
200 if (nullptr == pr.get()) { | 213 if (nullptr == pr.get()) { |
201 return nullptr; | 214 return nullptr; |
202 } | 215 } |
203 if (rowBytes) { | 216 if (rowBytes) { |
204 SkASSERT(pr->rowBytes() == rowBytes); | 217 SkASSERT(pr->rowBytes() == rowBytes); |
205 } | 218 } |
206 return sk_make_sp<SkSurface_Raster>(pr, props); | 219 return sk_make_sp<SkSurface_Raster>(pr, props); |
207 } | 220 } |
OLD | NEW |