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

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

Issue 1726823002: Set SkColorSpace object for PNGs and parse ICC profiles (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase 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 | « gyp/tools.gyp ('k') | resources/color_wheel_with_profile.png » ('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 "SkEncodedFormat.h" 14 #include "SkEncodedFormat.h"
14 #include "SkImageInfo.h" 15 #include "SkImageInfo.h"
15 #include "SkSize.h" 16 #include "SkSize.h"
16 #include "SkStream.h" 17 #include "SkStream.h"
17 #include "SkTypes.h" 18 #include "SkTypes.h"
18 19
19 class SkData; 20 class SkData;
20 class SkPngChunkReader; 21 class SkPngChunkReader;
21 class SkSampler; 22 class SkSampler;
22 23
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL); 93 static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL);
93 94
94 virtual ~SkCodec(); 95 virtual ~SkCodec();
95 96
96 /** 97 /**
97 * Return the ImageInfo associated with this codec. 98 * Return the ImageInfo associated with this codec.
98 */ 99 */
99 const SkImageInfo& getInfo() const { return fSrcInfo; } 100 const SkImageInfo& getInfo() const { return fSrcInfo; }
100 101
101 /** 102 /**
103 * Returns the color space associated with the codec.
104 * Does not affect ownership.
105 * Might be NULL.
106 */
107 SkColorSpace* getColorSpace() const { return fColorSpace; }
108
109 /**
102 * Return a size that approximately supports the desired scale factor. 110 * Return a size that approximately supports the desired scale factor.
103 * The codec may not be able to scale efficiently to the exact scale 111 * The codec may not be able to scale efficiently to the exact scale
104 * factor requested, so return a size that approximates that scale. 112 * factor requested, so return a size that approximates that scale.
105 * The returned value is the codec's suggestion for the closest valid 113 * The returned value is the codec's suggestion for the closest valid
106 * scale that it can natively support 114 * scale that it can natively support
107 */ 115 */
108 SkISize getScaledDimensions(float desiredScale) const { 116 SkISize getScaledDimensions(float desiredScale) const {
109 // Negative and zero scales are errors. 117 // Negative and zero scales are errors.
110 SkASSERT(desiredScale > 0.0f); 118 SkASSERT(desiredScale > 0.0f);
111 if (desiredScale <= 0.0f) { 119 if (desiredScale <= 0.0f) {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 * Returns the output y-coordinate of the row that corresponds to an input 503 * Returns the output y-coordinate of the row that corresponds to an input
496 * y-coordinate. The input y-coordinate represents where the scanline 504 * y-coordinate. The input y-coordinate represents where the scanline
497 * is located in the encoded data. 505 * is located in the encoded data.
498 * 506 *
499 * This will equal inputScanline, except in the case of strangely 507 * This will equal inputScanline, except in the case of strangely
500 * encoded image types (bottom-up bmps, interlaced gifs). 508 * encoded image types (bottom-up bmps, interlaced gifs).
501 */ 509 */
502 int outputScanline(int inputScanline) const; 510 int outputScanline(int inputScanline) const;
503 511
504 protected: 512 protected:
505 SkCodec(const SkImageInfo&, SkStream*); 513 /**
514 * Takes ownership of SkStream*
515 * Does not affect ownership of SkColorSpace*
516 */
517 SkCodec(const SkImageInfo&, SkStream*, SkColorSpace* = nullptr);
506 518
507 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { 519 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
508 // By default, scaling is not supported. 520 // By default, scaling is not supported.
509 return this->getInfo().dimensions(); 521 return this->getInfo().dimensions();
510 } 522 }
511 523
512 // FIXME: What to do about subsets?? 524 // FIXME: What to do about subsets??
513 /** 525 /**
514 * Subclasses should override if they support dimensions other than the 526 * Subclasses should override if they support dimensions other than the
515 * srcInfo's. 527 * srcInfo's.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 * Returns the number of scanlines that have been decoded so far. 635 * Returns the number of scanlines that have been decoded so far.
624 * This is unaffected by the SkScanlineOrder. 636 * This is unaffected by the SkScanlineOrder.
625 * 637 *
626 * Returns -1 if we have not started a scanline decode. 638 * Returns -1 if we have not started a scanline decode.
627 */ 639 */
628 int currScanline() const { return fCurrScanline; } 640 int currScanline() const { return fCurrScanline; }
629 641
630 virtual int onOutputScanline(int inputScanline) const; 642 virtual int onOutputScanline(int inputScanline) const;
631 643
632 private: 644 private:
633 const SkImageInfo fSrcInfo; 645 const SkImageInfo fSrcInfo;
634 SkAutoTDelete<SkStream> fStream; 646 SkAutoTDelete<SkStream> fStream;
635 bool fNeedsRewind; 647 bool fNeedsRewind;
648 SkAutoTUnref<SkColorSpace> fColorSpace;
649
636 // These fields are only meaningful during scanline decodes. 650 // These fields are only meaningful during scanline decodes.
637 SkImageInfo fDstInfo; 651 SkImageInfo fDstInfo;
638 SkCodec::Options fOptions; 652 SkCodec::Options fOptions;
639 int fCurrScanline; 653 int fCurrScanline;
640 654
641 /** 655 /**
642 * Return whether these dimensions are supported as a scale. 656 * Return whether these dimensions are supported as a scale.
643 * 657 *
644 * The codec may choose to cache the information about scale and subset. 658 * The codec may choose to cache the information about scale and subset.
645 * Either way, the same information will be passed to onGetPixels/onStart 659 * Either way, the same information will be passed to onGetPixels/onStart
646 * on success. 660 * on success.
647 * 661 *
648 * This must return true for a size returned from getScaledDimensions. 662 * This must return true for a size returned from getScaledDimensions.
649 */ 663 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 * not affect ownership. 699 * not affect ownership.
686 * 700 *
687 * Only valid during scanline decoding. 701 * Only valid during scanline decoding.
688 */ 702 */
689 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } 703 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
690 704
691 friend class SkSampledCodec; 705 friend class SkSampledCodec;
692 friend class SkIcoCodec; 706 friend class SkIcoCodec;
693 }; 707 };
694 #endif // SkCodec_DEFINED 708 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « gyp/tools.gyp ('k') | resources/color_wheel_with_profile.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698