Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
DM::ColorCodecSrc Class Reference

#include <DMSrcSink.h>

Inheritance diagram for DM::ColorCodecSrc:
DM::Src

Public Member Functions

 ColorCodecSrc (Path, bool decode_to_dst)
 
Result draw (SkCanvas *, GraphiteTestContext *) const override
 
SkISize size () const override
 
Name name () const override
 
bool veto (SinkFlags) const override
 
- Public Member Functions inherited from DM::Src
virtual ~Src ()
 
virtual Result draw (SkCanvas *canvas, GraphiteTestContext *) const =0
 
virtual SkISize size () const =0
 
virtual Name name () const =0
 
virtual void modifyGrContextOptions (GrContextOptions *) const
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool veto (SinkFlags) const
 
virtual int pageCount () const
 
virtual Result draw (int page, SkCanvas *canvas, GraphiteTestContext *graphiteTestContext) const
 
virtual SkISize size (int page) const
 
virtual bool serial () const
 

Additional Inherited Members

- Public Types inherited from DM::Src
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 

Detailed Description

Definition at line 253 of file DMSrcSink.h.

Constructor & Destructor Documentation

◆ ColorCodecSrc()

DM::ColorCodecSrc::ColorCodecSrc ( Path  path,
bool  decode_to_dst 
)

Definition at line 1066 of file DMSrcSink.cpp.

1066 : fPath(path)
1067 , fDecodeToDst(decode_to_dst) {}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

Member Function Documentation

◆ draw()

Result DM::ColorCodecSrc::draw ( SkCanvas canvas,
GraphiteTestContext  
) const
overridevirtual

Implements DM::Src.

Definition at line 1074 of file DMSrcSink.cpp.

1074 {
1076 if (!encoded) {
1077 return Result::Fatal("Couldn't read %s.", fPath.c_str());
1078 }
1079
1080 std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(encoded));
1081 if (nullptr == codec) {
1082 return Result::Fatal("Couldn't create codec for %s.", fPath.c_str());
1083 }
1084
1085 SkImageInfo info = codec->getInfo();
1086 if (SkEncodedOriginSwapsWidthHeight(codec->getOrigin())) {
1088 }
1089 if (fDecodeToDst) {
1090 SkImageInfo canvasInfo = canvas->imageInfo();
1091 if (!canvasInfo.colorSpace()) {
1092 // This will skip color conversion, and the resulting images will
1093 // look different from images they are compared against in Gold, but
1094 // that doesn't mean they are wrong. We have a test verifying that
1095 // passing a null SkColorSpace skips conversion, so skip this
1096 // misleading test.
1097 return Result::Skip("Skipping decoding without color transform.");
1098 }
1099 info = canvasInfo.makeDimensions(info.dimensions());
1100 }
1101
1102 auto [image, result] = codec->getImage(info);
1103 switch (result) {
1104 case SkCodec::kSuccess:
1107 canvas->drawImage(image, 0,0);
1108 return Result::Ok();
1110 // TODO(mtklein): why are there formats we can't decode to?
1111 return Result::Skip("SkCodec can't decode to this format.");
1112 default:
1113 return Result::Fatal("Couldn't getPixels %s. Error code %d", fPath.c_str(), result);
1114 }
1115}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static bool SkEncodedOriginSwapsWidthHeight(SkEncodedOrigin origin)
static Result Skip(const char *fmt,...) SK_PRINTF_LIKE(1
static Result Ok()
Definition: DMSrcSink.h:50
static Result Fatal(const char *fmt,...) SK_PRINTF_LIKE(1
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
Definition: SkCodec.cpp:241
@ kInvalidConversion
Definition: SkCodec.h:96
@ kIncompleteInput
Definition: SkCodec.h:84
@ kSuccess
Definition: SkCodec.h:80
@ kErrorInInput
Definition: SkCodec.h:91
static sk_sp< SkData > MakeFromFileName(const char path[])
Definition: SkData.cpp:148
const char * c_str() const
Definition: SkString.h:133
GAsyncResult * result
SK_API SkImageInfo SwapWidthHeight(const SkImageInfo &info)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkImageInfo makeDimensions(SkISize newSize) const
Definition: SkImageInfo.h:454
SkColorSpace * colorSpace() const

◆ name()

Name DM::ColorCodecSrc::name ( ) const
overridevirtual

Implements DM::Src.

Definition at line 1126 of file DMSrcSink.cpp.

1126 {
1127 return SkOSPath::Basename(fPath.c_str());
1128}
static SkString Basename(const char *fullPath)
Definition: SkOSPath.cpp:23

◆ size()

SkISize DM::ColorCodecSrc::size ( ) const
overridevirtual

Implements DM::Src.

Definition at line 1117 of file DMSrcSink.cpp.

1117 {
1119 std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(encoded));
1120 if (nullptr == codec) {
1121 return {0, 0};
1122 }
1123 return {codec->getInfo().width(), codec->getInfo().height()};
1124}

◆ veto()

bool DM::ColorCodecSrc::veto ( SinkFlags  flags) const
overridevirtual

Reimplemented from DM::Src.

Definition at line 1069 of file DMSrcSink.cpp.

1069 {
1070 // Test to direct raster backends (8888 and 565).
1071 return flags.type != SinkFlags::kRaster || flags.approach != SinkFlags::kDirect;
1072}
FlutterSemanticsFlag flags

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