28constexpr int kNumMipLevels = 6;
35 const float kTols[4] = { 0.01f, 0.01f, 0.01f, 0.01f };
37 auto error = std::function<ComparePixmapsErrorReporter>(
38 [
reporter, ct, label, expected](
int x,
int y,
const float diffs[4]) {
41 "expected: (%.2f, %.2f, %.2f, %.2f) "
42 "- diffs: (%.2f, %.2f, %.2f, %.2f)",
44 expected.fR, expected.fG, expected.fB, expected.fA,
45 diffs[0], diffs[1], diffs[2], diffs[3]);
51void update_backend_texture(
Recorder* recorder,
57 std::unique_ptr<char[]> memForPixmaps;
61 SkASSERT(numMipLevels == 1 || numMipLevels == kNumMipLevels);
84 update_backend_texture(recorder, backendTex, ct, withMips,
colors);
111 int numLevels = withMips ? kNumMipLevels : 1;
121 for (
int i = 0, drawSize =
kSize.width();
i < numLevels; ++
i, drawSize /= 2) {
141 lm.
setScale(1.0f / (1 <<
i), 1.0f / (1 <<
i));
172 std::unique_ptr<Recorder> recorder = context->
makeRecorder();
175 { 1.0f, 0.0f, 0.0f, 1.0f },
176 { 0.0f, 1.0f, 0.0f, 0.9f },
177 { 0.0f, 0.0f, 1.0f, 0.7f },
178 { 0.0f, 1.0f, 1.0f, 0.5f },
179 { 1.0f, 0.0f, 1.0f, 0.3f },
180 { 1.0f, 1.0f, 0.0f, 0.2f },
184 { 1.0f, 1.0f, 0.0f, 0.2f },
185 { 1.0f, 0.0f, 0.0f, 1.0f },
186 { 0.0f, 1.0f, 0.0f, 0.9f },
187 { 0.0f, 0.0f, 1.0f, 0.7f },
188 { 0.0f, 1.0f, 1.0f, 0.5f },
189 { 1.0f, 0.0f, 1.0f, 0.3f },
194 for (
bool withMips : {
true,
false }) {
198 ct, withMips, renderable,
211 update_backend_texture(recorder.get(), backendTex, ct, withMips, kColorsNew);
213 image = wrap_backend_texture(
reporter, recorder.get(), backendTex, ct, withMips);
218 check_levels(
reporter, context, recorder.get(),
image.
get(), withMips, kColorsNew);
222 recorder->deleteBackendTexture(backendTex);
static void check_solid_pixmap(skiatest::Reporter *reporter, const SkColor4f &expected, const SkPixmap &actual, GrColorType ct, const char *label1, const char *label2)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
bool CheckSolidPixels(const SkColor4f &col, const SkPixmap &pixmap, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define REPORTER_ASSERT(r, cond,...)
DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(UpdateImageBackendTextureTest, reporter, context, CtsEnforcement::kNextRelease)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clear(SkColor color)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
SkColorType colorType() const
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
bool readPixels(const SkPixmap &dst, int srcX, int srcY)
void reset(T *ptr=nullptr)
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
const Caps * caps() const
BackendApi backend() const
std::unique_ptr< Recorder > makeRecorder(const RecorderOptions &={})
BackendTexture createBackendTexture(SkISize dimensions, const TextureInfo &)
bool updateBackendTexture(const BackendTexture &, const SkPixmap srcData[], int numLevels)
const uint8_t uint32_t uint32_t GError ** error
constexpr SkColor4f kTransparent
SK_API sk_sp< SkImage > WrapTexture(skgpu::graphite::Recorder *, const skgpu::graphite::BackendTexture &, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, skgpu::Origin origin, GenerateMipmapsFromBase generateMipmapsFromBase, TextureReleaseProc=nullptr, ReleaseContext=nullptr, std::string_view label={})
sk_sp< const SkImage > image
PODArray< SkColor > colors
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)
SkSamplingOptions(SkFilterMode::kLinear))
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeWH(float w, float h)