59#include <initializer_list>
80#if defined(SK_DIRECT3D)
94using sk_gpu_test::ManagedBackendTexture;
106 const int initialCount =
cache->getResourceCount();
110 ERRORF(
reporter,
"Couldn't create backendTexture for grColorType %d renderable %s\n",
129 int cacheEntriesPerProxy = 1;
134 cacheEntriesPerProxy++;
146 ERRORF(
reporter,
"Couldn't make SkSurface from backendTexture for %s\n",
150 initialCount + cacheEntriesPerProxy ==
cache->getResourceCount());
162 ERRORF(
reporter,
"Couldn't make SkImage from backendTexture for %s\n",
173 initialCount + cacheEntriesPerProxy ==
cache->getResourceCount());
181 switch (
format.backend()) {
205 DXGI_FORMAT d3dFormat;
206 format.asDxgiFormat(&d3dFormat);
207 return d3dFormat == DXGI_FORMAT_B8G8R8A8_UNORM;
228 switch (
format.backend()) {
261 const char* label2) {
264 const float tols[4] = { 0.01f, 0.01f, 0.01f, 0.01f };
266 auto error = std::function<ComparePixmapsErrorReporter>(
267 [
reporter, ct, label1, label2, expected](
int x,
int y,
const float diffs[4]) {
270 "expected (%.2f, %.2f, %.2f %.2f) "
271 "- diffs (%.2f, %.2f, %.2f %.2f)",
272 GrColorTypeToStr(ct), label1, label2,
x,
y,
273 expected.fR, expected.fG, expected.fB, expected.fA,
274 diffs[0], diffs[1], diffs[2], diffs[3]);
283 std::unique_ptr<char[]>
data(
new char[ii.minRowBytes()]);
346 if (!surfaceContext) {
347 ERRORF(
reporter,
"Could not create surface context for colorType: %d\n",
351 if (!surfaceContext->readPixels(dContext, actual, {0, 0})) {
355 ERRORF(
reporter,
"Couldn't readback from SurfaceContext for colorType: %d\n",
361 :
"SurfaceContext"));
383 auto checkBackendTexture = [&](
const SkColor4f& testColor) {
386 SkColor4f expectedColors[6] = {expectedColor, expectedColor, expectedColor,
387 expectedColor, expectedColor, expectedColor};
397 checkBackendTexture(
color);
407 ManagedBackendTexture::ReleaseProc,
408 mbet->releaseContext());
409 checkBackendTexture(newColor);
441 if (!dstFillContext) {
446 constexpr int kNumMipLevels = 6;
460 for (
int i = 0, rectSize = 32;
i < kNumMipLevels; ++
i, rectSize /= 2) {
472 *dstFillContext->caps());
473 dstFillContext->fillRectWithFP(
SkIRect::MakeWH(rectSize, rectSize), std::move(
fp));
482 bool result = dstFillContext->readPixels(dContext, actual, {0, 0});
505 std::unique_ptr<char[]> memForPixmaps;
507 { 1.0f, 0.0f, 0.0f, 1.0f },
508 { 0.0f, 1.0f, 0.0f, 0.9f },
509 { 0.0f, 0.0f, 1.0f, 0.7f },
510 { 0.0f, 1.0f, 1.0f, 0.5f },
511 { 1.0f, 0.0f, 1.0f, 0.3f },
512 { 1.0f, 1.0f, 0.0f, 0.2f },
558 {1.0f, 1.0f, 0.0f, 0.2f},
559 {1.0f, 0.0f, 0.0f, 1.0f},
560 {0.0f, 1.0f, 0.0f, 0.9f},
561 {0.0f, 0.0f, 1.0f, 0.7f},
562 {0.0f, 1.0f, 1.0f, 0.5f},
563 {1.0f, 0.0f, 1.0f, 0.3f},
577 ManagedBackendTexture::ReleaseProc,
578 mbet->releaseContext());
580 checkBackendTexture(kColorsNew);
589#if defined(SK_VULKAN) && defined(SK_DEBUG)
600 using namespace skgpu;
603 const GrCaps* caps = context->priv().caps();
607 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
608 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 0.75f };
646 for (
auto combo : combinations) {
684 auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
761 createWithSrcDataMtd,
780 if (!
info.directContext()) {
786 if (
info.directContext()->priv().caps()->writePixelsRowBytesSupport() &&
789 overrideOptions.fDisallowWriteAndTransferPixelRowBytes =
true;
806 auto context = ctxInfo.directContext();
807 const GrGLCaps* glCaps =
static_cast<const GrGLCaps*
>(context->priv().caps());
809 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
810 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 1.f };
811 constexpr SkColor4f kTransGrayCol { 0.5f, 0.5f, 0.5f, .8f };
857 for (
auto combo : combinations) {
893 return ManagedBackendTexture::MakeWithoutData(dContext,
902 mipmapped, renderable);
915 switch (combo.fColorType) {
942 combo.fColor, mipmapped, renderable);
960 using namespace skgpu;
962 auto context = ctxInfo.directContext();
963 const GrVkCaps* vkCaps =
static_cast<const GrVkCaps*
>(context->priv().caps());
967 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
968 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 1 };
987 { 0.25f, 0.5f, 0.75f, 1.0f }},
989 { 0.25f, 0.5f, 0.75f, 1.0f }},
991 { 0.25f, 0.5f, 0.75f, 1.0f }},
1016 for (
auto combo : combinations) {
1043 auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
1067 switch (combo.fColorType) {
1106 combo.fColor, mipmapped, renderable);
DEF_GANESH_TEST(ColorTypeBackendAllocationTest, reporter, options, CtsEnforcement::kApiLevel_T)
static void check_solid_pixmap(skiatest::Reporter *reporter, const SkColor4f &expected, const SkPixmap &actual, GrColorType ct, const char *label1, const char *label2)
void check_vk_tiling(const GrBackendTexture &backendTex)
static bool isRGB(const GrBackendFormat &format)
void test_color_init(GrDirectContext *dContext, skiatest::Reporter *reporter, const std::function< sk_sp< ManagedBackendTexture >(GrDirectContext *, const SkColor4f &, skgpu::Mipmapped, GrRenderable)> &create, GrColorType colorType, const SkColor4f &color, skgpu::Mipmapped mipmapped, GrRenderable renderable)
static SkColor4f get_expected_color(SkColor4f orig, GrColorType ct)
static void check_base_readbacks(GrDirectContext *dContext, const GrBackendTexture &backendTex, GrColorType colorType, GrRenderable renderableTexture, const SkColor4f &color, skiatest::Reporter *reporter, const char *label)
static void check_mipmaps(GrDirectContext *, const GrBackendTexture &, GrColorType, const SkColor4f expectedColors[6], skiatest::Reporter *, const char *label)
void test_pixmap_init(GrDirectContext *dContext, skiatest::Reporter *reporter, const std::function< sk_sp< ManagedBackendTexture >(GrDirectContext *, const SkPixmap srcData[], int numLevels, GrSurfaceOrigin, GrRenderable)> &create, SkColorType skColorType, GrSurfaceOrigin origin, skgpu::Mipmapped mipmapped, GrRenderable renderable)
static bool isBGRA8(const GrBackendFormat &format)
void color_type_backend_allocation_test(const sk_gpu_test::ContextInfo &ctxInfo, skiatest::Reporter *reporter)
void test_wrapping(GrDirectContext *dContext, skiatest::Reporter *reporter, const std::function< sk_sp< ManagedBackendTexture >(GrDirectContext *, skgpu::Mipmapped, GrRenderable)> &create, GrColorType grColorType, skgpu::Mipmapped mipmapped, GrRenderable renderable)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
bool GrConvertPixels(const GrPixmap &dst, const GrCPixmap &src, bool flipY)
bool GrClearImage(const GrImageInfo &dstInfo, void *dst, size_t dstRB, std::array< float, 4 > color)
#define GR_GL_SRGB8_ALPHA8
#define GR_GL_LUMINANCE8_ALPHA8
#define GR_GL_LUMINANCE16F
#define GR_GL_TEXTURE_RECTANGLE
@ kBorrow_GrWrapOwnership
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
skgpu::Protected Protected
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
@ kLastEnum_SkColorType
last valid value
@ kSRGBA_8888_SkColorType
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
@ kA16_float_SkColorType
pixel with a half float for alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
@ kUnknown_SkColorType
uninitialized
@ kR16G16_float_SkColorType
pixel with a half float for red and green
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
bool CheckSolidPixels(const SkColor4f &col, const SkPixmap &pixmap, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(name, reporter, context_info, ctsEnforcement)
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GANESH_TEST_FOR_GL_CONTEXT(name, reporter, context_info, ctsEnforcement)
GrBackendFormat getBackendFormat() const
const GrCaps * caps() const
bool mipmapSupport() const
bool supportsProtectedContent() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
SK_API GrBackendApi backend() const
SK_API GrBackendFormat defaultBackendFormat(SkColorType, GrRenderable) const
GrResourceCache * getResourceCache()
SK_API bool colorTypeSupportedAsSurface(SkColorType colorType) const
bool updateBackendTexture(const GrBackendTexture &, const SkColor4f &color, GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext)
GrDirectContextPriv priv()
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const override
GrGLStandard standard() const
const GrGLContextInfo & ctxInfo() const
sk_sp< GrTextureProxy > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType, sk_sp< skgpu::RefCntedCallback >=nullptr)
sk_sp< GrTextureProxy > wrapRenderableBackendTexture(const GrBackendTexture &, int sampleCnt, GrWrapOwnership, GrWrapCacheable, sk_sp< skgpu::RefCntedCallback > releaseHelper)
GrProxyProvider * proxyProvider()
std::unique_ptr< skgpu::ganesh::SurfaceContext > makeSC(GrSurfaceProxyView readView, const GrColorInfo &)
std::unique_ptr< skgpu::ganesh::SurfaceFillContext > makeSFC(GrImageInfo, std::string_view label, SkBackingFit=SkBackingFit::kExact, int sampleCount=1, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Protected=skgpu::Protected::kNo, GrSurfaceOrigin=kTopLeft_GrSurfaceOrigin, skgpu::Budgeted=skgpu::Budgeted::kYes)
bool isInstantiated() const
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
skgpu::Mipmapped proxyMipmapped() const
skgpu::Mipmapped mipmapped() const
bool isVkFormatTexturable(VkFormat) const
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
bool tryAlloc(const SkImageInfo &)
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
bool erase(SkColor color, const SkIRect &subset) const
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
GrDirectContext * directContext() const
const GrGLInterface * gl() const
ContextInfo getContextInfo(ContextType type, ContextOverrides=ContextOverrides::kNone)
constexpr std::array< float, 4 > applyTo(std::array< float, 4 > color) const
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
Dart_NativeFunction function
SK_API bool GetVkImageInfo(const GrBackendTexture &, GrVkImageInfo *)
constexpr SkColor4f kLtGray
constexpr SkColor4f kGreen
constexpr SkColor4f kCyan
constexpr SkColor4f kTransparent
constexpr SkColor4f kGray
constexpr SkColor4f kBlue
constexpr SkColor4f kYellow
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkPixelRef > MakeWithData(const SkImageInfo &, size_t rowBytes, sk_sp< SkData > data)
PODArray< SkColor > colors
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
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
GrTextureProxy * GetTextureImageProxy(SkImage *image, GrRecordingContext *rContext)
static const int kContextTypeCount
bool IsRenderingContext(skgpu::ContextType type)
VkImageTiling fImageTiling
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data
@ VK_IMAGE_TILING_OPTIMAL
@ VK_FORMAT_R16G16B16A16_UNORM
@ VK_FORMAT_R8G8B8A8_SRGB
@ VK_FORMAT_B8G8R8A8_UNORM
@ VK_FORMAT_R16G16_SFLOAT
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
@ VK_FORMAT_R5G6B5_UNORM_PACK16
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
@ VK_FORMAT_R8G8B8A8_UNORM
@ VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16
@ VK_FORMAT_R16G16B16A16_SFLOAT
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32