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

Side by Side Diff: include/codec/SkCodec.h

Issue 1775493002: Revert of Update Skia's YUV API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | include/core/SkImageGenerator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #ifndef SkCodec_DEFINED 8 #ifndef SkCodec_DEFINED
9 #define SkCodec_DEFINED 9 #define SkCodec_DEFINED
10 10
11 #include "../private/SkTemplates.h" 11 #include "../private/SkTemplates.h"
12 #include "SkColor.h" 12 #include "SkColor.h"
13 #include "SkColorSpace.h" 13 #include "SkColorSpace.h"
14 #include "SkEncodedFormat.h" 14 #include "SkEncodedFormat.h"
15 #include "SkImageInfo.h" 15 #include "SkImageInfo.h"
16 #include "SkSize.h" 16 #include "SkSize.h"
17 #include "SkStream.h" 17 #include "SkStream.h"
18 #include "SkTypes.h" 18 #include "SkTypes.h"
19 #include "SkYUVSizeInfo.h"
20 19
21 class SkData; 20 class SkData;
22 class SkPngChunkReader; 21 class SkPngChunkReader;
23 class SkSampler; 22 class SkSampler;
24 23
25 /** 24 /**
26 * Abstraction layer directly on top of an image codec. 25 * Abstraction layer directly on top of an image codec.
27 */ 26 */
28 class SkCodec : SkNoncopyable { 27 class SkCodec : SkNoncopyable {
29 public: 28 public:
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 */ 278 */
280 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, con st Options*, 279 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, con st Options*,
281 SkPMColor ctable[], int* ctableCount); 280 SkPMColor ctable[], int* ctableCount);
282 281
283 /** 282 /**
284 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and 283 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and
285 * uses the default Options. 284 * uses the default Options.
286 */ 285 */
287 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); 286 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
288 287
288 struct YUVSizeInfo {
289 SkISize fYSize;
290 SkISize fUSize;
291 SkISize fVSize;
292
293 /**
294 * While the widths of the Y, U, and V planes are not restricted, the
295 * implementation requires that the width of the memory allocated for
296 * each plane be a multiple of DCTSIZE (which is always 8).
297 *
298 * This struct allows us to inform the client how many "widthBytes"
299 * that we need. Note that we use the new idea of "widthBytes"
300 * because this idea is distinct from "rowBytes" (used elsewhere in
301 * Skia). "rowBytes" allow the last row of the allocation to not
302 * include any extra padding, while, in this case, every single row of
303 * the allocation must be at least "widthBytes".
304 */
305 size_t fYWidthBytes;
306 size_t fUWidthBytes;
307 size_t fVWidthBytes;
308 };
309
289 /** 310 /**
290 * If decoding to YUV is supported, this returns true. Otherwise, this 311 * If decoding to YUV is supported, this returns true. Otherwise, this
291 * returns false and does not modify any of the parameters. 312 * returns false and does not modify any of the parameters.
292 * 313 *
293 * @param sizeInfo Output parameter indicating the sizes and required 314 * @param sizeInfo Output parameter indicating the sizes and required
294 * allocation widths of the Y, U, and V planes. 315 * allocation widths of the Y, U, and V planes.
295 * @param colorSpace Output parameter. If non-NULL this is set to kJPEG, 316 * @param colorSpace Output parameter. If non-NULL this is set to kJPEG,
296 * otherwise this is ignored. 317 * otherwise this is ignored.
297 */ 318 */
298 bool queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const { 319 bool queryYUV8(YUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
299 if (nullptr == sizeInfo) { 320 if (nullptr == sizeInfo) {
300 return false; 321 return false;
301 } 322 }
302 323
303 return this->onQueryYUV8(sizeInfo, colorSpace); 324 return this->onQueryYUV8(sizeInfo, colorSpace);
304 } 325 }
305 326
306 /** 327 /**
307 * Returns kSuccess, or another value explaining the type of failure. 328 * Returns kSuccess, or another value explaining the type of failure.
308 * This always attempts to perform a full decode. If the client only 329 * This always attempts to perform a full decode. If the client only
309 * wants size, it should call queryYUV8(). 330 * wants size, it should call queryYUV8().
310 * 331 *
311 * @param sizeInfo Needs to exactly match the values returned by the 332 * @param sizeInfo Needs to exactly match the values returned by the
312 * query, except the WidthBytes may be larger than the 333 * query, except the WidthBytes may be larger than the
313 * recommendation (but not smaller). 334 * recommendation (but not smaller).
314 * @param planes Memory for each of the Y, U, and V planes. 335 * @param planes Memory for each of the Y, U, and V planes.
315 */ 336 */
316 Result getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) { 337 Result getYUV8Planes(const YUVSizeInfo& sizeInfo, void* planes[3]) {
317 if (nullptr == planes || nullptr == planes[0] || nullptr == planes[1] || 338 if (nullptr == planes || nullptr == planes[0] || nullptr == planes[1] ||
318 nullptr == planes[2]) { 339 nullptr == planes[2]) {
319 return kInvalidInput; 340 return kInvalidInput;
320 } 341 }
321 342
322 if (!this->rewindIfNeeded()) { 343 if (!this->rewindIfNeeded()) {
323 return kCouldNotRewind; 344 return kCouldNotRewind;
324 } 345 }
325 346
326 return this->onGetYUV8Planes(sizeInfo, planes); 347 return this->onGetYUV8Planes(sizeInfo, planes);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 * @param rowsDecoded When the encoded image stream is incomplete, this func tion 536 * @param rowsDecoded When the encoded image stream is incomplete, this func tion
516 * will return kIncompleteInput and rowsDecoded will be s et to 537 * will return kIncompleteInput and rowsDecoded will be s et to
517 * the number of scanlines that were successfully decoded . 538 * the number of scanlines that were successfully decoded .
518 * This will allow getPixels() to fill the uninitialized memory. 539 * This will allow getPixels() to fill the uninitialized memory.
519 */ 540 */
520 virtual Result onGetPixels(const SkImageInfo& info, 541 virtual Result onGetPixels(const SkImageInfo& info,
521 void* pixels, size_t rowBytes, const Options&, 542 void* pixels, size_t rowBytes, const Options&,
522 SkPMColor ctable[], int* ctableCount, 543 SkPMColor ctable[], int* ctableCount,
523 int* rowsDecoded) = 0; 544 int* rowsDecoded) = 0;
524 545
525 virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const { 546 virtual bool onQueryYUV8(YUVSizeInfo*, SkYUVColorSpace*) const {
526 return false; 547 return false;
527 } 548 }
528 549
529 virtual Result onGetYUV8Planes(const SkYUVSizeInfo&, void*[3] /*planes*/) { 550 virtual Result onGetYUV8Planes(const YUVSizeInfo&, void*[3] /*planes*/) {
530 return kUnimplemented; 551 return kUnimplemented;
531 } 552 }
532 553
533 virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const { 554 virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const {
534 // By default, subsets are not supported. 555 // By default, subsets are not supported.
535 return false; 556 return false;
536 } 557 }
537 558
538 /** 559 /**
539 * If the stream was previously read, attempt to rewind. 560 * If the stream was previously read, attempt to rewind.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 * not affect ownership. 699 * not affect ownership.
679 * 700 *
680 * Only valid during scanline decoding. 701 * Only valid during scanline decoding.
681 */ 702 */
682 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } 703 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
683 704
684 friend class SkSampledCodec; 705 friend class SkSampledCodec;
685 friend class SkIcoCodec; 706 friend class SkIcoCodec;
686 }; 707 };
687 #endif // SkCodec_DEFINED 708 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « no previous file | include/core/SkImageGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698