OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkImageGenerator.h" | 8 #include "SkImageGenerator.h" |
9 | 9 |
10 #ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI | 10 #ifndef SK_SUPPORT_LEGACY_IMAGEGENERATORAPI |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 | 50 |
51 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes) { | 51 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes) { |
52 SkASSERT(kIndex_8_SkColorType != info.colorType()); | 52 SkASSERT(kIndex_8_SkColorType != info.colorType()); |
53 if (kIndex_8_SkColorType == info.colorType()) { | 53 if (kIndex_8_SkColorType == info.colorType()) { |
54 return false; | 54 return false; |
55 } | 55 } |
56 return this->getPixels(info, pixels, rowBytes, NULL, NULL); | 56 return this->getPixels(info, pixels, rowBytes, NULL, NULL); |
57 } | 57 } |
58 #endif | 58 #endif |
59 | 59 |
60 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r owBytes[3]) { | |
61 #ifdef SK_DEBUG | |
62 bool isValidWithPlanes = | |
63 ((NULL != planes[0]) && (NULL != planes[1]) && (NULL != planes[2]) && | |
reed1
2014/07/10 18:21:40
if planes is NULL, this will crash!
We should add
sugoi1
2014/07/10 19:59:06
Acknowledged. Added the NULL test here, I'll write
sugoi1
2014/07/11 18:46:15
Done.
| |
64 (0 != rowBytes[0]) && (0 != rowBytes[1]) && (0 != rowBytes[2])); | |
65 bool isValidWithoutPlanes = | |
66 ((NULL == planes[0]) && (NULL == planes[1]) && (NULL == planes[2]) && | |
67 (0 == rowBytes[0]) && (0 == rowBytes[1]) && (0 == rowBytes[2])); | |
68 | |
69 // Either we have all planes and rowBytes information or we have none of it | |
70 // Having only partial information is not supported | |
71 SkASSERT(isValidWithPlanes || isValidWithoutPlanes); | |
72 | |
73 // If we do have planes information, make sure all sizes are non 0 | |
74 // and all rowBytes are valid | |
75 SkASSERT(!isValidWithPlanes || | |
76 ((sizes[0].fWidth >= 0) && | |
77 (sizes[0].fHeight >= 0) && | |
78 (sizes[1].fWidth >= 0) && | |
79 (sizes[1].fHeight >= 0) && | |
80 (sizes[2].fWidth >= 0) && | |
81 (sizes[2].fHeight >= 0) && | |
82 (rowBytes[0] >= (size_t)sizes[0].fWidth) && | |
83 (rowBytes[1] >= (size_t)sizes[1].fWidth) && | |
84 (rowBytes[2] >= (size_t)sizes[2].fWidth))); | |
85 #endif | |
86 | |
87 return this->onGetYUV8Planes(sizes, planes, rowBytes); | |
88 } | |
89 | |
90 bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]) { | |
91 return false; | |
92 } | |
93 | |
60 //////////////////////////////////////////////////////////////////////////////// ///////////// | 94 //////////////////////////////////////////////////////////////////////////////// ///////////// |
61 | 95 |
62 SkData* SkImageGenerator::onRefEncodedData() { | 96 SkData* SkImageGenerator::onRefEncodedData() { |
63 return NULL; | 97 return NULL; |
64 } | 98 } |
65 | 99 |
66 bool SkImageGenerator::onGetInfo(SkImageInfo*) { | 100 bool SkImageGenerator::onGetInfo(SkImageInfo*) { |
67 return false; | 101 return false; |
68 } | 102 } |
69 | 103 |
70 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor* , int*) { | 104 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor* , int*) { |
71 return false; | 105 return false; |
72 } | 106 } |
OLD | NEW |