34const SkISize kSurfaceSize = { 16, 16 };
58 pm.
erase(mipLevelColors[
i]);
79 img = create_and_attach_mipmaps(std::move(img));
111 paint.setColor(kBaseImageColor);
131 BitmapBackedGenerator()
141 const Options&)
override {
154 return bm.
readPixels(dstInfo, pixels, rowBytes, 0, 0);
158 std::unique_ptr<SkImageGenerator>
gen(
new BitmapBackedGenerator());
168 const char* testcase,
187 canvas->
clear(kBackgroundColor);
197 if (!
surface->readPixels(pm, 0, 0)) {
203 auto error = std::function<ComparePixmapsErrorReporter>(
204 [&](
int x,
int y,
const float diffs[4]) {
206 "case %s %s: expected (%.1f %.1f %.1f %.1f) got (%.1f, %.1f, %.1f, %.1f)",
209 expectedColor.fR, expectedColor.fG, expectedColor.fB, expectedColor.fA,
210 expectedColor.fR-diffs[0], expectedColor.fG-diffs[1],
211 expectedColor.fB-diffs[2], expectedColor.fA-diffs[3]);
213 static constexpr float kTol[] = {0, 0, 0, 0};
222 const char* fTestCase;
232 for (
auto t : testcases) {
237 t.fTestCase, t.fExpectedColors[
static_cast<int>(mm)]);
277 TestCase testcases[] = {
278 {
"0", create_raster_backed_image_no_mipmaps, { kBackgroundColor, kBackgroundColor } },
279 {
"1", create_raster_backed_image_with_mipmaps, { kBackgroundColor, kBackgroundColor } },
280 {
"2", create_gpu_backed_image_no_mipmaps, { kBaseImageColor, kBaseImageColor } },
281 {
"3", create_gpu_backed_image_with_mipmaps, { kBaseImageColor, kFirstMipLevelColor } },
282 {
"4", create_picture_backed_image, { kBackgroundColor, kBackgroundColor } },
283 {
"5", create_bitmap_generator_backed_image, { kBackgroundColor, kBackgroundColor } },
286 std::unique_ptr<Recorder> recorder = context->makeRecorder();
319 static const TestCase testcases[] = {
320 {
"0", create_raster_backed_image_no_mipmaps, { kBaseImageColor, kBaseImageColor } },
321 {
"1", create_raster_backed_image_with_mipmaps, { kBaseImageColor, kFirstMipLevelColor } },
322 {
"2", create_gpu_backed_image_no_mipmaps, { kBaseImageColor, kBaseImageColor } },
323 {
"3", create_gpu_backed_image_with_mipmaps, { kBaseImageColor, kFirstMipLevelColor } },
324 {
"4", create_picture_backed_image, { kBaseImageColor, kBaseImageColor } },
325 {
"5", create_bitmap_generator_backed_image, { kBaseImageColor, kBaseImageColor } },
329 std::unique_ptr<skgpu::graphite::Recorder> recorder = context->makeRecorder(
options);
338 static const struct {
342 {
"raster_no_mips", create_raster_backed_image_no_mipmaps },
343 {
"raster_with_mips", create_raster_backed_image_with_mipmaps },
344 {
"texture_no_mips", create_gpu_backed_image_no_mipmaps },
345 {
"texture_with_mips", create_gpu_backed_image_with_mipmaps },
346 {
"picture_backed", create_picture_backed_image },
347 {
"image_generator", create_bitmap_generator_backed_image },
353 std::unique_ptr<Recorder> recorderUP = context->makeRecorder();
354 auto recorder = recorderUP.get();
356 for (
const auto&
test : testcases) {
359 for (
bool mipmapped : {
false,
true}) {
366 bool mipmapOptAllowed = orig->
hasMipmaps() && !mipmapped;
371 (
i->hasMipmaps() == mipmapped) || (
i->hasMipmaps() && mipmapOptAllowed));
376 i = orig->
makeSubset(recorder, kTrueSubset, {mipmapped});
378 "orig texture status %d != subset texture status %d",
380 if (
i->isTextureBacked()) {
385 i = orig->
makeSubset(recorder, kFakeSubset, {mipmapped});
387 "orig texture status %d != subset texture status %d",
389 if (
i->isTextureBacked()) {
393 i->hasMipmaps() == mipmapped || (
i->hasMipmaps() && mipmapOptAllowed));
407 i = orig->
makeSubset(
nullptr, kTrueSubset, {mipmapped});
412 i = orig->
makeSubset(
nullptr, kFakeSubset, {mipmapped});
427 if (
info.isValid()) {
433 if (
info.isValid()) {
448 static const struct {
453 {
"raster_no_mips", create_raster_backed_image_no_mipmaps,
false },
454 {
"raster_with_mips", create_raster_backed_image_with_mipmaps,
false },
455 {
"texture_no_mips", create_gpu_backed_image_no_mipmaps,
true },
456 {
"texture_with_mips", create_gpu_backed_image_with_mipmaps,
true },
457 {
"picture_backed", create_picture_backed_image,
false },
458 {
"image_generator", create_bitmap_generator_backed_image,
false },
463 std::unique_ptr<Recorder> recorder = context->makeRecorder();
465 const Caps* caps = recorder->priv().caps();
467 for (
const auto& testcase : testcases) {
475 for (
bool mipmapped : {
false,
true}) {
483 if (testcase.fTextureBacked) {
489 SkColorType altCT = pick_colortype(caps, mipmapped);
496 if (testcase.fTextureBacked) {
static void run_test(GrDirectContext *dContext, skiatest::Reporter *reporter, BulkRectTest test)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(ImageProviderTest_Graphite_Default, reporter, context, CtsEnforcement::kNextRelease)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkASSERT_RELEASE(cond)
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
constexpr int SkToInt(S x)
bool CheckSolidPixels(const SkColor4f &col, const SkPixmap &pixmap, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define REPORTER_ASSERT(r, cond,...)
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
bool tryAllocPixels(const SkImageInfo &info, size_t rowBytes)
void eraseColor(SkColor4f) const
void drawIRect(const SkIRect &rect, const SkPaint &paint)
void clear(SkColor color)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkColorSpace > makeColorSpin() const
SkImageGenerator(const SkImageInfo &info, uint32_t uniqueId=kNeedNewImageUniqueID)
virtual bool onGetPixels(const SkImageInfo &, void *, size_t, const Options &)
virtual sk_sp< SkImage > makeColorSpace(GrDirectContext *direct, sk_sp< SkColorSpace > target) const =0
const SkImageInfo & imageInfo() const
SkColorSpace * colorSpace() const
SkColorType colorType() const
virtual sk_sp< SkImage > makeColorTypeAndColorSpace(GrDirectContext *direct, SkColorType targetColorType, sk_sp< SkColorSpace > targetCS) const =0
virtual bool isTextureBacked() const =0
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
bool erase(SkColor color, const SkIRect &subset) const
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
const uint8_t uint32_t uint32_t GError ** error
static const int kImageSize
constexpr SkColor4f kMagenta
constexpr SkColor4f kGreen
constexpr SkColor4f kWhite
constexpr SkColor4f kCyan
constexpr SkColor4f kBlue
constexpr SkColor4f kYellow
SK_API sk_sp< SkImage > DeferredFromPicture(sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace, SkSurfaceProps props)
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
SK_API sk_sp< SkImage > SubsetTextureFrom(GrDirectContext *context, const SkImage *img, const SkIRect &subset)
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
@ kU8
uses 8-bit unsigned int per color component
sk_sp< const SkImage > image
sk_sp< const SkPicture > picture
SkSamplingOptions sampling
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library name
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
SkSamplingOptions(SkFilterMode::kLinear))
constexpr SkISize size() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
SkIRect makeInset(int32_t dx, int32_t dy) const
constexpr int32_t width() const
constexpr int32_t height() const
SkISize dimensions() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)
static constexpr SkRect MakeWH(float w, float h)
static sk_sp< SkColorFilter > spin(sk_sp< SkColorFilter > cf)