Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
SkSampledCodec Class Reference

#include <SkSampledCodec.h>

Inheritance diagram for SkSampledCodec:
SkAndroidCodec SkNoncopyable

Public Member Functions

 SkSampledCodec (SkCodec *)
 
 ~SkSampledCodec () override
 
- Public Member Functions inherited from SkAndroidCodec
virtual ~SkAndroidCodec ()
 
const SkImageInfogetInfo () const
 
const skcms_ICCProfilegetICCProfile () const
 
SkEncodedImageFormat getEncodedFormat () const
 
SkColorType computeOutputColorType (SkColorType requestedColorType)
 
SkAlphaType computeOutputAlphaType (bool requestedUnpremul)
 
sk_sp< SkColorSpacecomputeOutputColorSpace (SkColorType outputColorType, sk_sp< SkColorSpace > prefColorSpace=nullptr)
 
int computeSampleSize (SkISize *size) const
 
SkISize getSampledDimensions (int sampleSize) const
 
bool getSupportedSubset (SkIRect *desiredSubset) const
 
SkISize getSampledSubsetDimensions (int sampleSize, const SkIRect &subset) const
 
SkCodec::Result getAndroidPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions *options)
 
SkCodec::Result getAndroidPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 
SkCodec::Result getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 
SkCodeccodec () const
 
bool getAndroidGainmap (SkGainmapInfo *outInfo, std::unique_ptr< SkStream > *outGainmapImageStream)
 

Protected Member Functions

SkISize onGetSampledDimensions (int sampleSize) const override
 
bool onGetSupportedSubset (SkIRect *desiredSubset) const override
 
SkCodec::Result onGetAndroidPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions &options) override
 
- Protected Member Functions inherited from SkAndroidCodec
 SkAndroidCodec (SkCodec *)
 
virtual SkISize onGetSampledDimensions (int sampleSize) const =0
 
virtual bool onGetSupportedSubset (SkIRect *desiredSubset) const =0
 
virtual SkCodec::Result onGetAndroidPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const AndroidOptions &options)=0
 

Additional Inherited Members

- Public Types inherited from SkAndroidCodec
enum class  ExifOrientationBehavior { kIgnore , kRespect }
 
- Static Public Member Functions inherited from SkAndroidCodec
static std::unique_ptr< SkAndroidCodecMakeFromCodec (std::unique_ptr< SkCodec >)
 
static std::unique_ptr< SkAndroidCodecMakeFromStream (std::unique_ptr< SkStream >, SkPngChunkReader *=nullptr)
 
static std::unique_ptr< SkAndroidCodecMakeFromData (sk_sp< SkData >, SkPngChunkReader *=nullptr)
 

Detailed Description

This class implements the functionality of SkAndroidCodec. Scaling will be provided by sampling if it cannot be provided by fCodec.

Definition at line 23 of file SkSampledCodec.h.

Constructor & Destructor Documentation

◆ SkSampledCodec()

SkSampledCodec::SkSampledCodec ( SkCodec codec)
explicit

Definition at line 20 of file SkSampledCodec.cpp.

21 : INHERITED(codec)
22{}
SkCodec * codec() const

◆ ~SkSampledCodec()

SkSampledCodec::~SkSampledCodec ( )
inlineoverride

Definition at line 27 of file SkSampledCodec.h.

27{}

Member Function Documentation

◆ onGetAndroidPixels()

SkCodec::Result SkSampledCodec::onGetAndroidPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes,
const AndroidOptions options 
)
overrideprotectedvirtual

Implements SkAndroidCodec.

Definition at line 78 of file SkSampledCodec.cpp.

79 {
80 const SkIRect* subset = options.fSubset;
81 if (!subset || subset->size() == this->codec()->dimensions()) {
82 if (this->codec()->dimensionsSupported(info.dimensions())) {
83 return this->codec()->getPixels(info, pixels, rowBytes, &options);
84 }
85
86 // If the native codec does not support the requested scale, scale by sampling.
87 return this->sampledDecode(info, pixels, rowBytes, options);
88 }
89
90 // We are performing a subset decode.
91 int sampleSize = options.fSampleSize;
92 SkISize scaledSize = this->getSampledDimensions(sampleSize);
93 if (!this->codec()->dimensionsSupported(scaledSize)) {
94 // If the native codec does not support the requested scale, scale by sampling.
95 return this->sampledDecode(info, pixels, rowBytes, options);
96 }
97
98 // Calculate the scaled subset bounds.
99 int scaledSubsetX = subset->x() / sampleSize;
100 int scaledSubsetY = subset->y() / sampleSize;
101 int scaledSubsetWidth = info.width();
102 int scaledSubsetHeight = info.height();
103
104 const SkImageInfo scaledInfo = info.makeDimensions(scaledSize);
105
106 // Copy so we can use a different fSubset.
107 AndroidOptions subsetOptions = options;
108 {
109 // Although startScanlineDecode expects the bottom and top to match the
110 // SkImageInfo, startIncrementalDecode uses them to determine which rows to
111 // decode.
112 SkIRect incrementalSubset = SkIRect::MakeXYWH(scaledSubsetX, scaledSubsetY,
113 scaledSubsetWidth, scaledSubsetHeight);
114 subsetOptions.fSubset = &incrementalSubset;
115 const SkCodec::Result startResult = this->codec()->startIncrementalDecode(
116 scaledInfo, pixels, rowBytes, &subsetOptions);
117 if (SkCodec::kSuccess == startResult) {
118 int rowsDecoded = 0;
119 const SkCodec::Result incResult = this->codec()->incrementalDecode(&rowsDecoded);
120 if (incResult == SkCodec::kSuccess) {
121 return SkCodec::kSuccess;
122 }
123 SkASSERT(incResult == SkCodec::kIncompleteInput || incResult == SkCodec::kErrorInInput);
124
125 // FIXME: Can zero initialized be read from SkCodec::fOptions?
126 this->codec()->fillIncompleteImage(scaledInfo, pixels, rowBytes,
127 options.fZeroInitialized, scaledSubsetHeight, rowsDecoded);
128 return incResult;
129 } else if (startResult != SkCodec::kUnimplemented) {
130 return startResult;
131 }
132 // Otherwise fall down to use the old scanline decoder.
133 // subsetOptions.fSubset will be reset below, so it will not continue to
134 // point to the object that is no longer on the stack.
135 }
136
137 // Start the scanline decode.
138 SkIRect scanlineSubset = SkIRect::MakeXYWH(scaledSubsetX, 0, scaledSubsetWidth,
139 scaledSize.height());
140 subsetOptions.fSubset = &scanlineSubset;
141
142 SkCodec::Result result = this->codec()->startScanlineDecode(scaledInfo,
143 &subsetOptions);
144 if (SkCodec::kSuccess != result) {
145 return result;
146 }
147
148 // At this point, we are only concerned with subsetting. Either no scale was
149 // requested, or the this->codec() is handling the scale.
150 // Note that subsetting is only supported for kTopDown, so this code will not be
151 // reached for other orders.
152 SkASSERT(this->codec()->getScanlineOrder() == SkCodec::kTopDown_SkScanlineOrder);
153 if (!this->codec()->skipScanlines(scaledSubsetY)) {
154 this->codec()->fillIncompleteImage(info, pixels, rowBytes, options.fZeroInitialized,
155 scaledSubsetHeight, 0);
157 }
158
159 int decodedLines = this->codec()->getScanlines(pixels, scaledSubsetHeight, rowBytes);
160 if (decodedLines != scaledSubsetHeight) {
162 }
163 return SkCodec::kSuccess;
164}
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkISize getSampledDimensions(int sampleSize) const
int getScanlines(void *dst, int countLines, size_t rowBytes)
Definition: SkCodec.cpp:694
Result startScanlineDecode(const SkImageInfo &dstInfo, const Options *options)
Definition: SkCodec.cpp:635
@ kTopDown_SkScanlineOrder
Definition: SkCodec.h:581
Result getPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, const Options *)
Definition: SkCodec.cpp:467
Result startIncrementalDecode(const SkImageInfo &dstInfo, void *dst, size_t rowBytes, const Options *)
Definition: SkCodec.cpp:575
Result incrementalDecode(int *rowsDecoded=nullptr)
Definition: SkCodec.h:498
Result
Definition: SkCodec.h:76
@ kIncompleteInput
Definition: SkCodec.h:84
@ kUnimplemented
Definition: SkCodec.h:123
@ kSuccess
Definition: SkCodec.h:80
@ kErrorInInput
Definition: SkCodec.h:91
GAsyncResult * result
Definition: SkRect.h:32
constexpr int32_t x() const
Definition: SkRect.h:141
constexpr int32_t y() const
Definition: SkRect.h:148
constexpr SkISize size() const
Definition: SkRect.h:172
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
Definition: SkSize.h:16
constexpr int32_t height() const
Definition: SkSize.h:37

◆ onGetSampledDimensions()

SkISize SkSampledCodec::onGetSampledDimensions ( int  sampleSize) const
overrideprotectedvirtual

Implements SkAndroidCodec.

Definition at line 72 of file SkSampledCodec.cpp.

72 {
73 const SkISize size = this->accountForNativeScaling(&sampleSize);
74 return SkISize::Make(get_scaled_dimension(size.width(), sampleSize),
75 get_scaled_dimension(size.height(), sampleSize));
76}
static int get_scaled_dimension(int srcDimension, int sampleSize)
Definition: SkCodecPriv.h:44
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ onGetSupportedSubset()

bool SkSampledCodec::onGetSupportedSubset ( SkIRect desiredSubset) const
inlineoverrideprotectedvirtual

Implements SkAndroidCodec.

Definition at line 33 of file SkSampledCodec.h.

33{ return true; }

The documentation for this class was generated from the following files: