264 {
265 SkISize surfaceDims = {100, 100};
267 auto context = ctxInfo.directContext();
268
269 auto sourceTexture = context->createBackendTexture(texDims.
width(),
276
278 sourceTexture,
282 nullptr);
283
284 auto texture1 = context->createBackendTexture(surfaceDims.
width(),
291
292 auto texture2 = context->createBackendTexture(surfaceDims.
width(),
299
302
306
307
308
309
310
311
312 {
314 texture1,
316 1,
318 nullptr,
319 &kDMSAAProps);
320
321 surface->getCanvas()->drawImageRect(sourceImage,
322 srcRect,
323 dstRect,
327
329 }
330
331
332
333
334 {
336 texture2,
338 1,
340 nullptr,
341 &kBasicProps);
342
343 surface->getCanvas()->drawImageRect(sourceImage,
344 srcRect,
345 dstRect,
350 }
351
352 {
354 texture2,
358 nullptr);
363 nullptr);
364
366 bitmap.allocPixels(dstIInfo);
367
368 bool success = readImage->readPixels(context,
bitmap.pixmap(), dstRect.
fLeft, dstRect.
fTop);
369 if (!success) {
371 return;
372 }
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) {
380 continue;
381 }
382 }
383 }
384 }
385 sourceImage.reset();
386
388 context->deleteBackendTexture(sourceTexture);
389 context->deleteBackendTexture(texture1);
390 context->deleteBackendTexture(texture2);
391}
@ kTopLeft_GrSurfaceOrigin
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
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)
SkSamplingOptions(SkFilterMode::kLinear))
constexpr int32_t width() const
constexpr int32_t height() const
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