Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 * This is the default. It will be used if no Options struct is used. | 235 * This is the default. It will be used if no Options struct is used. |
| 236 */ | 236 */ |
| 237 kNo_ZeroInitialized, | 237 kNo_ZeroInitialized, |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 /** | 240 /** |
| 241 * Additional options to pass to getPixels. | 241 * Additional options to pass to getPixels. |
| 242 */ | 242 */ |
| 243 struct Options { | 243 struct Options { |
| 244 Options() | 244 Options() |
| 245 : fZeroInitialized(kNo_ZeroInitialized) | 245 : fZeroInitialized(kNo_ZeroInitialized) |
|
msarett
2016/09/21 22:23:48
I dislike having this option. Obviously unrelated
scroggo
2016/09/22 16:46:43
It's certainly awkward to have both fZeroInitializ
| |
| 246 , fSubset(NULL) | 246 , fSubset(NULL) |
| 247 , fFrameIndex(0) | |
|
msarett
2016/09/21 22:23:48
I think I might prefer it if all of the "multi-fra
scroggo
2016/09/22 16:46:42
I considered that, but I'm not sure whether it's b
| |
| 248 , fHasPriorFrame(false) | |
| 247 {} | 249 {} |
|
msarett
2016/09/21 22:23:48
While I'm nitting on the Options object, here's an
scroggo
2016/09/22 16:46:43
Yeah, we put those in the AndroidOptions object as
| |
| 248 | 250 |
| 249 ZeroInitialized fZeroInitialized; | 251 ZeroInitialized fZeroInitialized; |
| 250 /** | 252 /** |
| 251 * If not NULL, represents a subset of the original image to decode. | 253 * If not NULL, represents a subset of the original image to decode. |
| 252 * Must be within the bounds returned by getInfo(). | 254 * Must be within the bounds returned by getInfo(). |
| 253 * If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which | 255 * If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which |
| 254 * currently supports subsets), the top and left values must be even. | 256 * currently supports subsets), the top and left values must be even. |
| 255 * | 257 * |
| 256 * In getPixels and incremental decode, we will attempt to decode the | 258 * In getPixels and incremental decode, we will attempt to decode the |
| 257 * exact rectangular subset specified by fSubset. | 259 * exact rectangular subset specified by fSubset. |
| 258 * | 260 * |
| 259 * In a scanline decode, it does not make sense to specify a subset | 261 * In a scanline decode, it does not make sense to specify a subset |
| 260 * top or subset height, since the client already controls which rows | 262 * top or subset height, since the client already controls which rows |
| 261 * to get and which rows to skip. During scanline decodes, we will | 263 * to get and which rows to skip. During scanline decodes, we will |
| 262 * require that the subset top be zero and the subset height be equal | 264 * require that the subset top be zero and the subset height be equal |
| 263 * to the full height. We will, however, use the values of | 265 * to the full height. We will, however, use the values of |
| 264 * subset left and subset width to decode partial scanlines on calls | 266 * subset left and subset width to decode partial scanlines on calls |
| 265 * to getScanlines(). | 267 * to getScanlines(). |
| 266 */ | 268 */ |
| 267 SkIRect* fSubset; | 269 SkIRect* fSubset; |
| 270 | |
| 271 /** | |
| 272 * For multiframe images, this represents the frame to decode. | |
| 273 * | |
| 274 * Ignored by single frame images. | |
| 275 */ | |
| 276 size_t fFrameIndex; | |
| 277 | |
| 278 /** | |
| 279 * If true, the dst already contains the prior frame. | |
| 280 * | |
| 281 * Only meaningful for multiframe images. If fFrameIndex needs to be | |
| 282 * blended with a prior frame (as reported by | |
| 283 * getRequiredFrame(fFrameIndex)), the client can set this to either | |
| 284 * true or false: | |
| 285 * | |
| 286 * true means that the prior frame is already in the dst, and this | |
| 287 * codec only needs to decode fFrameIndex and blend it with the dst. | |
| 288 * | |
| 289 * false means that the dst is uninitialized, so this codec needs to | |
| 290 * first decode the prior frame (which in turn may need to decode its | |
| 291 * prior frame). | |
| 292 */ | |
| 293 bool fHasPriorFrame; | |
|
cblume
2016/09/22 01:08:47
I am curious about the design of this.
As I under
cblume
2016/09/22 01:42:19
Adding to this:
If we are still downloading the im
scroggo
2016/09/22 16:46:43
Agreed.
scroggo
2016/09/22 16:46:43
That is correct.
cblume
2016/09/22 21:29:02
I agree with what you are saying. Good thinking.
scroggo
2016/09/23 15:53:15
My preference would be to hide the dispose method
cblume
2016/09/23 19:15:45
I agree. We can cross that bridge if it becomes ne
| |
| 268 }; | 294 }; |
| 269 | 295 |
| 270 /** | 296 /** |
| 271 * Decode into the given pixels, a block of memory of size at | 297 * Decode into the given pixels, a block of memory of size at |
| 272 * least (info.fHeight - 1) * rowBytes + (info.fWidth * | 298 * least (info.fHeight - 1) * rowBytes + (info.fWidth * |
| 273 * bytesPerPixel) | 299 * bytesPerPixel) |
| 274 * | 300 * |
| 275 * Repeated calls to this function should give the same results, | 301 * Repeated calls to this function should give the same results, |
| 276 * allowing the PixelRef to be immutable. | 302 * allowing the PixelRef to be immutable. |
| 277 * | 303 * |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 /** | 585 /** |
| 560 * Returns the output y-coordinate of the row that corresponds to an input | 586 * Returns the output y-coordinate of the row that corresponds to an input |
| 561 * y-coordinate. The input y-coordinate represents where the scanline | 587 * y-coordinate. The input y-coordinate represents where the scanline |
| 562 * is located in the encoded data. | 588 * is located in the encoded data. |
| 563 * | 589 * |
| 564 * This will equal inputScanline, except in the case of strangely | 590 * This will equal inputScanline, except in the case of strangely |
| 565 * encoded image types (bottom-up bmps, interlaced gifs). | 591 * encoded image types (bottom-up bmps, interlaced gifs). |
| 566 */ | 592 */ |
| 567 int outputScanline(int inputScanline) const; | 593 int outputScanline(int inputScanline) const; |
| 568 | 594 |
| 595 /** | |
| 596 * Return the number of frames in the image. | |
| 597 * | |
| 598 * May require reading through the stream to determine the number of | |
| 599 * frames. | |
| 600 * | |
| 601 * As such, future decoding calls may require a rewind. | |
| 602 */ | |
| 603 size_t getFrameCount() { | |
|
msarett
2016/09/21 22:23:48
Can we get away with not having this? Seems like
cblume
2016/09/22 01:08:47
In the case of gif and apng, we won't know in adva
cblume
2016/09/22 01:42:19
Correcting myself:
We could still be wise about wh
joostouwerling
2016/09/22 15:43:16
For apng, the acTL chunk with the number of frames
scroggo
2016/09/22 16:46:42
FWIW, my initial design (patch set 1, which I work
cblume
2016/09/22 21:29:02
Oh man, that is a bummer.
As a client, having the
scroggo
2016/09/23 15:53:15
It might be easier not to provide the metadata up
cblume
2016/09/23 19:15:45
An alternative would be if Chrome changed its catc
scroggo
2016/09/23 21:15:00
Those sound like good reasons to change the catchu
cblume
2016/09/23 23:31:32
Oh no no. I didn't mean that the API changes. I me
scroggo
2016/09/26 15:51:43
+1
| |
| 604 return this->onGetFrameCount(); | |
| 605 } | |
| 606 | |
| 607 // The required frame for an independent frame is marked as | |
| 608 // kIndependentFrame. | |
| 609 static constexpr size_t kIndependentFrame = static_cast<size_t>(-1); | |
| 610 | |
| 611 /** | |
| 612 * For a multiframed image, return the image that frame |index| needs to | |
| 613 * be blended with. | |
| 614 * | |
| 615 * If the frame needs no blending, return kIndependentFrame. | |
| 616 */ | |
| 617 size_t getRequiredFrame(size_t index) { | |
| 618 return this->onGetRequiredFrame(index); | |
| 619 } | |
| 620 | |
| 621 /** | |
| 622 * For a multiframed image, return the number of 1/100 seconds to | |
| 623 * show frame |index|. | |
| 624 */ | |
| 625 size_t getFrameDuration(size_t index) { | |
| 626 return this->onGetFrameDuration(index); | |
| 627 } | |
| 628 | |
| 569 protected: | 629 protected: |
| 570 /** | 630 /** |
| 571 * Takes ownership of SkStream* | 631 * Takes ownership of SkStream* |
| 572 */ | 632 */ |
| 573 SkCodec(int width, | 633 SkCodec(int width, |
| 574 int height, | 634 int height, |
| 575 const SkEncodedInfo&, | 635 const SkEncodedInfo&, |
| 576 SkStream*, | 636 SkStream*, |
| 577 sk_sp<SkColorSpace> = nullptr, | 637 sk_sp<SkColorSpace> = nullptr, |
| 578 Origin = kTopLeft_Origin); | 638 Origin = kTopLeft_Origin); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 /** | 759 /** |
| 700 * Returns the number of scanlines that have been decoded so far. | 760 * Returns the number of scanlines that have been decoded so far. |
| 701 * This is unaffected by the SkScanlineOrder. | 761 * This is unaffected by the SkScanlineOrder. |
| 702 * | 762 * |
| 703 * Returns -1 if we have not started a scanline decode. | 763 * Returns -1 if we have not started a scanline decode. |
| 704 */ | 764 */ |
| 705 int currScanline() const { return fCurrScanline; } | 765 int currScanline() const { return fCurrScanline; } |
| 706 | 766 |
| 707 virtual int onOutputScanline(int inputScanline) const; | 767 virtual int onOutputScanline(int inputScanline) const; |
| 708 | 768 |
| 769 virtual size_t onGetFrameCount() { | |
| 770 return 1; | |
| 771 } | |
| 772 | |
| 773 virtual size_t onGetRequiredFrame(size_t) { | |
| 774 return kIndependentFrame; | |
| 775 } | |
| 776 | |
| 777 virtual size_t onGetFrameDuration(size_t) { | |
| 778 return 0; | |
| 779 } | |
| 780 | |
| 709 /** | 781 /** |
| 710 * Used for testing with qcms. | 782 * Used for testing with qcms. |
| 711 * FIXME: Remove this when we are done comparing with qcms. | 783 * FIXME: Remove this when we are done comparing with qcms. |
| 712 */ | 784 */ |
| 713 virtual sk_sp<SkData> getICCData() const { return nullptr; } | 785 virtual sk_sp<SkData> getICCData() const { return nullptr; } |
| 714 private: | 786 private: |
| 715 const SkEncodedInfo fEncodedInfo; | 787 const SkEncodedInfo fEncodedInfo; |
| 716 const SkImageInfo fSrcInfo; | 788 const SkImageInfo fSrcInfo; |
| 717 SkAutoTDelete<SkStream> fStream; | 789 SkAutoTDelete<SkStream> fStream; |
| 718 bool fNeedsRewind; | 790 bool fNeedsRewind; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 // For testing with qcms | 861 // For testing with qcms |
| 790 // FIXME: Remove these when we are done comparing with qcms. | 862 // FIXME: Remove these when we are done comparing with qcms. |
| 791 friend class DM::ColorCodecSrc; | 863 friend class DM::ColorCodecSrc; |
| 792 friend class ColorCodecBench; | 864 friend class ColorCodecBench; |
| 793 | 865 |
| 794 friend class DM::CodecSrc; // for fillIncompleteImage | 866 friend class DM::CodecSrc; // for fillIncompleteImage |
| 795 friend class SkSampledCodec; | 867 friend class SkSampledCodec; |
| 796 friend class SkIcoCodec; | 868 friend class SkIcoCodec; |
| 797 }; | 869 }; |
| 798 #endif // SkCodec_DEFINED | 870 #endif // SkCodec_DEFINED |
| OLD | NEW |