Chromium Code Reviews| 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 // In all cases, we need the sizes array | |
| 63 SkASSERT(NULL != sizes); | |
| 64 | |
| 65 bool isValidWithPlanes = (NULL != planes) && (NULL != rowBytes) && | |
| 66 ((NULL != planes[0]) && (NULL != planes[1]) && (NULL != planes[2]) && | |
| 67 (0 != rowBytes[0]) && (0 != rowBytes[1]) && (0 != rowBytes[2])); | |
| 68 bool isValidWithoutPlanes = | |
| 69 ((NULL == planes) || | |
| 70 ((NULL == planes[0]) && (NULL == planes[1]) && (NULL == planes[2]))) && | |
| 71 ((NULL == rowBytes) || | |
| 72 ((0 == rowBytes[0]) && (0 == rowBytes[1]) && (0 == rowBytes[2]))); | |
| 73 | |
| 74 // Either we have all planes and rowBytes information or we have none of it | |
|
scroggo
2014/07/18 21:52:40
The comment in the header seems to say that we can
sugoi1
2014/07/21 16:51:44
I'll change the header
| |
| 75 // Having only partial information is not supported | |
| 76 SkASSERT(isValidWithPlanes || isValidWithoutPlanes); | |
| 77 | |
| 78 // If we do have planes information, make sure all sizes are non 0 | |
| 79 // and all rowBytes are valid | |
| 80 SkASSERT(!isValidWithPlanes || | |
| 81 ((sizes[0].fWidth >= 0) && | |
| 82 (sizes[0].fHeight >= 0) && | |
| 83 (sizes[1].fWidth >= 0) && | |
| 84 (sizes[1].fHeight >= 0) && | |
| 85 (sizes[2].fWidth >= 0) && | |
| 86 (sizes[2].fHeight >= 0) && | |
| 87 (rowBytes[0] >= (size_t)sizes[0].fWidth) && | |
| 88 (rowBytes[1] >= (size_t)sizes[1].fWidth) && | |
| 89 (rowBytes[2] >= (size_t)sizes[2].fWidth))); | |
| 90 #endif | |
| 91 | |
| 92 return this->onGetYUV8Planes(sizes, planes, rowBytes); | |
| 93 } | |
| 94 | |
| 95 bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]) { | |
| 96 return false; | |
| 97 } | |
| 98 | |
| 60 //////////////////////////////////////////////////////////////////////////////// ///////////// | 99 //////////////////////////////////////////////////////////////////////////////// ///////////// |
| 61 | 100 |
| 62 SkData* SkImageGenerator::onRefEncodedData() { | 101 SkData* SkImageGenerator::onRefEncodedData() { |
| 63 return NULL; | 102 return NULL; |
| 64 } | 103 } |
| 65 | 104 |
| 66 bool SkImageGenerator::onGetInfo(SkImageInfo*) { | 105 bool SkImageGenerator::onGetInfo(SkImageInfo*) { |
| 67 return false; | 106 return false; |
| 68 } | 107 } |
| 69 | 108 |
| 70 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor* , int*) { | 109 bool SkImageGenerator::onGetPixels(const SkImageInfo&, void*, size_t, SkPMColor* , int*) { |
| 71 return false; | 110 return false; |
| 72 } | 111 } |
| OLD | NEW |