62#include <initializer_list>
71 auto context = ctxInfo.directContext();
72 auto resourceProvider = context->priv().resourceProvider();
74 static constexpr SkISize kDesc = {256, 256};
129 context->deleteBackendTexture(backendTex);
138 auto context = ctxInfo.directContext();
141 const GrCaps* caps = context->priv().caps();
159 (
char*)
data->writable_data(),
161 return rp->createCompressedTexture(dimensions,
169 return rp->createTexture(dimensions,
181 static constexpr SkISize kDims = {64, 64};
183 const std::vector<GrTest::TestFormatColorTypeCombination>& combos =
184 caps->getTestingCombinations();
204 sk_sp<GrSurface> tex = createTexture(kDims, combo.fColorType, combo.fFormat,
207 "ct:%s format:%s, tex:%d, isTexturable:%d",
208 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
213 bool expectedMipMapability = isTexturable && caps->
mipmapSupport() && !isCompressed;
225 "ct:%s format:%s, tex:%d, expectedMipMapability:%d",
226 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
244 "ct:%s format:%s, tex:%d, isRenderable:%d",
245 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
263 "ct:%s format:%s, tex:%d, isRenderable:%d",
264 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
274 options.fClearAllTextures =
true;
276 static constexpr int kSize = 100;
277 static constexpr SkColor kClearColor = 0xABABABAB;
294 auto dContext = factory.
get(contextType);
300 const GrCaps* caps = dContext->priv().caps();
302 const std::vector<GrTest::TestFormatColorTypeCombination>& combos =
303 caps->getTestingCombinations();
315 uint32_t readColor) {
323 if (readColor != 0x00000000 && readColor != 0xFF000000) {
325 "Failed on ct %s format %s 0x%08x is not 0x00000000 or 0xFF000000",
332 ERRORF(
reporter,
"Failed on ct %s format %s 0x%08x != 0x00000000",
351 auto proxy = proxyProvider->testingOnly_createInstantiatedProxy(
365 auto texCtx = dContext->priv().makeSC(std::move(view),
info);
368 if (texCtx->readPixels(dContext,
readback, {0, 0})) {
370 if (!checkColor(combo,
readback.addr32()[
i])) {
377 dContext->priv().getResourceCache()->purgeUnlockedResources(
388 {desc.fHeight, desc.fHeight});
390 auto sc = dContext->priv().makeSC(
info,
401 if (sc->readPixels(dContext,
readback, {0, 0})) {
403 if (!checkColor(combo,
readback.addr32()[
i])) {
408 dContext->priv().getResourceCache()->purgeUnlockedResources(
421 using namespace skgpu;
424 for (
int y = 0;
y <
p->height(); ++
y) {
425 for (
int x = 0;
x <
p->width(); ++
x) {
426 *
p->writable_addr32(
x,
y) =
f(
x,
y);
434 for (
int x = 0;
x < p1.
width(); ++
x) {
443 static constexpr int kSize = 100;
447 fillPixels(&srcPixmap,
449 return (0xFFU << 24) | (
x << 16) | (
y << 8) | uint8_t((
x *
y) & 0xFF);
452 auto dContext = context_info.directContext();
455 Protected isProtected =
Protected(dContext->priv().caps()->supportsProtectedContent());
472 mbet->refCountedCallback());
473 Swizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
476 auto surfContext = dContext->priv().makeSC(std::move(view), ii.
colorInfo());
481 auto readResult = surfContext->readPixels(dContext,
read, {0, 0});
491 fillPixels(&
write, [&srcPixmap](
int x,
int y) {
return ~*srcPixmap.
addr32(); });
492 auto writeResult = surfContext->writePixels(dContext,
write, {0, 0});
495 dContext->flushAndSubmit();
496 auto gpuWriteResult = dContext->priv().getGpu()->writePixels(
497 proxy->peekTexture(),
512 auto copyResult = surfContext->testCopy(copySrc.refProxy());
515 dContext->flushAndSubmit();
516 auto gpuCopyResult = dContext->priv().getGpu()->copySurface(
517 proxy->peekSurface(),
519 copySrc.proxy()->peekSurface(),
525 if (dContext->priv().caps()->mipmapSupport()) {
526 mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(dContext,
535 mbet->refCountedCallback());
536 dContext->flushAndSubmit();
539 dContext->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
static void readback(const SkBitmap &src, int *result, int resultCount)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
DEF_GANESH_TEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo)
DEF_GANESH_TEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
DEF_GANESH_TEST(InitialTextureClear, reporter, baseOptions, CtsEnforcement::kApiLevel_T)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info, CtsEnforcement::kApiLevel_T)
static constexpr uint32_t GrColorTypeChannelFlags(GrColorType ct)
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
@ kBorrow_GrWrapOwnership
static constexpr bool GrColorTypeHasAlpha(GrColorType ct)
@ kTopLeft_GrSurfaceOrigin
static constexpr GrBackendApi kVulkan_GrBackend
skgpu::Protected Protected
@ 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
@ kAlpha_SkColorChannelFlag
size_t SkCompressedDataSize(SkTextureCompressionType type, SkISize dimensions, TArray< size_t > *individualMipOffsets, bool mipmapped)
static bool read(SkStream *stream, void *buffer, size_t amount)
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeUncachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, skgpu::Mipmapped mipmapped, SkBackingFit fit, skgpu::Budgeted budgeted)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static constexpr bool SkToBool(const T &x)
#define REPORTER_ASSERT(r, cond,...)
bool mipmapSupport() const
virtual bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const =0
virtual bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) const =0
bool isFormatCompressed(const GrBackendFormat &format) const
virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const =0
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
sk_sp< GrTextureProxy > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType, sk_sp< skgpu::RefCntedCallback >=nullptr)
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
GrResourceProviderPriv priv()
sk_sp< GrTexture > createTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped mipmapped, skgpu::Budgeted budgeted, skgpu::Protected isProtected, std::string_view label)
GrTexture * peekTexture() const
virtual GrTexture * asTexture()
virtual GrRenderTarget * asRenderTarget()
GrTexture * asTexture() override
void alloc(const SkImageInfo &)
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
static sk_sp< SkData > MakeUninitialized(size_t length)
SkColor getColor(int x, int y) const
const uint32_t * addr32() const
const SkImageInfo & info() const
GrDirectContext * get(ContextType type, ContextOverrides overrides=ContextOverrides::kNone)
uint32_t uint32_t * format
Dart_NativeFunction function
constexpr SkColor4f kTransparent
SK_API sk_sp< SkPixelRef > MakeWithData(const SkImageInfo &, size_t rowBytes, sk_sp< SkData > data)
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
const myers::Point & get< 0 >(const myers::Segment &s)
void FillInCompressedData(SkTextureCompressionType type, SkISize dimensions, skgpu::Mipmapped mipmapped, char *dstPixels, const SkColor4f &colorf)
static const int kContextTypeCount
bool IsRenderingContext(skgpu::ContextType type)
void write(SkWStream *wStream, const T &text)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
const SkColorInfo & colorInfo() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data