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

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

Issue 1766413002: Use a smart pointer for SkColorSpace factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix spacing 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/codec_android.gyp ('k') | src/codec/SkBmpCodec.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"
14 #include "SkEncodedFormat.h" 13 #include "SkEncodedFormat.h"
15 #include "SkImageInfo.h" 14 #include "SkImageInfo.h"
16 #include "SkSize.h" 15 #include "SkSize.h"
17 #include "SkStream.h" 16 #include "SkStream.h"
18 #include "SkTypes.h" 17 #include "SkTypes.h"
19 18
19 class SkColorSpace;
20 class SkData; 20 class SkData;
21 class SkPngChunkReader; 21 class SkPngChunkReader;
22 class SkSampler; 22 class SkSampler;
23 23
24 /** 24 /**
25 * Abstraction layer directly on top of an image codec. 25 * Abstraction layer directly on top of an image codec.
26 */ 26 */
27 class SkCodec : SkNoncopyable { 27 class SkCodec : SkNoncopyable {
28 public: 28 public:
29 /** 29 /**
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 /** 97 /**
98 * Return the ImageInfo associated with this codec. 98 * Return the ImageInfo associated with this codec.
99 */ 99 */
100 const SkImageInfo& getInfo() const { return fSrcInfo; } 100 const SkImageInfo& getInfo() const { return fSrcInfo; }
101 101
102 /** 102 /**
103 * Returns the color space associated with the codec. 103 * Returns the color space associated with the codec.
104 * Does not affect ownership. 104 * Does not affect ownership.
105 * Might be NULL. 105 * Might be NULL.
106 */ 106 */
107 SkColorSpace* getColorSpace() const { return fColorSpace; } 107 SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
108 108
109 /** 109 /**
110 * Return a size that approximately supports the desired scale factor. 110 * Return a size that approximately supports the desired scale factor.
111 * 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
112 * factor requested, so return a size that approximates that scale. 112 * factor requested, so return a size that approximates that scale.
113 * 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
114 * scale that it can natively support 114 * scale that it can natively support
115 */ 115 */
116 SkISize getScaledDimensions(float desiredScale) const { 116 SkISize getScaledDimensions(float desiredScale) const {
117 // Negative and zero scales are errors. 117 // Negative and zero scales are errors.
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 * This will equal inputScanline, except in the case of strangely 507 * This will equal inputScanline, except in the case of strangely
508 * encoded image types (bottom-up bmps, interlaced gifs). 508 * encoded image types (bottom-up bmps, interlaced gifs).
509 */ 509 */
510 int outputScanline(int inputScanline) const; 510 int outputScanline(int inputScanline) const;
511 511
512 protected: 512 protected:
513 /** 513 /**
514 * Takes ownership of SkStream* 514 * Takes ownership of SkStream*
515 * Does not affect ownership of SkColorSpace* 515 * Does not affect ownership of SkColorSpace*
516 */ 516 */
517 SkCodec(const SkImageInfo&, SkStream*, SkColorSpace* = nullptr); 517 SkCodec(const SkImageInfo&, SkStream*, sk_sp<SkColorSpace> = nullptr);
518 518
519 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { 519 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
520 // By default, scaling is not supported. 520 // By default, scaling is not supported.
521 return this->getInfo().dimensions(); 521 return this->getInfo().dimensions();
522 } 522 }
523 523
524 // FIXME: What to do about subsets?? 524 // FIXME: What to do about subsets??
525 /** 525 /**
526 * Subclasses should override if they support dimensions other than the 526 * Subclasses should override if they support dimensions other than the
527 * srcInfo's. 527 * srcInfo's.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 * Returns -1 if we have not started a scanline decode. 638 * Returns -1 if we have not started a scanline decode.
639 */ 639 */
640 int currScanline() const { return fCurrScanline; } 640 int currScanline() const { return fCurrScanline; }
641 641
642 virtual int onOutputScanline(int inputScanline) const; 642 virtual int onOutputScanline(int inputScanline) const;
643 643
644 private: 644 private:
645 const SkImageInfo fSrcInfo; 645 const SkImageInfo fSrcInfo;
646 SkAutoTDelete<SkStream> fStream; 646 SkAutoTDelete<SkStream> fStream;
647 bool fNeedsRewind; 647 bool fNeedsRewind;
648 SkAutoTUnref<SkColorSpace> fColorSpace; 648 sk_sp<SkColorSpace> fColorSpace;
649 649
650 // These fields are only meaningful during scanline decodes. 650 // These fields are only meaningful during scanline decodes.
651 SkImageInfo fDstInfo; 651 SkImageInfo fDstInfo;
652 SkCodec::Options fOptions; 652 SkCodec::Options fOptions;
653 int fCurrScanline; 653 int fCurrScanline;
654 654
655 /** 655 /**
656 * Return whether these dimensions are supported as a scale. 656 * Return whether these dimensions are supported as a scale.
657 * 657 *
658 * 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.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 * not affect ownership. 699 * not affect ownership.
700 * 700 *
701 * Only valid during scanline decoding. 701 * Only valid during scanline decoding.
702 */ 702 */
703 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } 703 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
704 704
705 friend class SkSampledCodec; 705 friend class SkSampledCodec;
706 friend class SkIcoCodec; 706 friend class SkIcoCodec;
707 }; 707 };
708 #endif // SkCodec_DEFINED 708 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « gyp/codec_android.gyp ('k') | src/codec/SkBmpCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698