Flutter Engine
The Flutter Engine
BackendAllocationTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
15#include "include/core/SkRect.h"
25#include "include/gpu/GrTypes.h"
32#include "src/gpu/Swizzle.h"
50#include "tests/Test.h"
51#include "tests/TestUtils.h"
52#include "tools/ToolUtils.h"
56
57#include <array>
58#include <functional>
59#include <initializer_list>
60#include <memory>
61#include <utility>
62
63#if defined(SK_GL)
72#endif
73
74#if defined(SK_METAL)
78#endif
79
80#if defined(SK_DIRECT3D)
82#endif
83
84#if defined(SK_VULKAN)
88#include <vulkan/vulkan_core.h>
89#endif
90
91class SkImage;
92class SkSurface;
93
94using sk_gpu_test::ManagedBackendTexture;
95
96// Test wrapping of GrBackendObjects in SkSurfaces and SkImages (non-static since used in Mtl test)
101 GrColorType grColorType,
102 skgpu::Mipmapped mipmapped,
103 GrRenderable renderable) {
105
106 const int initialCount = cache->getResourceCount();
107
108 sk_sp<ManagedBackendTexture> mbet = create(dContext, mipmapped, renderable);
109 if (!mbet) {
110 ERRORF(reporter, "Couldn't create backendTexture for grColorType %d renderable %s\n",
111 (int)grColorType,
112 GrRenderable::kYes == renderable ? "yes" : "no");
113 return;
114 }
115
116 // Skia proper should know nothing about the new backend object
117 REPORTER_ASSERT(reporter, initialCount == cache->getResourceCount());
118
119 SkColorType skColorType = GrColorTypeToSkColorType(grColorType);
120
121 // Wrapping a backendTexture in an SkImage/SkSurface requires an SkColorType
122 if (skColorType == kUnknown_SkColorType) {
123 return;
124 }
125
126 // As we transition to using attachments instead of GrTextures and GrRenderTargets individual
127 // proxy instansiations may add multiple things to the cache. There would be an entry for the
128 // GrTexture/GrRenderTarget and entries for one or more attachments.
129 int cacheEntriesPerProxy = 1;
130 // We currently only have attachments on the vulkan and metal backends
131 if (dContext->backend() == GrBackend::kVulkan || dContext->backend() == GrBackend::kMetal) {
132 // If we ever make a rt with multisamples this would have an additional
133 // attachment as well.
134 cacheEntriesPerProxy++;
135 }
136
137 if (GrRenderable::kYes == renderable && dContext->colorTypeSupportedAsSurface(skColorType)) {
139 mbet->texture(),
141 0,
142 skColorType,
143 nullptr,
144 nullptr);
145 if (!surf) {
146 ERRORF(reporter, "Couldn't make SkSurface from backendTexture for %s\n",
147 ToolUtils::colortype_name(skColorType));
148 } else {
150 initialCount + cacheEntriesPerProxy == cache->getResourceCount());
151 }
152 }
153
154 {
156 mbet->texture(),
158 skColorType,
160 nullptr);
161 if (!img) {
162 ERRORF(reporter, "Couldn't make SkImage from backendTexture for %s\n",
163 ToolUtils::colortype_name(skColorType));
164 } else {
165 GrTextureProxy* proxy = sk_gpu_test::GetTextureImageProxy(img.get(), dContext);
167
168 REPORTER_ASSERT(reporter, mipmapped == proxy->proxyMipmapped());
170 REPORTER_ASSERT(reporter, mipmapped == proxy->mipmapped());
171
173 initialCount + cacheEntriesPerProxy == cache->getResourceCount());
174 }
175 }
176
177 REPORTER_ASSERT(reporter, initialCount == cache->getResourceCount());
178}
179
180static bool isBGRA8(const GrBackendFormat& format) {
181 switch (format.backend()) {
183#ifdef SK_GL
185#else
186 return false;
187#endif
189#ifdef SK_VULKAN
190 VkFormat vkFormat;
192 return vkFormat == VK_FORMAT_B8G8R8A8_UNORM;
193#else
194 return false;
195#endif
196 }
198#ifdef SK_METAL
199 return GrMtlFormatIsBGRA8(GrBackendFormats::AsMtlFormat(format));
200#else
201 return false;
202#endif
204#ifdef SK_DIRECT3D
205 DXGI_FORMAT d3dFormat;
206 format.asDxgiFormat(&d3dFormat);
207 return d3dFormat == DXGI_FORMAT_B8G8R8A8_UNORM;
208#else
209 return false;
210#endif
211 }
212 case GrBackendApi::kMock: {
213 SkTextureCompressionType compression = format.asMockCompressionType();
214 if (compression != SkTextureCompressionType::kNone) {
215 return false; // No compressed formats are BGRA
216 }
217
218 return format.asMockColorType() == GrColorType::kBGRA_8888;
219 }
221 return false;
222 }
223 }
225}
226
227static bool isRGB(const GrBackendFormat& format) {
228 switch (format.backend()) {
230#ifdef SK_GL
232#else
233 return false;
234#endif
236#ifdef SK_VULKAN
237 VkFormat vkFormat;
239 return vkFormat == VK_FORMAT_R8G8B8_UNORM;
240#else
241 return false;
242#endif
243 }
245 return false; // Metal doesn't even pretend to support this
247 return false; // Not supported in Direct3D 12
249 return format.asMockColorType() == GrColorType::kRGB_888;
251 return false;
252 }
254}
255
257 const SkColor4f& expected,
258 const SkPixmap& actual,
259 GrColorType ct,
260 const char* label1,
261 const char* label2) {
262 // we need 0.001f across the board just for noise
263 // we need 0.01f across the board for 1010102
264 const float tols[4] = { 0.01f, 0.01f, 0.01f, 0.01f };
265
266 auto error = std::function<ComparePixmapsErrorReporter>(
267 [reporter, ct, label1, label2, expected](int x, int y, const float diffs[4]) {
268 SkASSERT(x >= 0 && y >= 0);
269 ERRORF(reporter, "%s %s %s - mismatch at %d, %d "
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]);
275 });
276
277 CheckSolidPixels(expected, actual, tols, error);
278}
279
280// Determine what color we expect if we store 'orig' in 'ct' converted back to SkColor4f.
282 GrImageInfo ii(ct, kUnpremul_SkAlphaType, nullptr, {1, 1});
283 std::unique_ptr<char[]> data(new char[ii.minRowBytes()]);
284 GrClearImage(ii, data.get(), ii.minRowBytes(), orig.array());
285
286 // Read back to SkColor4f.
288 GrImageInfo resultII(GrColorType::kRGBA_F32, kUnpremul_SkAlphaType, nullptr, {1, 1});
289 GrConvertPixels(GrPixmap(resultII, &result.fR, sizeof(result)),
290 GrPixmap( ii, data.get(), ii.minRowBytes()));
291 return result;
292}
293
294static void check_mipmaps(GrDirectContext*,
295 const GrBackendTexture&,
297 const SkColor4f expectedColors[6],
299 const char* label);
300
302 const GrBackendTexture& backendTex,
304 GrRenderable renderableTexture,
305 const SkColor4f& color,
307 const char* label) {
308 if (isRGB(backendTex.getBackendFormat())) {
309 // readPixels is busted for the RGB backend format (skbug.com/8862)
310 // TODO: add a GrColorType::kRGB_888 to fix the situation
311 return;
312 }
313
315
316 SkAutoPixmapStorage actual;
317
318 {
319 SkImageInfo readBackII = SkImageInfo::Make(32, 32,
322
323 SkAssertResult(actual.tryAlloc(readBackII));
324 }
325 for (GrRenderable renderableCtx : {GrRenderable::kNo, GrRenderable::kYes}) {
326 if (renderableCtx == GrRenderable::kYes && renderableTexture == GrRenderable::kNo) {
327 continue;
328 }
330 if (renderableCtx == GrRenderable::kYes) {
331 proxy = dContext->priv().proxyProvider()->wrapRenderableBackendTexture(
332 backendTex, 1, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, nullptr);
333 } else {
334 proxy = dContext->priv().proxyProvider()->wrapBackendTexture(
336 }
337 if (!proxy) {
338 ERRORF(reporter, "Could not make proxy from backend texture");
339 return;
340 }
341 auto swizzle = dContext->priv().caps()->getReadSwizzle(backendTex.getBackendFormat(),
342 colorType);
343 GrSurfaceProxyView readView(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
345 auto surfaceContext = dContext->priv().makeSC(readView, info);
346 if (!surfaceContext) {
347 ERRORF(reporter, "Could not create surface context for colorType: %d\n",
348 (int)colorType);
349 }
350
351 if (!surfaceContext->readPixels(dContext, actual, {0, 0})) {
352 // TODO: we need a better way to tell a priori if readPixels will work for an
353 // arbitrary colorType
354#if 0
355 ERRORF(reporter, "Couldn't readback from SurfaceContext for colorType: %d\n",
356 (int)colorType);
357#endif
358 } else {
359 auto name = SkStringPrintf("%s::readPixels",
360 (renderableCtx == GrRenderable::kYes ? "SurfaceFillContext"
361 : "SurfaceContext"));
362 check_solid_pixmap(reporter, expectedColor, actual, colorType, label, name.c_str());
363 }
364 }
365}
366
367// Test initialization of GrBackendObjects to a specific color (non-static since used in Mtl test)
369 GrDirectContext* dContext,
374 const SkColor4f& color,
375 skgpu::Mipmapped mipmapped,
376 GrRenderable renderable) {
377 sk_sp<ManagedBackendTexture> mbet = create(dContext, color, mipmapped, renderable);
378 if (!mbet) {
379 // errors here should be reported by the test_wrapping test
380 return;
381 }
382
383 auto checkBackendTexture = [&](const SkColor4f& testColor) {
384 if (mipmapped == skgpu::Mipmapped::kYes) {
385 SkColor4f expectedColor = get_expected_color(testColor, colorType);
386 SkColor4f expectedColors[6] = {expectedColor, expectedColor, expectedColor,
387 expectedColor, expectedColor, expectedColor};
388 check_mipmaps(dContext, mbet->texture(), colorType, expectedColors, reporter,
389 "colorinit");
390 }
391
392 // The last step in this test will dirty the mipmaps so do it last
393 check_base_readbacks(dContext, mbet->texture(), colorType, renderable, testColor, reporter,
394 "colorinit");
395 };
396
397 checkBackendTexture(color);
398
399 SkColor4f newColor = {color.fB , color.fR, color.fG, color.fA };
400
402 // Our update method only works with SkColorTypes.
403 if (skColorType != kUnknown_SkColorType) {
404 dContext->updateBackendTexture(mbet->texture(),
405 skColorType,
406 newColor,
407 ManagedBackendTexture::ReleaseProc,
408 mbet->releaseContext());
409 checkBackendTexture(newColor);
410 }
411}
412
413// Draw the backend texture into an RGBA surface fill context, attempting to access all the mipMap
414// levels.
415static void check_mipmaps(GrDirectContext* dContext,
416 const GrBackendTexture& backendTex,
418 const SkColor4f expectedColors[6],
420 const char* label) {
421#ifdef SK_GL
422 // skbug.com/9141 (RGBA_F32 mipmaps appear to be broken on some Mali devices)
423 if (GrBackendApi::kOpenGL == dContext->backend()) {
424 GrGLGpu* glGPU = static_cast<GrGLGpu*>(dContext->priv().getGpu());
425
427 glGPU->ctxInfo().standard() == kGLES_GrGLStandard) {
428 return;
429 }
430 }
431#endif
432
433 if (isRGB(backendTex.getBackendFormat())) {
434 // readPixels is busted for the RGB backend format (skbug.com/8862)
435 // TODO: add a GrColorType::kRGB_888 to fix the situation
436 return;
437 }
438
440 auto dstFillContext = dContext->priv().makeSFC(info, /*label=*/{});
441 if (!dstFillContext) {
442 ERRORF(reporter, "Could not make dst fill context.");
443 return;
444 }
445
446 constexpr int kNumMipLevels = 6;
447
448 auto proxy = dContext->priv().proxyProvider()->wrapBackendTexture(backendTex,
452 if (!proxy) {
453 ERRORF(reporter, "Could not make proxy from backend texture");
454 return;
455 }
456 auto swizzle = dContext->priv().caps()->getReadSwizzle(backendTex.getBackendFormat(),
457 colorType);
458 GrSurfaceProxyView readView(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
459
460 for (int i = 0, rectSize = 32; i < kNumMipLevels; ++i, rectSize /= 2) {
461 SkASSERT(rectSize >= 1);
462 dstFillContext->clear(SK_PMColor4fTRANSPARENT);
463
464 SkMatrix texMatrix;
465 texMatrix.setScale(1 << i, 1 << i);
466 static constexpr GrSamplerState kNearestNearest(GrSamplerState::Filter::kNearest,
468 auto fp = GrTextureEffect::Make(readView,
470 texMatrix,
471 kNearestNearest,
472 *dstFillContext->caps());
473 dstFillContext->fillRectWithFP(SkIRect::MakeWH(rectSize, rectSize), std::move(fp));
474
475 SkImageInfo readbackII = SkImageInfo::Make(rectSize, rectSize,
478 SkAutoPixmapStorage actual;
479 SkAssertResult(actual.tryAlloc(readbackII));
481
482 bool result = dstFillContext->readPixels(dContext, actual, {0, 0});
484
485 SkString str;
486 str.appendf("mip-level %d", i);
487
488 check_solid_pixmap(reporter, expectedColors[i], actual, colorType, label, str.c_str());
489 }
490}
491
492// Test initialization of GrBackendObjects using SkPixmaps (non-static since used in Mtl test)
496 const SkPixmap srcData[],
497 int numLevels,
500 SkColorType skColorType,
501 GrSurfaceOrigin origin,
502 skgpu::Mipmapped mipmapped,
503 GrRenderable renderable) {
504 SkPixmap pixmaps[6];
505 std::unique_ptr<char[]> memForPixmaps;
506 constexpr SkColor4f kColors[6] = {
507 { 1.0f, 0.0f, 0.0f, 1.0f }, // R
508 { 0.0f, 1.0f, 0.0f, 0.9f }, // G
509 { 0.0f, 0.0f, 1.0f, 0.7f }, // B
510 { 0.0f, 1.0f, 1.0f, 0.5f }, // C
511 { 1.0f, 0.0f, 1.0f, 0.3f }, // M
512 { 1.0f, 1.0f, 0.0f, 0.2f }, // Y
513 };
514
515 int numMipLevels = ToolUtils::make_pixmaps(skColorType,
517 mipmapped == skgpu::Mipmapped::kYes,
518 kColors,
519 pixmaps,
520 &memForPixmaps);
521 SkASSERT(numMipLevels);
522
523 sk_sp<ManagedBackendTexture> mbet = create(dContext, pixmaps, numMipLevels, origin, renderable);
524 if (!mbet) {
525 // errors here should be reported by the test_wrapping test
526 return;
527 }
528
529 if (skColorType == kBGRA_8888_SkColorType && !isBGRA8(mbet->texture().getBackendFormat())) {
530 // When kBGRA is backed by an RGBA something goes wrong in the swizzling
531 return;
532 }
533
534 auto checkBackendTexture = [&](const SkColor4f colors[6]) {
535 GrColorType grColorType = SkColorTypeToGrColorType(skColorType);
536 if (mipmapped == skgpu::Mipmapped::kYes) {
537 SkColor4f expectedColors[6] = {
538 get_expected_color(colors[0], grColorType),
539 get_expected_color(colors[1], grColorType),
540 get_expected_color(colors[2], grColorType),
541 get_expected_color(colors[3], grColorType),
542 get_expected_color(colors[4], grColorType),
543 get_expected_color(colors[5], grColorType),
544 };
545
546 check_mipmaps(dContext, mbet->texture(), grColorType, expectedColors, reporter,
547 "pixmap");
548 }
549
550 // The last step in this test will dirty the mipmaps so do it last
551 check_base_readbacks(dContext, mbet->texture(), grColorType, renderable, colors[0],
552 reporter, "pixmap");
553 };
554
555 checkBackendTexture(kColors);
556
557 constexpr SkColor4f kColorsNew[6] = {
558 {1.0f, 1.0f, 0.0f, 0.2f}, // Y
559 {1.0f, 0.0f, 0.0f, 1.0f}, // R
560 {0.0f, 1.0f, 0.0f, 0.9f}, // G
561 {0.0f, 0.0f, 1.0f, 0.7f}, // B
562 {0.0f, 1.0f, 1.0f, 0.5f}, // C
563 {1.0f, 0.0f, 1.0f, 0.3f}, // M
564 };
565 ToolUtils::make_pixmaps(skColorType,
567 mipmapped == skgpu::Mipmapped::kYes,
568 kColorsNew,
569 pixmaps,
570 &memForPixmaps);
571
572 // Upload new data and make sure everything still works
573 dContext->updateBackendTexture(mbet->texture(),
574 pixmaps,
575 numMipLevels,
576 origin,
577 ManagedBackendTexture::ReleaseProc,
578 mbet->releaseContext());
579
580 checkBackendTexture(kColorsNew);
581}
582
583enum class VkLayout {
586};
587
588void check_vk_tiling(const GrBackendTexture& backendTex) {
589#if defined(SK_VULKAN) && defined(SK_DEBUG)
590 GrVkImageInfo vkII;
591 if (GrBackendTextures::GetVkImageInfo(backendTex, &vkII)) {
593 }
594#endif
595}
596
597///////////////////////////////////////////////////////////////////////////////
600 using namespace skgpu;
601
602 auto context = ctxInfo.directContext();
603 const GrCaps* caps = context->priv().caps();
604
605 Protected isProtected = Protected(caps->supportsProtectedContent());
606
607 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
608 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 0.75f };
609
610 struct {
612 SkColor4f fColor;
613 } combinations[] = {
614 { kAlpha_8_SkColorType, kTransCol },
618 { kSRGBA_8888_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f}},
620 // TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul)
621 { kBGRA_8888_SkColorType, { 1, 0, 0, 1.0f } },
622 // TODO: readback is busted for *10A2 when alpha = 0.5f (perhaps premul vs. unpremul)
623 { kRGBA_1010102_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }},
624 { kBGRA_1010102_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }},
625 // RGB/BGR 101010x have no Ganesh correlate
626 { kRGB_101010x_SkColorType, { 0, 0.5f, 0, 0.5f } },
627 { kBGR_101010x_SkColorType, { 0, 0.5f, 0, 0.5f } },
628 { kBGR_101010x_XR_SkColorType, { 0, 0.5f, 0, 0.5f } },
629 { kRGBA_10x6_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }},
630 { kBGRA_10101010_XR_SkColorType, { 0.25f, 0.5f, 0.75f, 1.0f }},
631 { kGray_8_SkColorType, kGrayCol },
635 { kR8G8_unorm_SkColorType, { .25f, .75f, 0, 1 } },
637 { kA16_unorm_SkColorType, kTransCol },
638 { kA16_float_SkColorType, kTransCol },
639 { kR16G16_float_SkColorType, { .25f, .75f, 0, 1 } },
640 { kR16G16B16A16_unorm_SkColorType,{ .25f, .5f, .75f, 1 } },
641 { kR8_unorm_SkColorType, { .25f, 0, 0, 1 } },
642 };
643
644 static_assert(kLastEnum_SkColorType == std::size(combinations));
645
646 for (auto combo : combinations) {
647 SkColorType colorType = combo.fColorType;
648
649 if (GrBackendApi::kMetal == context->backend()) {
650 // skbug.com/9086 (Metal caps may not be handling RGBA32 correctly)
651 if (kRGBA_F32_SkColorType == combo.fColorType) {
652 continue;
653 }
654 }
655
657 // Creating a texture with kBGR_101010x_XR_SkColorType is not
658 // implemented.
659 continue;
660 }
661
662 for (auto mipmapped : { Mipmapped::kNo, Mipmapped::kYes}) {
663 if (Mipmapped::kYes == mipmapped && !caps->mipmapSupport()) {
664 continue;
665 }
666
667 for (auto renderable : { GrRenderable::kNo, GrRenderable::kYes }) {
669 renderable).isValid()) {
670 continue;
671 }
672
673 if (GrRenderable::kYes == renderable) {
674 if (kRGB_888x_SkColorType == combo.fColorType) {
675 // Ganesh can't perform the blends correctly when rendering this format
676 continue;
677 }
678 }
679
680 {
681 auto uninitCreateMtd = [&](GrDirectContext* dContext,
682 Mipmapped mipmapped,
683 GrRenderable renderable) {
684 auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
685 32, 32,
686 colorType,
687 mipmapped,
688 renderable,
689 isProtected);
690 check_vk_tiling(mbet->texture());
691#ifdef SK_DEBUG
692 {
694 renderable);
695 SkASSERT(format == mbet->texture().getBackendFormat());
696 }
697#endif
698
699 return mbet;
700 };
701
702 test_wrapping(context, reporter, uninitCreateMtd,
703 SkColorTypeToGrColorType(colorType), mipmapped, renderable);
704 }
705
706 {
707 auto createWithColorMtd = [&](GrDirectContext* dContext,
708 const SkColor4f& color,
709 Mipmapped mipmapped,
710 GrRenderable renderable) {
711 auto mbet = ManagedBackendTexture::MakeWithData(dContext,
712 32, 32,
713 colorType,
714 color,
715 mipmapped,
716 renderable,
717 isProtected);
718 check_vk_tiling(mbet->texture());
719
720#ifdef SK_DEBUG
721 {
723 renderable);
724 SkASSERT(format == mbet->texture().getBackendFormat());
725 }
726#endif
727
728 return mbet;
729 };
730 test_color_init(context, reporter, createWithColorMtd,
731 SkColorTypeToGrColorType(colorType), combo.fColor, mipmapped,
732 renderable);
733 }
734
736 auto createWithSrcDataMtd = [&](GrDirectContext* dContext,
737 const SkPixmap srcData[],
738 int numLevels,
739 GrSurfaceOrigin origin,
740 GrRenderable renderable) {
741 SkASSERT(srcData && numLevels);
742 auto mbet = ManagedBackendTexture::MakeWithData(dContext,
743 srcData,
744 numLevels,
745 origin,
746 renderable,
747 isProtected);
748 check_vk_tiling(mbet->texture());
749#ifdef SK_DEBUG
750 {
751 auto format = dContext->defaultBackendFormat(srcData[0].colorType(),
752 renderable);
753 SkASSERT(format == mbet->texture().getBackendFormat());
754 }
755#endif
756 return mbet;
757 };
758
759 test_pixmap_init(context,
760 reporter,
761 createWithSrcDataMtd,
762 colorType,
763 origin,
764 mipmapped,
765 renderable);
766 }
767 }
768 }
769 }
770}
771
773 for (int t = 0; t < skgpu::kContextTypeCount; ++t) {
774 auto type = static_cast<skgpu::ContextType>(t);
776 continue;
777 }
780 if (!info.directContext()) {
781 continue;
782 }
784 // The GL backend must support contexts that don't allow GL_UNPACK_ROW_LENGTH. Other
785 // backends are not required to work with this cap disabled.
786 if (info.directContext()->priv().caps()->writePixelsRowBytesSupport() &&
787 info.directContext()->backend() == GrBackendApi::kOpenGL) {
788 GrContextOptions overrideOptions = options;
789 overrideOptions.fDisallowWriteAndTransferPixelRowBytes = true;
790 sk_gpu_test::GrContextFactory overrideFactory(overrideOptions);
791 info = overrideFactory.getContextInfo(type);
793 }
794 }
795}
796
797///////////////////////////////////////////////////////////////////////////////
798#ifdef SK_GL
799
800DEF_GANESH_TEST_FOR_GL_CONTEXT(GLBackendAllocationTest,
801 reporter,
802 ctxInfo,
804 sk_gpu_test::GLTestContext* glCtx = ctxInfo.glContext();
805 GrGLStandard standard = glCtx->gl()->fStandard;
806 auto context = ctxInfo.directContext();
807 const GrGLCaps* glCaps = static_cast<const GrGLCaps*>(context->priv().caps());
808
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 };
812
813 struct {
815 GrGLenum fFormat;
816 SkColor4f fColor;
817 } combinations[] = {
820
824
827 // TODO: readback is busted when alpha = 0.5f (perhaps premul vs. unpremul)
828 { GrColorType::kRGBA_1010102, GR_GL_RGB10_A2, { 0.25f, 0.5f, 0.75f, 1.f }},
829 { GrColorType::kBGRA_1010102, GR_GL_RGB10_A2, { 0.25f, 0.5f, 0.75f, 1.f }},
832
833 { GrColorType::kAlpha_8, GR_GL_ALPHA8, kTransCol },
834 { GrColorType::kAlpha_8, GR_GL_R8, kTransCol },
835
837 { GrColorType::kGray_8, GR_GL_R8, kGrayCol },
838
840
842
845
846 { GrColorType::kRG_88, GR_GL_RG8, { 1, 0.5f, 0, 1 } },
847 { GrColorType::kAlpha_F16, GR_GL_R16F, { 1.0f, 0, 0, 0.5f } },
849
850 { GrColorType::kAlpha_16, GR_GL_R16, kTransCol },
852
855 };
856
857 for (auto combo : combinations) {
862 if (!glCaps->isFormatTexturable(format, textureType)) {
863 continue;
864 }
865
866 if (GrColorType::kBGRA_8888 == combo.fColorType ||
867 GrColorType::kBGRA_1010102 == combo.fColorType) {
868 // We allow using a GL_RGBA8 or GR_GL_RGB10_A2 texture as BGRA on desktop GL but not
869 // ES
870 if (kGL_GrGLStandard != standard &&
871 (GR_GL_RGBA8 == combo.fFormat || GR_GL_RGB10_A2 == combo.fFormat)) {
872 continue;
873 }
874 }
875
876 for (auto mipmapped : {skgpu::Mipmapped::kNo, skgpu::Mipmapped::kYes}) {
877 if (skgpu::Mipmapped::kYes == mipmapped &&
878 (!glCaps->mipmapSupport() || target == GR_GL_TEXTURE_RECTANGLE)) {
879 continue;
880 }
881
882 for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
883 if (GrRenderable::kYes == renderable) {
884 if (!glCaps->isFormatAsColorTypeRenderable(combo.fColorType, format)) {
885 continue;
886 }
887 }
888
889 {
890 auto uninitCreateMtd = [format](GrDirectContext* dContext,
891 skgpu::Mipmapped mipmapped,
892 GrRenderable renderable) {
893 return ManagedBackendTexture::MakeWithoutData(dContext,
894 32, 32,
895 format,
896 mipmapped,
897 renderable,
899 };
900
901 test_wrapping(context, reporter, uninitCreateMtd, combo.fColorType,
902 mipmapped, renderable);
903 }
904
905 {
906 // We're creating backend textures without specifying a color type "view" of
907 // them at the public API level. Therefore, Ganesh will not apply any
908 // swizzles before writing the color to the texture. However, our validation
909 // code does rely on interpreting the texture contents via a SkColorType and
910 // therefore swizzles may be applied during the read step. Ideally we'd
911 // update our validation code to use a "raw" read that doesn't impose a
912 // color type but for now we just munge the data we upload to match the
913 // expectation.
914 skgpu::Swizzle swizzle;
915 switch (combo.fColorType) {
917 swizzle = skgpu::Swizzle("aaaa");
918 break;
920 swizzle = skgpu::Swizzle("aaaa");
921 break;
923 swizzle = skgpu::Swizzle("aaaa");
924 break;
925 default:
926 break;
927 }
928 auto createWithColorMtd = [format, swizzle](GrDirectContext* dContext,
929 const SkColor4f& color,
930 skgpu::Mipmapped mipmapped,
931 GrRenderable renderable) {
932 auto swizzledColor = swizzle.applyTo(color);
934 32, 32,
935 format,
936 swizzledColor,
937 mipmapped,
938 renderable,
940 };
941 test_color_init(context, reporter, createWithColorMtd, combo.fColorType,
942 combo.fColor, mipmapped, renderable);
943 }
944 }
945 }
946 }
947 }
948}
949
950#endif
951
952///////////////////////////////////////////////////////////////////////////////
953
954#ifdef SK_VULKAN
955
956DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(VkBackendAllocationTest,
957 reporter,
958 ctxInfo,
960 using namespace skgpu;
961
962 auto context = ctxInfo.directContext();
963 const GrVkCaps* vkCaps = static_cast<const GrVkCaps*>(context->priv().caps());
964
965 Protected isProtected = Protected(vkCaps->supportsProtectedContent());
966
967 constexpr SkColor4f kTransCol { 0, 0.25f, 0.75f, 0.5f };
968 constexpr SkColor4f kGrayCol { 0.75f, 0.75f, 0.75f, 1 };
969
970 struct {
972 VkFormat fFormat;
973 SkColor4f fColor;
974 } combinations[] = {
977
978 // In this configuration (i.e., an RGB_888x colortype with an RGBA8 backing format),
979 // there is nothing to tell Skia to make the provided color opaque. Clients will need
980 // to provide an opaque initialization color in this case.
983
985
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 }},
993
996
998 // In this config (i.e., a Gray8 color type with an R8 backing format), there is nothing
999 // to tell Skia this isn't an Alpha8 color type (so it will initialize the texture with
1000 // the alpha channel of the color). Clients should, in general, fill all the channels
1001 // of the provided color with the same value in such cases.
1003
1006
1007 { GrColorType::kRG_88, VK_FORMAT_R8G8_UNORM, { 1, 0.5f, 0, 1 } },
1008 { GrColorType::kAlpha_F16, VK_FORMAT_R16_SFLOAT, { 1.0f, 0, 0, 0.5f }},
1009
1014 };
1015
1016 for (auto combo : combinations) {
1017 if (!vkCaps->isVkFormatTexturable(combo.fFormat)) {
1018 continue;
1019 }
1020
1022
1023 for (auto mipmapped : { Mipmapped::kNo, Mipmapped::kYes }) {
1024 if (Mipmapped::kYes == mipmapped && !vkCaps->mipmapSupport()) {
1025 continue;
1026 }
1027
1028 for (auto renderable : { GrRenderable::kNo, GrRenderable::kYes }) {
1029
1030 if (GrRenderable::kYes == renderable) {
1031 // We must also check whether we allow rendering to the format using the
1032 // color type.
1033 if (!vkCaps->isFormatAsColorTypeRenderable(
1034 combo.fColorType, GrBackendFormats::MakeVk(combo.fFormat), 1)) {
1035 continue;
1036 }
1037 }
1038
1039 {
1040 auto uninitCreateMtd = [&](GrDirectContext* dContext,
1041 Mipmapped mipmapped,
1042 GrRenderable renderable) {
1043 auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
1044 32, 32,
1045 format,
1046 mipmapped,
1047 renderable,
1048 isProtected);
1049 check_vk_tiling(mbet->texture());
1050 return mbet;
1051 };
1052
1053 test_wrapping(context, reporter, uninitCreateMtd, combo.fColorType, mipmapped,
1054 renderable);
1055 }
1056
1057 {
1058 // We're creating backend textures without specifying a color type "view" of
1059 // them at the public API level. Therefore, Ganesh will not apply any swizzles
1060 // before writing the color to the texture. However, our validation code does
1061 // rely on interpreting the texture contents via a SkColorType and therefore
1062 // swizzles may be applied during the read step.
1063 // Ideally we'd update our validation code to use a "raw" read that doesn't
1064 // impose a color type but for now we just munge the data we upload to match the
1065 // expectation.
1066 Swizzle swizzle;
1067 switch (combo.fColorType) {
1069 SkASSERT(combo.fFormat == VK_FORMAT_R8_UNORM);
1070 swizzle = Swizzle("aaaa");
1071 break;
1073 SkASSERT(combo.fFormat == VK_FORMAT_R16_UNORM);
1074 swizzle = Swizzle("aaaa");
1075 break;
1077 SkASSERT(combo.fFormat == VK_FORMAT_R16_SFLOAT);
1078 swizzle = Swizzle("aaaa");
1079 break;
1081 if (combo.fFormat == VK_FORMAT_B4G4R4A4_UNORM_PACK16) {
1082 swizzle = Swizzle("bgra");
1083 }
1084 break;
1085 default:
1086 swizzle = Swizzle("rgba");
1087 break;
1088 }
1089
1090 auto createWithColorMtd = [&](GrDirectContext* dContext,
1091 const SkColor4f& color,
1092 Mipmapped mipmapped,
1093 GrRenderable renderable) {
1094 auto swizzledColor = swizzle.applyTo(color);
1095 auto mbet = ManagedBackendTexture::MakeWithData(dContext,
1096 32, 32,
1097 format,
1098 swizzledColor,
1099 mipmapped,
1100 renderable,
1101 isProtected);
1102 check_vk_tiling(mbet->texture());
1103 return mbet;
1104 };
1105 test_color_init(context, reporter, createWithColorMtd, combo.fColorType,
1106 combo.fColor, mipmapped, renderable);
1107 }
1108 }
1109 }
1110 }
1111}
1112
1113#endif
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)
@ kReadOnlyOptimal
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)
const char * options
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
reporter
Definition: FontMgrTest.cpp:39
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_RGB8
Definition: GrGLDefines.h:509
#define GR_GL_SRGB8_ALPHA8
Definition: GrGLDefines.h:526
#define GR_GL_RGB10_A2
Definition: GrGLDefines.h:525
#define GR_GL_R16
Definition: GrGLDefines.h:460
#define GR_GL_RGBA8
Definition: GrGLDefines.h:524
#define GR_GL_R8
Definition: GrGLDefines.h:459
#define GR_GL_R16F
Definition: GrGLDefines.h:494
#define GR_GL_TEXTURE_2D
Definition: GrGLDefines.h:152
#define GR_GL_LUMINANCE8
Definition: GrGLDefines.h:473
#define GR_GL_RG8
Definition: GrGLDefines.h:492
#define GR_GL_RGBA16
Definition: GrGLDefines.h:530
#define GR_GL_LUMINANCE8_ALPHA8
Definition: GrGLDefines.h:474
#define GR_GL_LUMINANCE16F
Definition: GrGLDefines.h:475
#define GR_GL_RGBA32F
Definition: GrGLDefines.h:528
#define GR_GL_RGBA4
Definition: GrGLDefines.h:522
#define GR_GL_TEXTURE_RECTANGLE
Definition: GrGLDefines.h:1056
#define GR_GL_RG16F
Definition: GrGLDefines.h:496
#define GR_GL_RGBA16F
Definition: GrGLDefines.h:527
#define GR_GL_BGRA8
Definition: GrGLDefines.h:541
#define GR_GL_RGBX8
Definition: GrGLDefines.h:511
#define GR_GL_RGB565
Definition: GrGLDefines.h:508
#define GR_GL_ALPHA8
Definition: GrGLDefines.h:478
#define GR_GL_RG16
Definition: GrGLDefines.h:493
GrGLStandard
Definition: GrGLTypes.h:19
@ kGLES_GrGLStandard
Definition: GrGLTypes.h:22
@ kGL_GrGLStandard
Definition: GrGLTypes.h:21
unsigned int GrGLenum
Definition: GrGLTypes.h:102
@ kRW_GrIOType
Definition: GrTypesPriv.h:405
@ kBorrow_GrWrapOwnership
Definition: GrTypesPriv.h:79
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
Definition: GrTypesPriv.h:589
GrTextureType
Definition: GrTypesPriv.h:268
GrColorType
Definition: GrTypesPriv.h:540
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
Definition: GrTypesPriv.h:629
GrSurfaceOrigin
Definition: GrTypes.h:147
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
skgpu::Protected Protected
SkColorType fColorType
kUnpremul_SkAlphaType
#define SkUNREACHABLE
Definition: SkAssert.h:135
#define SkASSERT(cond)
Definition: SkAssert.h:116
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
Definition: SkColorData.h:378
SkColorType
Definition: SkColorType.h:19
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
Definition: SkColorType.h:50
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
Definition: SkColorType.h:33
@ kR8_unorm_SkColorType
Definition: SkColorType.h:54
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
Definition: SkColorType.h:30
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
Definition: SkColorType.h:43
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
Definition: SkColorType.h:48
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition: SkColorType.h:29
@ kLastEnum_SkColorType
last valid value
Definition: SkColorType.h:56
@ kSRGBA_8888_SkColorType
Definition: SkColorType.h:53
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
Definition: SkColorType.h:32
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
Definition: SkColorType.h:25
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:28
@ kA16_float_SkColorType
pixel with a half float for alpha
Definition: SkColorType.h:45
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition: SkColorType.h:40
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:27
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition: SkColorType.h:31
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
Definition: SkColorType.h:49
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition: SkColorType.h:36
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
@ kR16G16_float_SkColorType
pixel with a half float for red and green
Definition: SkColorType.h:46
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.
SkTextureCompressionType
bool CheckSolidPixels(const SkColor4f &col, const SkPixmap &pixmap, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
Definition: TestUtils.cpp:191
#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(name, reporter, context_info, ctsEnforcement)
Definition: Test.h:458
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
#define DEF_GANESH_TEST_FOR_GL_CONTEXT(name, reporter, context_info, ctsEnforcement)
Definition: Test.h:442
#define ERRORF(r,...)
Definition: Test.h:293
GLenum type
bool isValid() const
GrBackendFormat getBackendFormat() const
const GrCaps * caps() const
Definition: GrCaps.h:57
bool mipmapSupport() const
Definition: GrCaps.h:72
bool supportsProtectedContent() const
Definition: GrCaps.h:422
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition: GrCaps.cpp:400
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
Definition: GrCaps.cpp:443
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
Definition: GrGLCaps.cpp:4909
bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const override
Definition: GrGLCaps.cpp:4897
GrGLStandard standard() const
Definition: GrGLContext.h:30
const GrGLContextInfo & ctxInfo() const
Definition: GrGLGpu.h:104
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
Definition: GrVkCaps.cpp:1566
bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const override
Definition: GrVkCaps.cpp:1571
bool tryAlloc(const SkImageInfo &)
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:296
bool erase(SkColor color, const SkIRect &subset) const
Definition: SkPixmap.cpp:742
const char * c_str() const
Definition: SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550
GrDirectContext * directContext() const
const GrGLInterface * gl() const
Definition: GLTestContext.h:30
ContextInfo getContextInfo(ContextType type, ContextOverrides=ContextOverrides::kNone)
T * get() const
Definition: SkRefCnt.h:303
constexpr std::array< float, 4 > applyTo(std::array< float, 4 > color) const
Definition: Swizzle.h:101
DlColor color
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
uint32_t uint32_t * format
uint32_t * target
Dart_NativeFunction function
Definition: fuchsia.cc:51
double y
double x
SK_API GrMTLPixelFormat AsMtlFormat(const GrBackendFormat &)
SK_API GrGLFormat AsGLFormat(const GrBackendFormat &)
SK_API bool AsVkFormat(const GrBackendFormat &, VkFormat *)
SK_API GrBackendFormat MakeVk(VkFormat format, bool willUseDRMFormatModifiers=false)
SK_API GrBackendFormat MakeGL(GrGLenum format, GrGLenum target)
SK_API bool GetVkImageInfo(const GrBackendTexture &, GrVkImageInfo *)
constexpr SkColor4f kLtGray
Definition: SkColor.h:438
constexpr SkColor4f kGreen
Definition: SkColor.h:441
constexpr SkColor4f kRed
Definition: SkColor.h:440
constexpr SkColor4f kCyan
Definition: SkColor.h:444
constexpr SkColor4f kTransparent
Definition: SkColor.h:434
constexpr SkColor4f kGray
Definition: SkColor.h:437
constexpr SkColor4f kBlue
Definition: SkColor.h:442
constexpr SkColor4f kYellow
Definition: SkColor.h:443
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
Definition: SkRecords.h:276
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)
int make_pixmaps(SkColorType ct, SkAlphaType at, bool withMips, const SkColor4f colors[6], SkPixmap pixmaps[6], std::unique_ptr< char[]> *mem)
Definition: ToolUtils.cpp:181
const char * colortype_name(SkColorType ct)
Definition: ToolUtils.cpp:65
Definition: create.py:1
const uint32_t fp
const DlColor kColors[]
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
Definition: switches.h:191
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
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
GrTextureProxy * GetTextureImageProxy(SkImage *image, GrRecordingContext *rContext)
Definition: ProxyUtils.cpp:32
Definition: GpuTools.h:21
static const int kContextTypeCount
Definition: ContextType.h:42
ContextType
Definition: ContextType.h:19
Renderable
Definition: GpuTypes.h:69
Mipmapped
Definition: GpuTypes.h:53
bool IsRenderingContext(skgpu::ContextType type)
Definition: ContextType.cpp:88
Protected
Definition: GpuTypes.h:61
GrGLStandard fStandard
Definition: GrGLInterface.h:81
VkImageTiling fImageTiling
Definition: GrVkTypes.h:28
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
int_closure create
@ VK_IMAGE_TILING_OPTIMAL
Definition: vulkan_core.h:1767
VkFormat
Definition: vulkan_core.h:1458
@ VK_FORMAT_R16G16B16A16_UNORM
Definition: vulkan_core.h:1550
@ VK_FORMAT_R8G8B8A8_SRGB
Definition: vulkan_core.h:1502
@ VK_FORMAT_R8G8B8_UNORM
Definition: vulkan_core.h:1482
@ VK_FORMAT_B8G8R8A8_UNORM
Definition: vulkan_core.h:1503
@ VK_FORMAT_R16G16_SFLOAT
Definition: vulkan_core.h:1542
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
Definition: vulkan_core.h:1462
@ VK_FORMAT_R16_SFLOAT
Definition: vulkan_core.h:1535
@ VK_FORMAT_R8G8_UNORM
Definition: vulkan_core.h:1475
@ VK_FORMAT_R8_UNORM
Definition: vulkan_core.h:1468
@ VK_FORMAT_R5G6B5_UNORM_PACK16
Definition: vulkan_core.h:1463
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
Definition: vulkan_core.h:1461
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
Definition: vulkan_core.h:1523
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496
@ VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16
Definition: vulkan_core.h:1653
@ VK_FORMAT_R16_UNORM
Definition: vulkan_core.h:1529
@ VK_FORMAT_R16G16B16A16_SFLOAT
Definition: vulkan_core.h:1556
@ VK_FORMAT_R16G16_UNORM
Definition: vulkan_core.h:1536
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32
Definition: vulkan_core.h:1517