Pull non-substantive changes out of explicit GPU resource allocation CL
Change-Id: Ib6a289553ecd15c722599b7dc0d347a7800801cb
Reviewed-on: https://skia-review.googlesource.com/46284
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/gm/blurrect.cpp b/gm/blurrect.cpp
index 1e24571..54f3c21 100644
--- a/gm/blurrect.cpp
+++ b/gm/blurrect.cpp
@@ -58,7 +58,7 @@
/*
* Spits out a dummy gradient to test blur with shader on paint
*/
-static sk_sp<SkShader> MakeRadial() {
+static sk_sp<SkShader> make_radial() {
SkPoint pts[2] = {
{ 0, 0 },
{ SkIntToScalar(100), SkIntToScalar(100) }
@@ -123,7 +123,7 @@
paint.setAlpha(fAlpha);
SkPaint paintWithRadial = paint;
- paintWithRadial.setShader(MakeRadial());
+ paintWithRadial.setShader(make_radial());
constexpr Proc procs[] = {
fill_rect, draw_donut, draw_donut_skewed
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 001c53d..f957566 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -253,8 +253,9 @@
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
grPaint.addColorFragmentProcessor(std::move(fp));
- renderTargetContext->priv().testingOnly_addDrawOp(GrRectOpFactory::MakeNonAAFill(
- std::move(grPaint), viewMatrix, renderRect, GrAAType::kNone));
+ std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
+ std::move(grPaint), viewMatrix, renderRect, GrAAType::kNone));
+ renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
}
}
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d05f197..ba26cc8 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -646,12 +646,6 @@
return false;
}
- if (!proxyToRead->instantiate(fContext->resourceProvider())) {
- return false;
- }
-
- GrSurface* surfaceToRead = proxyToRead->priv().peekSurface();
-
if (GrGpu::kRequireDraw_DrawPreference == drawPreference && !didTempDraw) {
return false;
}
@@ -660,6 +654,13 @@
this->flushSurfaceWrites(proxyToRead.get());
configToRead = tempDrawInfo.fReadConfig;
}
+
+ if (!proxyToRead->instantiate(fContext->resourceProvider())) {
+ return false;
+ }
+
+ GrSurface* surfaceToRead = proxyToRead->priv().peekSurface();
+
if (!fContext->fGpu->readPixels(surfaceToRead, proxyToRead->origin(),
left, top, width, height, configToRead, buffer, rowBytes)) {
return false;
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index 521beea..17b0f10 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -31,6 +31,7 @@
fTarget.setProxy(sk_ref_sp(surfaceProxy), kWrite_GrIOType);
fTarget.get()->setLastOpList(this);
+#ifndef MDB_ALLOC_RESOURCES
// MDB TODO: remove this! We are currently moving to having all the ops that target
// the RT as a dest (e.g., clear, etc.) rely on the opList's 'fTarget' pointer
// for the IO Ref. This works well but until they are all swapped over (and none
@@ -39,6 +40,7 @@
// re-use assumptions.
fTarget.get()->instantiate(resourceProvider);
fTarget.markPendingIO();
+#endif
}
GrOpList::~GrOpList() {
@@ -101,6 +103,10 @@
}
#ifdef SK_DEBUG
+bool GrOpList::isInstantiated() const {
+ return fTarget.get()->priv().isInstantiated();
+}
+
void GrOpList::dump() const {
SkDebugf("--------------------------------------------------------------\n");
SkDebugf("node: %d -> RT: %d\n", fUniqueID, fTarget.get() ? fTarget.get()->uniqueID().asUInt()
diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h
index ae6b9a1..ef21a24 100644
--- a/src/gpu/GrOpList.h
+++ b/src/gpu/GrOpList.h
@@ -98,6 +98,8 @@
void setStencilLoadOp(GrLoadOp loadOp) { fStencilLoadOp = loadOp; }
protected:
+ SkDEBUGCODE(bool isInstantiated() const;)
+
GrSurfaceProxyRef fTarget;
GrAuditTrail* fAuditTrail;
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 561eaef..4f1ad12 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -124,10 +124,12 @@
fColorXformFromSRGB = GrColorSpaceXform::Make(srgbColorSpace.get(), fColorSpace.get());
}
+#ifndef MDB_ALLOC_RESOURCES
// MDB TODO: to ensure all resources still get allocated in the correct order in the hybrid
// world we need to get the correct opList here so that it, in turn, can grab and hold
// its rendertarget.
this->getRTOpList();
+#endif
SkDEBUGCODE(this->validate();)
}
diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp
index 76abe18..e5d6dbf 100644
--- a/src/gpu/GrResourceAllocator.cpp
+++ b/src/gpu/GrResourceAllocator.cpp
@@ -134,3 +134,35 @@
fActiveIntvls.insertByIncreasingEnd(cur);
}
}
+
+#ifdef SK_DEBUG
+void GrResourceAllocator::dump() {
+ unsigned int min = fNumOps+1;
+ unsigned int max = 0;
+ for(const Interval* cur = fIntvlList.peekHead(); cur; cur = cur->fNext) {
+ SkDebugf("{ %d,%d }: [%d, %d]\n",
+ cur->fProxy->uniqueID().asUInt(), cur->fProxy->underlyingUniqueID().asUInt(),
+ cur->fStart, cur->fEnd);
+ if (min > cur->fStart) {
+ min = cur->fStart;
+ }
+ if (max < cur->fEnd) {
+ max = cur->fEnd;
+ }
+ }
+
+ for(const Interval* cur = fIntvlList.peekHead(); cur; cur = cur->fNext) {
+ SkDebugf("{ %3d,%3d }: ",
+ cur->fProxy->uniqueID().asUInt(), cur->fProxy->underlyingUniqueID().asUInt());
+ for (unsigned int i = min; i <= max; ++i) {
+ if (i >= cur->fStart && i <= cur->fEnd) {
+ SkDebugf("x");
+ } else {
+ SkDebugf(" ");
+ }
+ }
+ SkDebugf("\n");
+ }
+}
+#endif
+
diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h
index fcaa3d5..bd0c690 100644
--- a/src/gpu/GrResourceAllocator.h
+++ b/src/gpu/GrResourceAllocator.h
@@ -52,6 +52,7 @@
}
void assign();
+ SkDEBUGCODE(void dump();)
private:
class Interval;
@@ -92,7 +93,7 @@
static uint32_t Hash(const uint32_t& key) { return key; }
GrSurfaceProxy* fProxy;
- uint32_t fProxyID; // This is here b.c. DynamicHash requires a ref to the key
+ uint32_t fProxyID; // This is here b.c. DynamicHash requires a ref to the key
unsigned int fStart;
unsigned int fEnd;
Interval* fNext;
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 823444c..b88ed93 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -298,10 +298,6 @@
int lastRun = fRuns[run].fSubRunInfo.count() - 1;
for (int subRun = 0; subRun <= lastRun; subRun++) {
const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
- GrPaint grPaint;
- if (!paint.toGrPaint(info.maskFormat(), rtc, viewMatrix, &grPaint)) {
- continue;
- }
int glyphCount = info.glyphCount();
if (0 == glyphCount) {
continue;
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index e64f5e9..7aaf554 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -105,8 +105,7 @@
}
}
-// Will call proc with multiple styles of canse (recording, raster, pdf)
-//
+// Will call proc with multiple styles of canvas (recording, raster, pdf)
template <typename F> static void multi_canvas_driver(int w, int h, F proc) {
proc(SkPictureRecorder().beginRecording(SkRect::MakeIWH(w, h)));
@@ -116,7 +115,6 @@
proc(SkSurface::MakeRasterN32Premul(w, h, nullptr)->getCanvas());
}
-
const SkIRect gBaseRestrictedR = { 0, 0, 10, 10 };
static void test_restriction(skiatest::Reporter* reporter, SkCanvas* canvas) {
diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp
index 399f431..fa99a9a 100644
--- a/tests/GpuSampleLocationsTest.cpp
+++ b/tests/GpuSampleLocationsTest.cpp
@@ -117,11 +117,11 @@
for (int i = 0; i < numTestPatterns; ++i) {
int numSamples = (int)kTestPatterns[i].size();
GrAlwaysAssert(numSamples > 1 && SkIsPow2(numSamples));
- bottomUps[i] = ctx->makeDeferredRenderTargetContextWithFallback(
+ bottomUps[i] = ctx->makeDeferredRenderTargetContext(
SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig, nullptr,
rand.nextRangeU(1 + numSamples / 2, numSamples),
kBottomLeft_GrSurfaceOrigin);
- topDowns[i] = ctx->makeDeferredRenderTargetContextWithFallback(
+ topDowns[i] = ctx->makeDeferredRenderTargetContext(
SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig, nullptr,
rand.nextRangeU(1 + numSamples / 2, numSamples),
kTopLeft_GrSurfaceOrigin);