52#include <initializer_list>
77 if (!
surface->readPixels(actual, 0, 0)) {
84 tmp.
clear(expectedColor);
87 const float tols[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
89 auto error = std::function<ComparePixmapsErrorReporter>(
90 [
reporter](
int x,
int y,
const float diffs[4]) {
93 x,
y, diffs[0], diffs[1], diffs[2], diffs[3]);
103 auto dContext = ctxInfo.directContext();
107 auto managedTex = ManagedBackendTexture::MakeFromInfo(
112 auto tex = managedTex->texture();
127 const GrCaps* caps = dContext->priv().caps();
137 dContext->flush(
surface.get());
154 dContext->flush(
surface.get());
188 dContext->flush(
surface.get());
220 auto dc = ctxInfo.directContext();
222 if (!dc->priv().caps()->mipmapSupport()) {
226 for (
int sampleCount : {1, 4}) {
230 if (sampleCount > 1) {
231 if (dc->priv().caps()->msaaResolvesAutomatically()) {
235 sampleCount = dc->priv().caps()->getRenderTargetSampleCount(sampleCount, bef);
242 auto mmProxy = dc->priv().proxyProvider()->createProxy(bef,
255 if (sampleCount > 1) {
268 auto src = dc->priv().proxyProvider()->createProxy(bef,
302 paint.setColorFragmentProcessor(std::move(te));
304 drawDst->drawRect(
nullptr,
309 if (sampleCount > 1) {
311 drawDst->getOpsTask()->resolveTask();
316 if (resolveTask->flagsForProxy(mmProxy) != ResolveFlags::kMSAA) {
334 paint.setColorFragmentProcessor(std::move(te));
336 drawDst->drawRect(
nullptr,
344 ERRORF(
reporter,
"No resolve task after drawing mip mapped proxy");
349 const char* expectedStr =
"kMipMaps";
350 if (sampleCount > 1) {
352 expectedStr =
"kMipMaps|kMSAA";
354 if (resolveTask->flagsForProxy(mmProxy) != expectedFlags) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
bool check_pixels(skiatest::Reporter *reporter, GrDirectContext *dContext, const GrBackendTexture &tex, const SkImageInfo &info, SkColor expectedColor)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(SurfaceResolveTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
constexpr SkPMColor4f SK_PMColor4fWHITE
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
bool ComparePixels(const GrCPixmap &a, const GrCPixmap &b, const float tolRGBA[4], std::function< ComparePixmapsErrorReporter > &error)
#define REPORTER_ASSERT(r, cond,...)
bool preferDiscardableMSAAAttachment() const
bool msaaResolvesAutomatically() const
static std::unique_ptr< GrFragmentProcessor > MakeColor(SkPMColor4f color)
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
void allocPixels(const SkImageInfo &info, size_t rowBytes)
const SkPixmap & pixmap() const
void clear(SkColor color)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static const SkMatrix & I()
static constexpr Swizzle RGBA()
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
const uint8_t uint32_t uint32_t GError ** error
SK_API void ResolveMSAA(SkSurface *surface)
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)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)