49#include <initializer_list>
62 const char* label0,
const char* label1,
const char* label2) {
63 const float tols[4] = { 0.01f, 0.01f, 0.01f, 0.01f };
65 auto error = std::function<ComparePixmapsErrorReporter>(
66 [
reporter, label0, label1, label2](
int x,
int y,
const float diffs[4]) {
69 label0, label1, label2,
x,
y,
70 diffs[0], diffs[1], diffs[2], diffs[3]);
119 int numMipLevels = 1;
124 for (
int i = 0, rectSize = 32;
i < numMipLevels; ++
i, rectSize /= 2) {
155#ifdef SK_BUILD_FOR_IOS
204 newColor.fR =
color.fB;
205 newColor.fG =
color.fR;
206 newColor.fB =
color.fG;
207 newColor.fA =
color.fA;
213 SkColor4f expectedNewColors[6] = {newColor, newColor, newColor, newColor, newColor, newColor};
228 int numMipLevels = 1;
237 char*
data =
new char[dataSize];
248 dimensions = {
std::max(1, dimensions.width() /2),
std::max(1, dimensions.height()/2)};
251 return std::unique_ptr<const char[]>(
data);
264 { 1.0f, 0.0f, 0.0f, 1.0f },
265 { 0.0f, 1.0f, 0.0f, 1.0f },
266 { 0.0f, 0.0f, 1.0f, 1.0f },
267 { 0.0f, 1.0f, 1.0f, 1.0f },
268 { 1.0f, 0.0f, 1.0f, 1.0f },
269 { 1.0f, 1.0f, 0.0f, 1.0f },
278 if (!backendTex.isValid()) {
292 {1.0f, 1.0f, 0.0f, 1.0f},
293 {1.0f, 0.0f, 0.0f, 1.0f},
294 {0.0f, 1.0f, 0.0f, 1.0f},
295 {0.0f, 0.0f, 1.0f, 1.0f},
296 {0.0f, 1.0f, 1.0f, 1.0f},
297 {1.0f, 0.0f, 1.0f, 1.0f},
300 std::unique_ptr<const char[]> dataNew(
322 auto dContext = ctxInfo.directContext();
334 for (
auto combo : combinations) {
359 combo.fColor, combo.fCompression, mipmapped);
373 combo.fCompression, mipmapped);
static std::unique_ptr< const char[]> make_compressed_data(SkTextureCompressionType compression, SkColor4f levelColors[6], skgpu::Mipmapped mipmapped)
static void check_readback(GrDirectContext *dContext, sk_sp< SkImage > img, SkTextureCompressionType compressionType, const SkColor4f &expectedColor, skiatest::Reporter *reporter, const char *label)
static void check_solid_pixmap(skiatest::Reporter *reporter, const SkColor4f &expected, const SkPixmap &actual, const char *label0, const char *label1, const char *label2)
static void check_compressed_mipmaps(GrRecordingContext *rContext, sk_sp< SkImage > img, SkTextureCompressionType compressionType, const SkColor4f expectedColors[6], skgpu::Mipmapped mipmapped, skiatest::Reporter *reporter, const char *label)
static void test_compressed_data_init(GrDirectContext *dContext, skiatest::Reporter *reporter, std::function< GrBackendTexture(GrDirectContext *, const char *data, size_t dataSize, skgpu::Mipmapped)> create, SkTextureCompressionType compression, skgpu::Mipmapped mipmapped)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(CompressedBackendAllocationTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
sk_sp< SkImage > create_image(GrDirectContext *dContext, const GrBackendTexture &backendTex)
static void test_compressed_color_init(GrDirectContext *dContext, skiatest::Reporter *reporter, std::function< GrBackendTexture(GrDirectContext *, const SkColor4f &, skgpu::Mipmapped)> create, const SkColor4f &color, SkTextureCompressionType compression, skgpu::Mipmapped mipmapped)
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
@ kTopLeft_GrSurfaceOrigin
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorTRANSPARENT
size_t SkCompressedDataSize(SkTextureCompressionType type, SkISize dimensions, TArray< size_t > *individualMipOffsets, bool mipmapped)
static constexpr bool SkTextureCompressionTypeIsOpaque(SkTextureCompressionType compression)
bool CheckSolidPixels(const SkColor4f &col, const SkPixmap &pixmap, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define REPORTER_ASSERT(r, cond,...)
GrBackendFormat getBackendFormat() const
const GrCaps * caps() const
bool mipmapSupport() const
virtual bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const =0
SK_API GrBackendApi backend() const
SK_API GrBackendFormat compressedBackendFormat(SkTextureCompressionType) const
bool updateCompressedBackendTexture(const GrBackendTexture &, const SkColor4f &color, GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
GrBackendTexture createCompressedBackendTexture(int width, int height, const GrBackendFormat &, const SkColor4f &color, skgpu::Mipmapped, GrProtected=GrProtected::kNo, GrGpuFinishedProc finishedProc=nullptr, GrGpuFinishedContext finishedContext=nullptr)
void deleteBackendTexture(const GrBackendTexture &)
GrDirectContextPriv priv()
bool tryAlloc(const SkImageInfo &)
void clear(SkColor color)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
static int ComputeLevelCount(int baseWidth, int baseHeight)
bool erase(SkColor color, const SkIRect &subset) const
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)
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
Dart_NativeFunction function
static float max(float r, float g, float b)
constexpr SkColor4f kTransparent
constexpr SkColor4f kBlue
SK_API sk_sp< SkImage > TextureFromCompressedTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
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)
void FillInCompressedData(SkTextureCompressionType type, SkISize dimensions, skgpu::Mipmapped mipmapped, char *dstPixels, const SkColor4f &colorf)
static constexpr const char * CompressionTypeToStr(SkTextureCompressionType compression)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeWH(float w, float h)
std::shared_ptr< const fml::Mapping > data