Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: src/core/SkImageGenerator.cpp

Issue 1716523002: Update Skia's YUV API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Tweak the API to use arrays and named indices Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "SkNextID.h" 9 #include "SkNextID.h"
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes) { 47 bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r owBytes) {
48 SkASSERT(kIndex_8_SkColorType != info.colorType()); 48 SkASSERT(kIndex_8_SkColorType != info.colorType());
49 if (kIndex_8_SkColorType == info.colorType()) { 49 if (kIndex_8_SkColorType == info.colorType()) {
50 return false; 50 return false;
51 } 51 }
52 return this->getPixels(info, pixels, rowBytes, nullptr, nullptr); 52 return this->getPixels(info, pixels, rowBytes, nullptr, nullptr);
53 } 53 }
54 54
55 bool SkImageGenerator::getYUV8Planes(SkISize sizes[3], void* planes[3], size_t r owBytes[3], 55 bool SkImageGenerator::queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* color Space) const {
56 SkYUVColorSpace* colorSpace) { 56 SkASSERT(sizeInfo);
57 #ifdef SK_DEBUG
58 // In all cases, we need the sizes array
59 SkASSERT(sizes);
60 57
61 bool isValidWithPlanes = (planes) && (rowBytes) && 58 return this->onQueryYUV8(sizeInfo, colorSpace);
62 ((planes[0]) && (planes[1]) && (planes[2]) &&
63 (0 != rowBytes[0]) && (0 != rowBytes[1]) && (0 != rowBytes[2]));
64 bool isValidWithoutPlanes =
65 ((nullptr == planes) ||
66 ((nullptr == planes[0]) && (nullptr == planes[1]) && (nullptr == planes [2]))) &&
67 ((nullptr == rowBytes) ||
68 ((0 == rowBytes[0]) && (0 == rowBytes[1]) && (0 == rowBytes[2])));
69
70 // Either we have all planes and rowBytes information or we have none of it
71 // Having only partial information is not supported
72 SkASSERT(isValidWithPlanes || isValidWithoutPlanes);
73
74 // If we do have planes information, make sure all sizes are non 0
75 // and all rowBytes are valid
76 SkASSERT(!isValidWithPlanes ||
77 ((sizes[0].fWidth >= 0) &&
78 (sizes[0].fHeight >= 0) &&
79 (sizes[1].fWidth >= 0) &&
80 (sizes[1].fHeight >= 0) &&
81 (sizes[2].fWidth >= 0) &&
82 (sizes[2].fHeight >= 0) &&
83 (rowBytes[0] >= (size_t)sizes[0].fWidth) &&
84 (rowBytes[1] >= (size_t)sizes[1].fWidth) &&
85 (rowBytes[2] >= (size_t)sizes[2].fWidth)));
86 #endif
87
88 return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace);
89 } 59 }
90 60
91 bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]) { 61 bool SkImageGenerator::getYUV8Planes(const SkYUVSizeInfo& sizeInfo,
92 return false; 62 void* planes[SkYUVSizeInfo::kPlaneCount]) {
93 } 63 SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth >= 0);
64 SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight >= 0);
65 SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kU].fWidth >= 0);
66 SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kU].fHeight >= 0);
67 SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kV].fWidth >= 0);
68 SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kV].fHeight >= 0);
69 SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kY] >=
70 (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth);
71 SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kU] >=
72 (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kU].fWidth);
73 SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] >=
74 (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kV].fWidth);
75 SkASSERT(planes && planes[0] && planes[1] && planes[2]);
94 76
95 bool SkImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3], 77 return this->onGetYUV8Planes(sizeInfo, planes);
96 SkYUVColorSpace* colorSpace) {
97 // In order to maintain compatibility with clients that implemented the orig inal
98 // onGetYUV8Planes interface, we assume that the color space is JPEG.
99 // TODO(rileya): remove this and the old onGetYUV8Planes once clients switch over to
100 // the new interface.
101 if (colorSpace) {
102 *colorSpace = kJPEG_SkYUVColorSpace;
103 }
104 return this->onGetYUV8Planes(sizes, planes, rowBytes);
105 } 78 }
106 79
107 GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subs et) { 80 GrTexture* SkImageGenerator::generateTexture(GrContext* ctx, const SkIRect* subs et) {
108 if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subs et)) { 81 if (subset && !SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(*subs et)) {
109 return nullptr; 82 return nullptr;
110 } 83 }
111 return this->onGenerateTexture(ctx, subset); 84 return this->onGenerateTexture(ctx, subset);
112 } 85 }
113 86
114 bool SkImageGenerator::computeScaledDimensions(SkScalar scale, SupportedSizes* s izes) { 87 bool SkImageGenerator::computeScaledDimensions(SkScalar scale, SupportedSizes* s izes) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if (nullptr == data) { 211 if (nullptr == data) {
239 return nullptr; 212 return nullptr;
240 } 213 }
241 if (gFactory) { 214 if (gFactory) {
242 if (SkImageGenerator* generator = gFactory(data)) { 215 if (SkImageGenerator* generator = gFactory(data)) {
243 return generator; 216 return generator;
244 } 217 }
245 } 218 }
246 return SkImageGenerator::NewFromEncodedImpl(data); 219 return SkImageGenerator::NewFromEncodedImpl(data);
247 } 220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698