Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | List of all members
skiagm::YUVMakeColorSpaceGM Class Reference
Inheritance diagram for skiagm::YUVMakeColorSpaceGM:
skiagm::GM

Public Member Functions

 YUVMakeColorSpaceGM ()
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void createBitmaps ()
 
bool createImages (GrDirectContext *context)
 
DrawResult onGpuSetup (SkCanvas *canvas, SkString *errorMsg, GraphiteTestContext *) override
 
void onGpuTeardown () override
 
DrawResult onDraw (SkCanvas *canvas, SkString *msg) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 1065 of file wacky_yuv_formats.cpp.

Constructor & Destructor Documentation

◆ YUVMakeColorSpaceGM()

skiagm::YUVMakeColorSpaceGM::YUVMakeColorSpaceGM ( )
inline

Definition at line 1067 of file wacky_yuv_formats.cpp.

1067 {
1068 this->setBGColor(0xFFCCCCCC);
1069 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ createBitmaps()

void skiagm::YUVMakeColorSpaceGM::createBitmaps ( )
inlineprotected

Definition at line 1081 of file wacky_yuv_formats.cpp.

1081 {
1082 SkPoint origin = { kTileWidthHeight/2.0f, kTileWidthHeight/2.0f };
1083 float outerRadius = kTileWidthHeight/2.0f - 20.0f;
1084 float innerRadius = 20.0f;
1085
1086 {
1087 // transparent
1088 SkTDArray<SkRect> circles;
1089 SkPath path = create_splat(origin, innerRadius, outerRadius, 1.0f, 5, &circles);
1090 fOriginalBMs[0] = make_bitmap(kN32_SkColorType, path, circles, false, false);
1091 }
1092
1093 {
1094 // opaque
1095 SkTDArray<SkRect> circles;
1096 SkPath path = create_splat(origin, innerRadius, outerRadius, 1.0f, 7, &circles);
1097 fOriginalBMs[1] = make_bitmap(kN32_SkColorType, path, circles, true, false);
1098 }
1099
1100 fTargetColorSpace = SkColorSpace::MakeSRGB()->makeColorSpin();
1101 }
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkColorSpace > makeColorSpin() const
Definition: SkPath.h:59
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
static SkBitmap make_bitmap(SkColorType colorType, const SkPath &path, const SkTDArray< SkRect > &circles, bool opaque, bool padWithRed)
static const int kTileWidthHeight
static SkPath create_splat(const SkPoint &o, SkScalar innerRadius, SkScalar outerRadius, SkScalar ratio, int numLobes, SkTDArray< SkRect > *circles)

◆ createImages()

bool skiagm::YUVMakeColorSpaceGM::createImages ( GrDirectContext context)
inlineprotected

Definition at line 1103 of file wacky_yuv_formats.cpp.

1103 {
1104 for (bool opaque : { false, true }) {
1105 PlaneData planes;
1106 extract_planes(fOriginalBMs[opaque],
1109 &planes);
1110
1111 SkBitmap resultBMs[4];
1112
1113 create_YUV(planes, kAYUV_YUVFormat, resultBMs, opaque);
1114
1116
1117 auto yuvaPixmaps = planarConfig.makeYUVAPixmaps(fOriginalBMs[opaque].dimensions(),
1119 resultBMs,
1120 std::size(resultBMs));
1121
1122 int i = 0;
1123 for (sk_sp<SkColorSpace> cs : {sk_sp<SkColorSpace>(nullptr),
1125 auto lazyYUV = sk_gpu_test::LazyYUVImage::Make(
1126 yuvaPixmaps, skgpu::Mipmapped::kNo, std::move(cs));
1127 fImages[opaque][i++] =
1128 lazyYUV->refImage(context, sk_gpu_test::LazyYUVImage::Type::kFromTextures);
1129 }
1130 }
1131
1132 // Some backends (e.g., Vulkan) require all work be completed for backend textures before
1133 // they are deleted. Since we don't know when we'll next have access to a direct context,
1134 // flush all the work now.
1135 context->flush();
1136 context->submit(GrSyncCpu::kYes);
1137
1138 return true;
1139 }
@ kTopLeft_SkEncodedOrigin
@ kJPEG_SkYUVColorSpace
Definition: SkImageInfo.h:98
@ kJPEG_Full_SkYUVColorSpace
describes full range
Definition: SkImageInfo.h:69
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
static std::unique_ptr< LazyYUVImage > Make(sk_sp< SkData > data, skgpu::Mipmapped=skgpu::Mipmapped::kNo, sk_sp< SkColorSpace >=nullptr)
Definition: YUVUtils.cpp:200
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
@ kAYUV_YUVFormat
static int create_YUV(const PlaneData &planes, YUVFormat yuvFormat, SkBitmap resultBMs[], bool opaque)
static void extract_planes(const SkBitmap &origBM, SkYUVColorSpace yuvColorSpace, SkEncodedOrigin origin, PlaneData *planes)

◆ getISize()

SkISize skiagm::YUVMakeColorSpaceGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 1074 of file wacky_yuv_formats.cpp.

1074 {
1075 int numCols = 4; // (transparent, opaque) x (untagged, tagged)
1076 int numRows = 5; // original, YUV, subset, makeNonTextureImage, readPixels
1077 return SkISize::Make(numCols * (kTileWidthHeight + kPad) + kPad,
1078 numRows * (kTileWidthHeight + kPad) + kPad);
1079 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static const int kPad

◆ getName()

SkString skiagm::YUVMakeColorSpaceGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 1072 of file wacky_yuv_formats.cpp.

1072{ return SkString("yuv_make_color_space"); }

◆ onDraw()

DrawResult skiagm::YUVMakeColorSpaceGM::onDraw ( SkCanvas canvas,
SkString msg 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 1161 of file wacky_yuv_formats.cpp.

1161 {
1162 SkASSERT(fImages[0][0] && fImages[0][1] && fImages[1][0] && fImages[1][1]);
1163
1164 auto dContext = GrAsDirectContext(canvas->recordingContext());
1165 if (!dContext) {
1166 *msg = "YUV ColorSpace image creation requires a direct context.";
1167 return DrawResult::kSkip;
1168 }
1169
1170 int x = kPad;
1171 for (int tagged : { 0, 1 }) {
1172 for (int opaque : { 0, 1 }) {
1173 int y = kPad;
1174
1175 auto raster = fOriginalBMs[opaque].asImage()->makeColorSpace(
1176 nullptr, fTargetColorSpace);
1177 canvas->drawImage(raster, x, y);
1178 y += kTileWidthHeight + kPad;
1179
1180 if (fImages[opaque][tagged]) {
1181 auto yuv = fImages[opaque][tagged]->makeColorSpace(dContext, fTargetColorSpace);
1182 SkASSERT(yuv);
1183 SkASSERT(SkColorSpace::Equals(yuv->colorSpace(), fTargetColorSpace.get()));
1184 canvas->drawImage(yuv, x, y);
1185 y += kTileWidthHeight + kPad;
1186
1188 auto subset = SkImages::SubsetTextureFrom(dContext, yuv.get(), bounds);
1189 SkASSERT(subset);
1190 canvas->drawImage(subset, x, y);
1191 y += kTileWidthHeight + kPad;
1192
1193 auto nonTexture = yuv->makeNonTextureImage();
1194 SkASSERT(nonTexture);
1195 canvas->drawImage(nonTexture, x, y);
1196 y += kTileWidthHeight + kPad;
1197
1198 SkBitmap readBack;
1199 readBack.allocPixels(yuv->imageInfo());
1200 SkAssertResult(yuv->readPixels(dContext, readBack.pixmap(), 0, 0));
1201 canvas->drawImage(readBack.asImage(), x, y);
1202 }
1203 x += kTileWidthHeight + kPad;
1204 }
1205 }
1206 return DrawResult::kOk;
1207 }
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
#define SkASSERT(cond)
Definition: SkAssert.h:116
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
const SkPixmap & pixmap() const
Definition: SkBitmap.h:133
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static bool Equals(const SkColorSpace *, const SkColorSpace *)
virtual sk_sp< SkImage > makeColorSpace(GrDirectContext *direct, sk_sp< SkColorSpace > target) const =0
T * get() const
Definition: SkRefCnt.h:303
double y
double x
SK_API sk_sp< SkImage > SubsetTextureFrom(GrDirectContext *context, const SkImage *img, const SkIRect &subset)
Optional< SkRect > bounds
Definition: SkRecords.h:189
Definition: SkRect.h:32
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56

◆ onGpuSetup()

DrawResult skiagm::YUVMakeColorSpaceGM::onGpuSetup ( SkCanvas canvas,
SkString errorMsg,
GraphiteTestContext  
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 1141 of file wacky_yuv_formats.cpp.

1141 {
1142 auto dContext = GrAsDirectContext(canvas->recordingContext());
1143 if (!dContext || dContext->abandoned()) {
1144 *errorMsg = "DirectContext required to create YUV images";
1145 return DrawResult::kSkip;
1146 }
1147
1148 this->createBitmaps();
1149 if (!this->createImages(dContext)) {
1150 *errorMsg = "Failed to create YUV images";
1151 return DrawResult::kFail;
1152 }
1153
1154 return DrawResult::kOk;
1155 }
bool createImages(GrDirectContext *context)

◆ onGpuTeardown()

void skiagm::YUVMakeColorSpaceGM::onGpuTeardown ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 1157 of file wacky_yuv_formats.cpp.

1157 {
1158 fImages[0][0] = fImages[0][1] = fImages[1][0] = fImages[1][1] = nullptr;
1159 }

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