32#include <initializer_list>
44 auto dContext = ctxInfo.directContext();
46 static const int kW = 10;
47 static const int kH = 10;
48 static const size_t kRowBytes =
sizeof(uint32_t) *
kW;
51 for (
int i = 0;
i <
kW *
kH; ++
i) {
52 srcPixels.
get()[
i] =
i;
56 for (
int i = 0;
i <
kW *
kH; ++
i) {
57 dstPixels.
get()[
i] = ~i;
60 static const SkIRect kSrcRects[] {
88 for (
const SkIRect& srcRect : kSrcRects) {
89 for (
const SkIPoint& dstPoint : kDstPoints) {
94 dContext, sRenderable, sOrigin, srcPM);
96 dContext, dRenderable, dOrigin, dstPM);
101 if (!srcView || !dstView) {
103 "Could not create surfaces for copy surface test.");
107 if (!dContext->defaultBackendFormat(
111 if (!srcView || !dstView) {
113 "Could not create surfaces for copy surface test.");
118 auto dstContext = dContext->priv().makeSC(std::move(dstView),
122 if (sOrigin == dOrigin) {
123 result = dstContext->testCopy(srcView.refProxy(),
127 SkASSERT(dstContext->asFillContext());
128 result = dstContext->asFillContext()->blitTexture(
129 std::move(srcView), srcRect, dstPoint);
132 bool expectedResult =
true;
133 SkIPoint dstOffset = { dstPoint.
fX - srcRect.fLeft,
134 dstPoint.fY - srcRect.fTop };
142 expectedResult =
false;
146 copiedDstRect.
fLeft += copiedSrcRect.
fLeft - srcRect.fLeft;
147 copiedDstRect.
fTop += copiedSrcRect.
fTop - srcRect.fTop;
148 copiedDstRect.
fRight -= copiedSrcRect.
fRight - srcRect.fRight;
154 expectedResult =
false;
157 expectedResult =
false;
163 if (expectedResult !=
result) {
165 "got %d.", expectedResult,
result);
169 if (!expectedResult || !
result) {
175 if (!dstContext->readPixels(dContext, readPM, {0, 0})) {
183 for (
int y = 0;
y <
kH && !abort; ++
y) {
184 for (
int x = 0;
x <
kW; ++
x) {
185 uint32_t r =
read.get()[
y *
kW +
x];
187 int sx =
x - dstOffset.
fX;
188 int sy =
y - dstOffset.
fY;
189 uint32_t
s = srcPixels.
get()[sy *
kW + sx];
192 "0x%08x copied from src location %d,%d. Got "
193 "0x%08x",
x,
y,
s, sx, sy, r);
198 uint32_t
d = dstPixels.
get()[
y *
kW +
x];
201 "unmodified (0x%08x). Got 0x%08x",
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static bool read(SkStream *stream, void *buffer, size_t amount)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
void(* memset32)(uint32_t[], uint32_t, int)
GrSurfaceProxyView MakeTextureProxyViewFromData(GrDirectContext *dContext, GrRenderable renderable, GrSurfaceOrigin origin, GrCPixmap pixmap)
bool intersect(const SkIRect &r)
int32_t fBottom
larger y-axis bounds
int32_t fTop
smaller y-axis bounds
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
bool contains(int32_t x, int32_t y) const
int32_t fRight
larger x-axis bounds
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)