Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1013ecf

Browse files
egdanielSkia Commit-Bot
authored andcommitted
Revert "Remove call to copy in GrcontextPriv read/write pixel calls."
This reverts commit d0d66fb. Reason for revert: crashing on readpixels on some android bots Original change's description: > Remove call to copy in GrcontextPriv read/write pixel calls. > > Instead we just directly do all those copies as draws. > > Change-Id: I0cd9dfc6f96e35fbbc9c153a28a08eebf1d7b77f > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/216356 > Commit-Queue: Greg Daniel <[email protected]> > Reviewed-by: Brian Salomon <[email protected]> > Reviewed-by: Robert Phillips <[email protected]> [email protected],[email protected],[email protected] Change-Id: I2b39564e0b20cf83e21744c91ee8ddb9d988ab22 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/216608 Reviewed-by: Greg Daniel <[email protected]> Commit-Queue: Greg Daniel <[email protected]>
1 parent 8a3c059 commit 1013ecf

File tree

4 files changed

+48
-44
lines changed

4 files changed

+48
-44
lines changed

src/gpu/GrContextPriv.cpp

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -327,50 +327,63 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top,
327327

328328
if (!fContext->priv().caps()->surfaceSupportsReadPixels(srcSurface) ||
329329
canvas2DFastPath) {
330+
GrSurfaceDesc desc;
331+
desc.fWidth = width;
332+
desc.fHeight = height;
333+
desc.fSampleCnt = 1;
334+
330335
GrBackendFormat format;
331-
GrPixelConfig config;
332336
if (canvas2DFastPath) {
333-
config = kRGBA_8888_GrPixelConfig;
337+
desc.fFlags = kRenderTarget_GrSurfaceFlag;
338+
desc.fConfig = kRGBA_8888_GrPixelConfig;
334339
format = this->caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
335340
} else {
336-
config = srcProxy->config();
341+
desc.fFlags = kNone_GrSurfaceFlags;
342+
desc.fConfig = srcProxy->config();
337343
format = srcProxy->backendFormat().makeTexture2D();
338344
if (!format.isValid()) {
339345
return false;
340346
}
341347
}
342-
sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr : src->colorSpaceInfo().refColorSpace();
343348

344-
sk_sp<GrRenderTargetContext> tempCtx = this->makeDeferredRenderTargetContext(
345-
format, SkBackingFit::kApprox, width, height, config, std::move(cs), 1,
346-
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes);
349+
auto tempProxy = this->proxyProvider()->createProxy(
350+
format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
351+
if (!tempProxy) {
352+
return false;
353+
}
354+
sk_sp<GrSurfaceContext> tempCtx;
355+
if (canvas2DFastPath) {
356+
tempCtx = this->drawingManager()->makeRenderTargetContext(std::move(tempProxy), nullptr,
357+
nullptr);
358+
SkASSERT(tempCtx->asRenderTargetContext());
359+
tempCtx->asRenderTargetContext()->discard();
360+
} else {
361+
tempCtx = this->drawingManager()->makeTextureContext(
362+
std::move(tempProxy), src->colorSpaceInfo().refColorSpace());
363+
}
347364
if (!tempCtx) {
348365
return false;
349366
}
350-
351-
std::unique_ptr<GrFragmentProcessor> fp;
352367
if (canvas2DFastPath) {
353-
fp = fContext->createPMToUPMEffect(
368+
GrPaint paint;
369+
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
370+
auto fp = fContext->createPMToUPMEffect(
354371
GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
355372
SkMatrix::I()));
356373
if (dstColorType == GrColorType::kBGRA_8888) {
357374
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
358375
dstColorType = GrColorType::kRGBA_8888;
359376
}
360-
} else {
361-
fp = GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()), SkMatrix::I());
362-
}
363-
if (!fp) {
377+
if (!fp) {
378+
return false;
379+
}
380+
paint.addColorFragmentProcessor(std::move(fp));
381+
tempCtx->asRenderTargetContext()->fillRectToRect(
382+
GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(),
383+
SkRect::MakeWH(width, height), SkRect::MakeXYWH(left, top, width, height));
384+
} else if (!tempCtx->copy(srcProxy, SkIRect::MakeXYWH(left, top, width, height), {0, 0})) {
364385
return false;
365386
}
366-
GrPaint paint;
367-
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
368-
paint.addColorFragmentProcessor(std::move(fp));
369-
370-
tempCtx->asRenderTargetContext()->fillRectToRect(
371-
GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(),
372-
SkRect::MakeWH(width, height), SkRect::MakeXYWH(left, top, width, height));
373-
374387
uint32_t flags = canvas2DFastPath ? 0 : pixelOpsFlags;
375388
return this->readSurfacePixels(tempCtx.get(), 0, 0, width, height, dstColorType,
376389
dstColorSpace, buffer, rowBytes, flags);
@@ -532,26 +545,26 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top,
532545
srcColorSpace, buffer, rowBytes, flags)) {
533546
return false;
534547
}
535-
536-
std::unique_ptr<GrFragmentProcessor> fp;
537548
if (canvas2DFastPath) {
538-
fp = fContext->createUPMToPMEffect(
549+
GrPaint paint;
550+
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
551+
auto fp = fContext->createUPMToPMEffect(
539552
GrSimpleTextureEffect::Make(std::move(tempProxy), SkMatrix::I()));
540553
if (srcColorType == GrColorType::kBGRA_8888) {
541554
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
542555
}
556+
if (!fp) {
557+
return false;
558+
}
559+
paint.addColorFragmentProcessor(std::move(fp));
560+
dst->asRenderTargetContext()->fillRectToRect(
561+
GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(),
562+
SkRect::MakeXYWH(left, top, width, height), SkRect::MakeWH(width, height));
543563
} else {
544-
fp = GrSimpleTextureEffect::Make(std::move(tempProxy), SkMatrix::I());
545-
}
546-
if (!fp) {
547-
return false;
564+
if (!dst->copy(tempProxy.get(), SkIRect::MakeWH(width, height), {left, top})) {
565+
return false;
566+
}
548567
}
549-
GrPaint paint;
550-
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
551-
paint.addColorFragmentProcessor(std::move(fp));
552-
dst->asRenderTargetContext()->fillRectToRect(
553-
GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(),
554-
SkRect::MakeXYWH(left, top, width, height), SkRect::MakeWH(width, height));
555568

556569
return true;
557570
}

src/gpu/GrSurfaceContext.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ bool GrSurfaceContext::writePixels(const SkImageInfo& srcInfo, const void* srcBu
9494
return false;
9595
}
9696

97-
if (this->asSurfaceProxy()->readOnly()) {
98-
return false;
99-
}
100-
10197
return direct->priv().writeSurfacePixels(this, x, y, srcInfo.width(), srcInfo.height(),
10298
colorType, srcInfo.colorSpace(), srcBuffer,
10399
srcRowBytes, flags);

tests/GrSurfaceTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
329329

330330
// Mip regen should not work with a read only texture.
331331
if (context->priv().caps()->mipMapSupport()) {
332-
delete_backend_texture(context, backendTex);
333332
backendTex = context->createBackendTexture(
334333
kSize, kSize, kRGBA_8888_SkColorType, GrMipMapped::kYes, GrRenderable::kYes);
335334
proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
@@ -341,7 +340,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
341340
context->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
342341
REPORTER_ASSERT(reporter, regenResult == (ioType == kRW_GrIOType));
343342
}
344-
delete_backend_texture(context, backendTex);
345343
}
346344
}
347345

tests/TestUtils.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ bool create_backend_texture(GrContext* context, GrBackendTexture* backendTex,
156156
}
157157

158158
void delete_backend_texture(GrContext* context, const GrBackendTexture& backendTex) {
159-
GrFlushInfo flushInfo;
160-
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
161-
context->flush(flushInfo);
162159
context->deleteBackendTexture(backendTex);
163160
}
164161

0 commit comments

Comments
 (0)