57constexpr static SkPMColor4f kTransYellow = {.5f,.5f,.0f,.5f};
58constexpr static SkPMColor4f kTransCyan = {.0f,.5f,.5f,.5f};
80 memcpy(
builder.positions(), kVertices,
sizeof(kVertices));
81 auto vertices =
builder.detach();
90 constexpr static float kTolerance = 2.5f / 256;
91 for (
int i = 0;
i < 4; ++
i) {
106 auto pix =
static_cast<const float*
>(pixmap.
addr());
111 "Got [%0.3f, %0.3f, %0.3f, %0.3f]\n"
112 "Expected [%0.3f, %0.3f, %0.3f, %0.3f]",
127 auto dContext = ctxInfo.directContext();
141 sdc->clear(kTransYellow);
156 options->fSuppressAdvancedBlendEquations =
true;
157 options->fSuppressFramebufferFetch =
true;
166 auto dContext = ctxInfo.directContext();
197 auto dContext = ctxInfo.directContext();
229 auto dContext = ctxInfo.directContext();
265 SkISize surfaceDims = {100, 100};
267 auto context = ctxInfo.directContext();
269 auto sourceTexture = context->createBackendTexture(texDims.
width(),
284 auto texture1 = context->createBackendTexture(surfaceDims.
width(),
292 auto texture2 = context->createBackendTexture(surfaceDims.
width(),
321 surface->getCanvas()->drawImageRect(sourceImage,
343 surface->getCanvas()->drawImageRect(sourceImage,
366 bitmap.allocPixels(dstIInfo);
368 bool success = readImage->readPixels(context,
bitmap.pixmap(), dstRect.
fLeft, dstRect.
fTop);
373 auto pix =
static_cast<const uint32_t*
>(
bitmap.getAddr(0, 0));
374 for (
int x = 0;
x < 50; ++
x) {
375 for (
int y = 0;
y < 50; ++
y) {
376 uint32_t pixColor = pix[
x +
y * 50];
377 if (pixColor != 0xFFFF0000) {
388 context->deleteBackendTexture(sourceTexture);
389 context->deleteBackendTexture(texture1);
390 context->deleteBackendTexture(texture2);
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(DMSAA_dual_source_blend_disable, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
static void draw_paint_with_aa(skgpu::ganesh::SurfaceDrawContext *sdc, const SkPMColor4f &color, SkBlendMode blendMode)
static void check_sdc_color(skiatest::Reporter *reporter, skgpu::ganesh::SurfaceDrawContext *sdc, GrDirectContext *ctx, const SkPMColor4f &color)
static void require_dst_reads(GrContextOptions *options)
DEF_GANESH_TEST_FOR_CONTEXTS(DMSAA_preserve_contents, &skgpu::IsRenderingContext, reporter, ctxInfo, nullptr, CtsEnforcement::kApiLevel_T)
static bool fuzzy_equals(const float a[4], const SkPMColor4f &b)
static void draw_paint_with_dmsaa(skgpu::ganesh::SurfaceDrawContext *sdc, const SkPMColor4f &color, SkBlendMode blendMode)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static constexpr float kTolerance
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
SkPMColor4f SkBlendMode_Apply(SkBlendMode mode, const SkPMColor4f &src, const SkPMColor4f &dst)
@ kSrcOver
r = s + (1-sa)*d
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
constexpr SkPMColor4f SK_PMColor4fWHITE
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
@ kUnknown_SkPixelGeometry
static GrPixmap Allocate(const GrImageInfo &info)
static const GrXPFactory * FromBlendMode(SkBlendMode)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
static const SkMatrix & I()
bool readPixels(GrDirectContext *dContext, GrPixmap dst, SkIPoint srcPt)
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
void drawRect(const GrClip *, GrPaint &&paint, GrAA, const SkMatrix &viewMatrix, const SkRect &, const GrStyle *style=nullptr)
void drawVertices(const GrClip *, GrPaint &&paint, const SkMatrix &viewMatrix, sk_sp< SkVertices > vertices, GrPrimitiveType *overridePrimType=nullptr, bool skipColorXform=false)
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< 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)
bool IsRenderingContext(skgpu::ContextType type)
SkSamplingOptions(SkFilterMode::kLinear))
constexpr int32_t width() const
constexpr int32_t height() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkScalar fLeft
smaller x-axis bounds
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkScalar fTop
smaller y-axis bounds