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

#include <DMSrcSink.h>

Inheritance diagram for DM::AndroidCodecSrc:
DM::Src

Public Member Functions

 AndroidCodecSrc (Path, CodecSrc::DstColorType, SkAlphaType, int sampleSize)
 
Result draw (SkCanvas *, GraphiteTestContext *) const override
 
SkISize size () const override
 
Name name () const override
 
bool veto (SinkFlags) const override
 
bool serial () 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 187 of file DMSrcSink.h.

Constructor & Destructor Documentation

◆ AndroidCodecSrc()

DM::AndroidCodecSrc::AndroidCodecSrc ( Path  path,
CodecSrc::DstColorType  dstColorType,
SkAlphaType  dstAlphaType,
int  sampleSize 
)

Definition at line 865 of file DMSrcSink.cpp.

867 : fPath(path)
868 , fDstColorType(dstColorType)
869 , fDstAlphaType(dstAlphaType)
870 , fSampleSize(sampleSize)
871 , fRunSerially(serial_from_path_name(path))
872{}
static bool serial_from_path_name(const SkString &path)
Definition: DMSrcSink.cpp:376
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::AndroidCodecSrc::draw ( SkCanvas canvas,
GraphiteTestContext  
) const
overridevirtual

Implements DM::Src.

Definition at line 880 of file DMSrcSink.cpp.

880 {
882 if (!encoded) {
883 return Result::Fatal("Couldn't read %s.", fPath.c_str());
884 }
885 std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::MakeFromData(encoded));
886 if (nullptr == codec) {
887 return Result::Fatal("Couldn't create android codec for %s.", fPath.c_str());
888 }
889
890 SkImageInfo decodeInfo = codec->getInfo();
891 if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType,
892 fDstAlphaType)) {
893 return Result::Skip("Skipping uninteresting test.");
894 }
895
896 // Scale the image if it is desired.
897 SkISize size = codec->getSampledDimensions(fSampleSize);
898
899 // Visually inspecting very small output images is not necessary. We will
900 // cover these cases in unit testing.
901 if ((size.width() <= 10 || size.height() <= 10) && 1 != fSampleSize) {
902 return Result::Skip("Scaling very small images is uninteresting.");
903 }
904 decodeInfo = decodeInfo.makeDimensions(size);
905
906 int bpp = decodeInfo.bytesPerPixel();
907 size_t rowBytes = size.width() * bpp;
908 SkAutoMalloc pixels(size.height() * rowBytes);
909
911 SkImageInfo bitmapInfo = decodeInfo;
912 set_bitmap_color_space(&bitmapInfo);
913 if (kRGBA_8888_SkColorType == decodeInfo.colorType() ||
914 kBGRA_8888_SkColorType == decodeInfo.colorType()) {
915 bitmapInfo = bitmapInfo.makeColorType(kN32_SkColorType);
916 }
917
918 // Create options for the codec.
920 options.fSampleSize = fSampleSize;
921
922 switch (codec->getAndroidPixels(decodeInfo, pixels.get(), rowBytes, &options)) {
926 break;
927 default:
928 return Result::Fatal("Couldn't getPixels %s.", fPath.c_str());
929 }
930 draw_to_canvas(canvas, bitmapInfo, pixels.get(), rowBytes, fDstColorType);
931 return Result::Ok();
932}
const char * options
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
SkISize size() const override
Definition: DMSrcSink.cpp:934
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
static std::unique_ptr< SkAndroidCodec > MakeFromData(sk_sp< SkData >, SkPngChunkReader *=nullptr)
SkImageInfo imageInfo() const
Definition: SkCanvas.cpp:1206
@ 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
static void draw_to_canvas(SkCanvas *canvas, const SkImageInfo &info, void *pixels, size_t rowBytes, CodecSrc::DstColorType dstColorType, SkScalar left=0, SkScalar top=0)
Definition: DMSrcSink.cpp:456
static void set_bitmap_color_space(SkImageInfo *info)
Definition: DMSrcSink.cpp:470
static bool get_decode_info(SkImageInfo *decodeInfo, SkColorType canvasColorType, CodecSrc::DstColorType dstColorType, SkAlphaType dstAlphaType)
Definition: DMSrcSink.cpp:422
Definition: bitmap.py:1
Definition: SkSize.h:16
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37
SkImageInfo makeDimensions(SkISize newSize) const
Definition: SkImageInfo.h:454
int bytesPerPixel() const
Definition: SkImageInfo.h:492
SkColorType colorType() const
Definition: SkImageInfo.h:373
SkImageInfo makeColorType(SkColorType newColorType) const
Definition: SkImageInfo.h:475

◆ name()

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

Implements DM::Src.

Definition at line 943 of file DMSrcSink.cpp.

943 {
944 // We will replicate the names used by CodecSrc so that images can
945 // be compared in Gold.
946 if (1 == fSampleSize) {
947 return SkOSPath::Basename(fPath.c_str());
948 }
949 return get_scaled_name(fPath, 1.0f / (float) fSampleSize);
950}
static SkString Basename(const char *fullPath)
Definition: SkOSPath.cpp:23
static SkString get_scaled_name(const Path &path, float scale)
Definition: DMSrcSink.cpp:199

◆ serial()

bool DM::AndroidCodecSrc::serial ( ) const
inlineoverridevirtual

Reimplemented from DM::Src.

Definition at line 195 of file DMSrcSink.h.

195{ return fRunSerially; }

◆ size()

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

Implements DM::Src.

Definition at line 934 of file DMSrcSink.cpp.

934 {
936 std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::MakeFromData(encoded));
937 if (nullptr == codec) {
938 return {0, 0};
939 }
940 return codec->getSampledDimensions(fSampleSize);
941}

◆ veto()

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

Reimplemented from DM::Src.

Definition at line 874 of file DMSrcSink.cpp.

874 {
875 // No need to test decoding to non-raster or indirect backend.
876 return flags.type != SinkFlags::kRaster
877 || flags.approach != SinkFlags::kDirect;
878}
FlutterSemanticsFlag flags

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