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 SkColorSpace::kLinear_GammaNamed != info.colorSpace()->gammaName d()) { | |
Brian Osman
2016/08/23 13:25:56
Matt mentioned that if someone constructs a color
msarett
2016/08/23 13:46:11
What I was trying to say is that we won't catch IC
| |
66 return false; | |
67 } | |
58 shift = 2; | 68 shift = 2; |
59 break; | 69 break; |
60 case kRGBA_F16_SkColorType: | 70 case kRGBA_F16_SkColorType: |
61 shift = 3; | 71 shift = 3; |
62 break; | 72 break; |
63 default: | 73 default: |
64 return false; | 74 return false; |
65 } | 75 } |
66 | 76 |
67 if (kIgnoreRowBytesValue == rowBytes) { | 77 if (kIgnoreRowBytesValue == rowBytes) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 | 208 |
199 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, null ptr)); | 209 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, null ptr)); |
200 if (nullptr == pr.get()) { | 210 if (nullptr == pr.get()) { |
201 return nullptr; | 211 return nullptr; |
202 } | 212 } |
203 if (rowBytes) { | 213 if (rowBytes) { |
204 SkASSERT(pr->rowBytes() == rowBytes); | 214 SkASSERT(pr->rowBytes() == rowBytes); |
205 } | 215 } |
206 return sk_make_sp<SkSurface_Raster>(pr, props); | 216 return sk_make_sp<SkSurface_Raster>(pr, props); |
207 } | 217 } |
OLD | NEW |