Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
GrSurfaceTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTextureCompressionType.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/private/base/SkTo.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/gpu/DataUtils.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrBackendUtils.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrColorInfo.h"
#include "src/gpu/ganesh/GrDataUtils.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "src/gpu/ganesh/GrImageInfo.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
#include "src/gpu/ganesh/GrResourceCache.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrSamplerState.h"
#include "src/gpu/ganesh/GrSurface.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/SkGr.h"
#include "src/gpu/ganesh/SurfaceContext.h"
#include "src/gpu/ganesh/TestFormatColorTypeCombination.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/gpu/ContextType.h"
#include "tools/gpu/ManagedBackendTexture.h"
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <memory>
#include <tuple>
#include <utility>
#include <vector>

Go to the source code of this file.

Functions

 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)
 

Function Documentation

◆ DEF_GANESH_TEST()

DEF_GANESH_TEST ( InitialTextureClear  ,
reporter  ,
baseOptions  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 272 of file GrSurfaceTest.cpp.

272 {
273 GrContextOptions options = baseOptions;
274 options.fClearAllTextures = true;
275
276 static constexpr int kSize = 100;
277 static constexpr SkColor kClearColor = 0xABABABAB;
278
281
283 readback.alloc(imageInfo);
284
286 desc.fWidth = desc.fHeight = kSize;
287
288 for (int ct = 0; ct < skgpu::kContextTypeCount; ++ct) {
290 auto contextType = static_cast<skgpu::ContextType>(ct);
291 if (!skgpu::IsRenderingContext(contextType)) {
292 continue;
293 }
294 auto dContext = factory.get(contextType);
295 if (!dContext) {
296 continue;
297 }
298
299 GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
300 const GrCaps* caps = dContext->priv().caps();
301
302 const std::vector<GrTest::TestFormatColorTypeCombination>& combos =
303 caps->getTestingCombinations();
304
305 for (const GrTest::TestFormatColorTypeCombination& combo : combos) {
306
307 SkASSERT(combo.fColorType != GrColorType::kUnknown);
308 SkASSERT(combo.fFormat.isValid());
309
310 if (!caps->isFormatTexturable(combo.fFormat, GrTextureType::k2D)) {
311 continue;
312 }
313
314 auto checkColor = [reporter](const GrTest::TestFormatColorTypeCombination& combo,
315 uint32_t readColor) {
316 // We expect that if there is no alpha in the src color type and we read it to a
317 // color type with alpha that we will get one for alpha rather than zero. We used to
318 // require this but the Intel Iris 6100 on Win 10 test bot doesn't put one in the
319 // alpha channel when reading back from GL_RG16 or GL_RG16F. So now we allow either.
320 uint32_t channels = GrColorTypeChannelFlags(combo.fColorType);
321 bool allowAlphaOne = !(channels & kAlpha_SkColorChannelFlag);
322 if (allowAlphaOne) {
323 if (readColor != 0x00000000 && readColor != 0xFF000000) {
325 "Failed on ct %s format %s 0x%08x is not 0x00000000 or 0xFF000000",
326 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
327 readColor);
328 return false;
329 }
330 } else {
331 if (readColor) {
332 ERRORF(reporter, "Failed on ct %s format %s 0x%08x != 0x00000000",
333 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
334 readColor);
335 return false;
336 }
337 }
338 return true;
339 };
340
341 for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
342 if (renderable == GrRenderable::kYes &&
343 !caps->isFormatAsColorTypeRenderable(combo.fColorType, combo.fFormat)) {
344 continue;
345 }
346
347 for (auto fit : {SkBackingFit::kApprox, SkBackingFit::kExact}) {
348
349 // Does directly allocating a texture clear it?
350 {
351 auto proxy = proxyProvider->testingOnly_createInstantiatedProxy(
352 {kSize, kSize},
353 combo.fFormat,
354 renderable,
355 1,
356 fit,
358 GrProtected::kNo);
359 if (proxy) {
360 skgpu::Swizzle swizzle = caps->getReadSwizzle(combo.fFormat,
361 combo.fColorType);
362 GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin,
363 swizzle);
365 auto texCtx = dContext->priv().makeSC(std::move(view), info);
366
367 readback.erase(kClearColor);
368 if (texCtx->readPixels(dContext, readback, {0, 0})) {
369 for (int i = 0; i < kSize * kSize; ++i) {
370 if (!checkColor(combo, readback.addr32()[i])) {
371 break;
372 }
373 }
374 }
375 }
376
377 dContext->priv().getResourceCache()->purgeUnlockedResources(
379 }
380
381 // Try creating the texture as a deferred proxy.
382 {
387 nullptr,
388 {desc.fHeight, desc.fHeight});
389
390 auto sc = dContext->priv().makeSC(info,
391 combo.fFormat,
392 /*label=*/{},
393 fit,
395 renderable);
396 if (!sc) {
397 continue;
398 }
399
400 readback.erase(kClearColor);
401 if (sc->readPixels(dContext, readback, {0, 0})) {
402 for (int i = 0; i < kSize * kSize; ++i) {
403 if (!checkColor(combo, readback.addr32()[i])) {
404 break;
405 }
406 }
407 }
408 dContext->priv().getResourceCache()->purgeUnlockedResources(
410 }
411 }
412 }
413 }
414 }
415}
static void readback(const SkBitmap &src, int *result, int resultCount)
Definition BlurTest.cpp:264
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
reporter
static constexpr uint32_t GrColorTypeChannelFlags(GrColorType ct)
static constexpr bool GrColorTypeHasAlpha(GrColorType ct)
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
@ kOpaque_SkAlphaType
pixel is opaque
Definition SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
uint32_t SkColor
Definition SkColor.h:37
@ kAlpha_SkColorChannelFlag
Definition SkColor.h:242
#define ERRORF(r,...)
Definition Test.h:293
virtual bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const =0
virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const =0
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
Definition GrCaps.cpp:443
void alloc(const SkImageInfo &)
static constexpr int kSize
static const int kContextTypeCount
Definition ContextType.h:42
bool IsRenderingContext(skgpu::ContextType type)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ DEF_GANESH_TEST_FOR_ALL_CONTEXTS()

DEF_GANESH_TEST_FOR_ALL_CONTEXTS ( GrSurfaceRenderability  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 134 of file GrSurfaceTest.cpp.

137 {
138 auto context = ctxInfo.directContext();
139 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
140 GrResourceProvider* resourceProvider = context->priv().resourceProvider();
141 const GrCaps* caps = context->priv().caps();
142
143 // TODO: Should only need format here but need to determine compression type from format
144 // without config.
145 auto createTexture = [](SkISize dimensions, GrColorType colorType,
146 const GrBackendFormat& format, GrRenderable renderable,
149 if (compression != SkTextureCompressionType::kNone) {
150 if (renderable == GrRenderable::kYes) {
151 return nullptr;
152 }
153 auto size = SkCompressedDataSize(compression, dimensions, nullptr, false);
154 auto data = SkData::MakeUninitialized(size);
155 SkColor4f color = {0, 0, 0, 0};
156 skgpu::FillInCompressedData(compression,
157 dimensions,
158 skgpu::Mipmapped::kNo,
159 (char*)data->writable_data(),
160 color);
161 return rp->createCompressedTexture(dimensions,
162 format,
164 skgpu::Mipmapped::kNo,
165 GrProtected::kNo,
166 data.get(),
167 /*label=*/{});
168 } else {
169 return rp->createTexture(dimensions,
170 format,
172 renderable,
173 1,
174 skgpu::Mipmapped::kNo,
176 GrProtected::kNo,
177 /*label=*/{});
178 }
179 };
180
181 static constexpr SkISize kDims = {64, 64};
182
183 const std::vector<GrTest::TestFormatColorTypeCombination>& combos =
184 caps->getTestingCombinations();
185
186 for (const GrTest::TestFormatColorTypeCombination& combo : combos) {
187
188 SkASSERT(combo.fColorType != GrColorType::kUnknown);
189 SkASSERT(combo.fFormat.isValid());
190
191 // Right now Vulkan has two backend formats that support ABGR_4444 (R4G4B4A4 and B4G4R4A4).
192 // Until we can create textures directly from the backend format this yields some
193 // ambiguity in what is actually supported and which textures can be created.
194 if (ctxInfo.backend() == kVulkan_GrBackend && combo.fColorType == GrColorType::kABGR_4444) {
195 continue;
196 }
197
198 // Check if 'isFormatTexturable' agrees with 'createTexture' and that the mipmap
199 // support check is working
200 {
201 bool isCompressed = caps->isFormatCompressed(combo.fFormat);
202 bool isTexturable = caps->isFormatTexturable(combo.fFormat, GrTextureType::k2D);
203
204 sk_sp<GrSurface> tex = createTexture(kDims, combo.fColorType, combo.fFormat,
205 GrRenderable::kNo, resourceProvider);
206 REPORTER_ASSERT(reporter, SkToBool(tex) == isTexturable,
207 "ct:%s format:%s, tex:%d, isTexturable:%d",
208 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
209 SkToBool(tex), isTexturable);
210
211 // Check that the lack of mipmap support blocks the creation of mipmapped
212 // proxies
213 bool expectedMipMapability = isTexturable && caps->mipmapSupport() && !isCompressed;
214
215 sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(combo.fFormat,
216 kDims,
217 GrRenderable::kNo,
218 1,
219 skgpu::Mipmapped::kYes,
222 GrProtected::kNo,
223 /*label=*/{});
224 REPORTER_ASSERT(reporter, SkToBool(proxy.get()) == expectedMipMapability,
225 "ct:%s format:%s, tex:%d, expectedMipMapability:%d",
226 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
227 SkToBool(proxy.get()), expectedMipMapability);
228 }
229
230 // Check if 'isFormatAsColorTypeRenderable' agrees with 'createTexture' (w/o MSAA)
231 {
232 bool isRenderable = caps->isFormatRenderable(combo.fFormat, 1);
233
234 sk_sp<GrSurface> tex = resourceProvider->createTexture(kDims,
235 combo.fFormat,
237 GrRenderable::kYes,
238 1,
239 skgpu::Mipmapped::kNo,
241 GrProtected::kNo,
242 /*label=*/{});
243 REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
244 "ct:%s format:%s, tex:%d, isRenderable:%d",
245 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
246 SkToBool(tex), isRenderable);
247 }
248
249 // Check if 'isFormatAsColorTypeRenderable' agrees with 'createTexture' w/ MSAA
250 {
251 bool isRenderable = caps->isFormatRenderable(combo.fFormat, 2);
252
253 sk_sp<GrSurface> tex = resourceProvider->createTexture(kDims,
254 combo.fFormat,
256 GrRenderable::kYes,
257 2,
258 skgpu::Mipmapped::kNo,
260 GrProtected::kNo,
261 /*label=*/{});
262 REPORTER_ASSERT(reporter, SkToBool(tex) == isRenderable,
263 "ct:%s format:%s, tex:%d, isRenderable:%d",
264 GrColorTypeToStr(combo.fColorType), combo.fFormat.toStr().c_str(),
265 SkToBool(tex), isRenderable);
266 }
267 }
268}
SkTextureCompressionType GrBackendFormatToCompressionType(const GrBackendFormat &format)
GrColorType
static constexpr GrBackendApi kVulkan_GrBackend
Definition GrTypes.h:126
SkColor4f color
size_t SkCompressedDataSize(SkTextureCompressionType type, SkISize dimensions, TArray< size_t > *individualMipOffsets, bool mipmapped)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
bool mipmapSupport() const
Definition GrCaps.h:72
virtual bool isFormatRenderable(const GrBackendFormat &format, int sampleCount) const =0
bool isFormatCompressed(const GrBackendFormat &format) const
Definition GrCaps.cpp:457
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)
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition SkData.cpp:116
T * get() const
Definition SkRefCnt.h:303
uint32_t uint32_t * format
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
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
Definition switches.h:259
void FillInCompressedData(SkTextureCompressionType type, SkISize dimensions, skgpu::Mipmapped mipmapped, char *dstPixels, const SkColor4f &colorf)
Renderable
Definition GpuTypes.h:69

◆ DEF_GANESH_TEST_FOR_MOCK_CONTEXT()

DEF_GANESH_TEST_FOR_MOCK_CONTEXT ( GrSurface  ,
reporter  ,
ctxInfo   
)

Definition at line 70 of file GrSurfaceTest.cpp.

70 {
71 auto context = ctxInfo.directContext();
72 auto resourceProvider = context->priv().resourceProvider();
73
74 static constexpr SkISize kDesc = {256, 256};
75 auto format = context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
76 GrRenderable::kYes);
77 sk_sp<GrSurface> texRT1 = resourceProvider->createTexture(kDesc,
78 format,
80 GrRenderable::kYes,
81 1,
82 skgpu::Mipmapped::kNo,
84 GrProtected::kNo,
85 /*label=*/{});
86
87 REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget());
88 REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asTexture());
89 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) ==
90 texRT1->asTexture());
91 REPORTER_ASSERT(reporter, texRT1->asRenderTarget() ==
92 static_cast<GrSurface*>(texRT1->asTexture()));
93 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) ==
94 static_cast<GrSurface*>(texRT1->asTexture()));
95
96 sk_sp<GrTexture> tex1 = resourceProvider->createTexture(kDesc,
97 format,
99 GrRenderable::kNo,
100 1,
101 skgpu::Mipmapped::kNo,
103 GrProtected::kNo,
104 /*label=*/{});
105 REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
106 REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture());
107 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture());
108
109 GrBackendTexture backendTex = context->createBackendTexture(256,
110 256,
113 skgpu::Mipmapped::kNo,
114 GrRenderable::kNo,
115 GrProtected::kNo);
116
117 sk_sp<GrSurface> texRT2 = resourceProvider->wrapRenderableBackendTexture(
119
120 REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget());
121 REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture());
122 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
123 texRT2->asTexture());
124 REPORTER_ASSERT(reporter, texRT2->asRenderTarget() ==
125 static_cast<GrSurface*>(texRT2->asTexture()));
126 REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
127 static_cast<GrSurface*>(texRT2->asTexture()));
128
129 context->deleteBackendTexture(backendTex);
130}
@ kBorrow_GrWrapOwnership
Definition GrTypesPriv.h:78
constexpr SkColor4f kTransparent
Definition SkColor.h:434

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( ReadOnlyTexture  ,
reporter  ,
context_info  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 417 of file GrSurfaceTest.cpp.

420 {
421 using namespace skgpu;
422
423 auto fillPixels = [](SkPixmap* p, const std::function<uint32_t(int x, int y)>& f) {
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);
427 }
428 }
429 };
430
431 auto comparePixels = [](const SkPixmap& p1, const SkPixmap& p2, skiatest::Reporter* reporter) {
432 SkASSERT(p1.info() == p2.info());
433 for (int y = 0; y < p1.height(); ++y) {
434 for (int x = 0; x < p1.width(); ++x) {
435 REPORTER_ASSERT(reporter, p1.getColor(x, y) == p2.getColor(x, y));
436 if (p1.getColor(x, y) != p2.getColor(x, y)) {
437 return;
438 }
439 }
440 }
441 };
442
443 static constexpr int kSize = 100;
445 SkAutoPixmapStorage srcPixmap;
446 srcPixmap.alloc(ii);
447 fillPixels(&srcPixmap,
448 [](int x, int y) {
449 return (0xFFU << 24) | (x << 16) | (y << 8) | uint8_t((x * y) & 0xFF);
450 });
451
452 auto dContext = context_info.directContext();
453 GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
454
455 Protected isProtected = Protected(dContext->priv().caps()->supportsProtectedContent());
456
457 // We test both kRW in addition to kRead mostly to ensure that the calls are structured such
458 // that they'd succeed if the texture wasn't kRead. We want to be sure we're failing with
459 // kRead for the right reason.
460 for (auto ioType : {kRead_GrIOType, kRW_GrIOType}) {
461 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithData(dContext,
462 srcPixmap,
464 GrRenderable::kNo,
465 isProtected);
466 if (!mbet) {
467 ERRORF(reporter, "Could not make texture.");
468 return;
469 }
470 auto proxy = proxyProvider->wrapBackendTexture(mbet->texture(), kBorrow_GrWrapOwnership,
471 GrWrapCacheable::kNo, ioType,
472 mbet->refCountedCallback());
473 Swizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
475 GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
476 auto surfContext = dContext->priv().makeSC(std::move(view), ii.colorInfo());
477 // Read pixels should work with a read-only texture.
478 {
480 read.alloc(srcPixmap.info());
481 auto readResult = surfContext->readPixels(dContext, read, {0, 0});
482 REPORTER_ASSERT(reporter, readResult);
483 if (readResult) {
484 comparePixels(srcPixmap, read, reporter);
485 }
486 }
487
488 // Write pixels should not work with a read-only texture.
490 write.alloc(srcPixmap.info());
491 fillPixels(&write, [&srcPixmap](int x, int y) { return ~*srcPixmap.addr32(); });
492 auto writeResult = surfContext->writePixels(dContext, write, {0, 0});
493 REPORTER_ASSERT(reporter, writeResult == (ioType == kRW_GrIOType));
494 // Try the low level write.
495 dContext->flushAndSubmit();
496 auto gpuWriteResult = dContext->priv().getGpu()->writePixels(
497 proxy->peekTexture(),
501 write.addr32(),
503 REPORTER_ASSERT(reporter, gpuWriteResult == (ioType == kRW_GrIOType));
504
505 SkBitmap copySrcBitmap;
506 copySrcBitmap.installPixels(write);
507 copySrcBitmap.setImmutable();
508
509 auto copySrc = std::get<0>(GrMakeUncachedBitmapProxyView(dContext, copySrcBitmap));
510
511 REPORTER_ASSERT(reporter, copySrc);
512 auto copyResult = surfContext->testCopy(copySrc.refProxy());
513 REPORTER_ASSERT(reporter, copyResult == (ioType == kRW_GrIOType));
514 // Try the low level copy.
515 dContext->flushAndSubmit();
516 auto gpuCopyResult = dContext->priv().getGpu()->copySurface(
517 proxy->peekSurface(),
519 copySrc.proxy()->peekSurface(),
521 GrSamplerState::Filter::kNearest);
522 REPORTER_ASSERT(reporter, gpuCopyResult == (ioType == kRW_GrIOType));
523
524 // Mip regen should not work with a read only texture.
525 if (dContext->priv().caps()->mipmapSupport()) {
526 mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(dContext,
527 kSize,
528 kSize,
530 Mipmapped::kYes,
531 GrRenderable::kNo,
532 isProtected);
533 proxy = proxyProvider->wrapBackendTexture(mbet->texture(), kBorrow_GrWrapOwnership,
534 GrWrapCacheable::kNo, ioType,
535 mbet->refCountedCallback());
536 dContext->flushAndSubmit();
537 proxy->peekTexture()->markMipmapsDirty(); // avoids assert in GrGpu.
538 auto regenResult =
539 dContext->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
540 REPORTER_ASSERT(reporter, regenResult == (ioType == kRW_GrIOType));
541 }
542 }
543}
static constexpr size_t GrColorTypeBytesPerPixel(GrColorType ct)
@ kRead_GrIOType
@ kRW_GrIOType
skgpu::Protected Protected
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)
Definition SkGr.cpp:253
sk_sp< GrTextureProxy > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType, sk_sp< skgpu::RefCntedCallback >=nullptr)
GrTexture * peekTexture() const
void markMipmapsDirty()
Definition GrTexture.cpp:25
void setImmutable()
Definition SkBitmap.cpp:400
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition SkBitmap.cpp:323
SkColor getColor(int x, int y) const
Definition SkPixmap.cpp:187
const uint32_t * addr32() const
Definition SkPixmap.h:352
int width() const
Definition SkPixmap.h:160
const SkImageInfo & info() const
Definition SkPixmap.h:135
int height() const
Definition SkPixmap.h:166
double y
double x
Protected
Definition GpuTypes.h:61
void write(SkWStream *wStream, const T &text)
Definition skqp.cpp:188
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
const SkColorInfo & colorInfo() const