43 {
44 auto dContext = ctxInfo.directContext();
45
46 static const int kW = 10;
47 static const int kH = 10;
48 static const size_t kRowBytes =
sizeof(uint32_t) *
kW;
49
51 for (
int i = 0;
i <
kW *
kH; ++
i) {
52 srcPixels.get()[
i] =
i;
53 }
54
56 for (
int i = 0;
i <
kW *
kH; ++
i) {
57 dstPixels.get()[
i] = ~i;
58 }
59
60 static const SkIRect kSrcRects[] {
64 { 5, 5, 6 , 6 },
65 };
66
68 { 0 , 0 },
69 { 1 , 1 },
74 {-1 , -1 },
75 };
76
80 };
81
83
88 for (
const SkIRect& srcRect : kSrcRects) {
89 for (
const SkIPoint& dstPoint : kDstPoints) {
91 GrCPixmap srcPM(ii, srcPixels.get(), kRowBytes);
92 GrPixmap dstPM(ii, dstPixels.get(), kRowBytes);
94 dContext, sRenderable, sOrigin, srcPM);
96 dContext, dRenderable, dOrigin, dstPM);
97
98
99
101 if (!srcView || !dstView) {
103 "Could not create surfaces for copy surface test.");
104 continue;
105 }
106 } else {
107 if (!dContext->defaultBackendFormat(
109 continue;
110 }
111 if (!srcView || !dstView) {
113 "Could not create surfaces for copy surface test.");
114 continue;
115 }
116 }
117
118 auto dstContext = dContext->priv().makeSC(std::move(dstView),
119 ii.colorInfo());
120
122 if (sOrigin == dOrigin) {
123 result = dstContext->testCopy(srcView.refProxy(),
124 srcRect,
125 dstPoint);
127 SkASSERT(dstContext->asFillContext());
128 result = dstContext->asFillContext()->blitTexture(
129 std::move(srcView), srcRect, dstPoint);
130 }
131
132 bool expectedResult = true;
133 SkIPoint dstOffset = { dstPoint.
fX - srcRect.fLeft,
134 dstPoint.fY - srcRect.fTop };
136 dstPoint.fY,
137 srcRect.width(),
138 srcRect.height());
139
142 expectedResult = false;
143 } else {
144
145
146 copiedDstRect.
fLeft += copiedSrcRect.
fLeft - srcRect.fLeft;
147 copiedDstRect.
fTop += copiedSrcRect.
fTop - srcRect.fTop;
148 copiedDstRect.
fRight -= copiedSrcRect.
fRight - srcRect.fRight;
150 srcRect.fBottom;
151 }
154 expectedResult = false;
155 }
157 expectedResult = false;
158 }
159
160
161
162
163 if (expectedResult !=
result) {
165 "got %d.", expectedResult,
result);
166 continue;
167 }
168
169 if (!expectedResult || !
result) {
170 continue;
171 }
172
175 if (!dstContext->readPixels(dContext, readPM, {0, 0})) {
177 continue;
178 }
179
180 bool abort = false;
181
182
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);
194 abort = true;
195 break;
196 }
197 } else {
198 uint32_t
d = dstPixels.get()[
y *
kW +
x];
201 "unmodified (0x%08x). Got 0x%08x",
203 abort = true;
204 break;
205 }
206 }
207 }
208 }
209 }
210 }
211 }
212 }
213 }
214 }
215 }
216}
@ 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)