Retract GrRenderTarget from GrTestTarget

Split out of: https://codereview.chromium.org/1988923002/ (Declassify GrClipMaskManager and Remove GrRenderTarget and GrDrawTarget from GrPipelineBuilder)

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=2004433002

Review-Url: https://codereview.chromium.org/2004433002
This commit is contained in:
robertphillips 2016-05-20 11:14:33 -07:00 committed by Commit bot
parent f2c96a2a6f
commit 87f15c8ff1
8 changed files with 46 additions and 61 deletions

View File

@ -8,7 +8,9 @@
#include "GLBench.h"
#if SK_SUPPORT_GPU
#include "GrGpu.h"
#include "GrTest.h"
#include "gl/GrGLContext.h"
#include <stdio.h>
const GrGLContext* GLBench::getGLContext(SkCanvas* canvas) {

View File

@ -12,6 +12,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrGpu.h"
#include "GrTest.h"
#include "SkBitmap.h"
#include "SkGradientShader.h"

View File

@ -12,7 +12,9 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrGpu.h"
#include "GrTest.h"
#include "gl/GrGLContext.h"
#include "SkBitmap.h"
#include "SkGradientShader.h"
#include "SkImage.h"

View File

@ -27,7 +27,6 @@ struct GrContextOptions;
class GrContextThreadSafeProxy;
class GrDrawingManager;
class GrDrawContext;
class GrDrawTarget;
class GrFragmentProcessor;
class GrGpu;
class GrIndexBuffer;
@ -354,8 +353,8 @@ public:
const GrResourceProvider* resourceProvider() const { return fResourceProvider; }
GrResourceCache* getResourceCache() { return fResourceCache; }
// Called by tests that draw directly to the context via GrDrawTarget
void getTestTarget(GrTestTarget*, GrRenderTarget* rt);
// Called by tests that draw directly to the context via GrDrawContext
void getTestTarget(GrTestTarget*, sk_sp<GrDrawContext>);
/** Reset GPU stats */
void resetGpuStats() const ;

View File

@ -296,6 +296,7 @@ private:
friend class GrStencilAndCoverTextContext; // for access to drawBatch
friend class GrDrawingManager; // for ctor
friend class GrDrawContextPriv;
friend class GrTestTarget; // for access to getDrawTarget
bool drawFilledDRRect(const GrClip& clip,
const GrPaint& paint,

View File

@ -232,13 +232,13 @@ static SkPath create_path_15() {
return path;
}
static void test_path(GrDrawTarget* dt, GrRenderTarget* rt, GrResourceProvider* rp,
const SkPath& path) {
static void test_path(GrDrawTarget* dt, GrDrawContext* drawContext,
GrResourceProvider* rp, const SkPath& path) {
GrTessellatingPathRenderer tess;
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget());
GrNoClip noClip;
GrStyle style(SkStrokeRec::kFill_InitStyle);
GrPathRenderer::DrawPathArgs args;
@ -255,35 +255,35 @@ static void test_path(GrDrawTarget* dt, GrRenderTarget* rt, GrResourceProvider*
}
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = 800;
desc.fHeight = 800;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
SkAutoTUnref<GrTexture> texture(
ctxInfo.grContext()->textureProvider()->createApproxTexture(desc));
sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBackingFit::kApprox,
800, 800,
kSkia8888_GrPixelConfig,
0,
kTopLeft_GrSurfaceOrigin));
if (!drawContext) {
return;
}
GrTestTarget tt;
GrRenderTarget* rt = texture->asRenderTarget();
ctxInfo.grContext()->getTestTarget(&tt, rt);
ctxInfo.grContext()->getTestTarget(&tt, drawContext);
GrDrawTarget* dt = tt.target();
GrResourceProvider* rp = tt.resourceProvider();
test_path(dt, rt, rp, create_path_0());
test_path(dt, rt, rp, create_path_1());
test_path(dt, rt, rp, create_path_2());
test_path(dt, rt, rp, create_path_3());
test_path(dt, rt, rp, create_path_4());
test_path(dt, rt, rp, create_path_5());
test_path(dt, rt, rp, create_path_6());
test_path(dt, rt, rp, create_path_7());
test_path(dt, rt, rp, create_path_8());
test_path(dt, rt, rp, create_path_9());
test_path(dt, rt, rp, create_path_10());
test_path(dt, rt, rp, create_path_11());
test_path(dt, rt, rp, create_path_12());
test_path(dt, rt, rp, create_path_13());
test_path(dt, rt, rp, create_path_14());
test_path(dt, rt, rp, create_path_15());
test_path(dt, drawContext.get(), rp, create_path_0());
test_path(dt, drawContext.get(), rp, create_path_1());
test_path(dt, drawContext.get(), rp, create_path_2());
test_path(dt, drawContext.get(), rp, create_path_3());
test_path(dt, drawContext.get(), rp, create_path_4());
test_path(dt, drawContext.get(), rp, create_path_5());
test_path(dt, drawContext.get(), rp, create_path_6());
test_path(dt, drawContext.get(), rp, create_path_7());
test_path(dt, drawContext.get(), rp, create_path_8());
test_path(dt, drawContext.get(), rp, create_path_9());
test_path(dt, drawContext.get(), rp, create_path_10());
test_path(dt, drawContext.get(), rp, create_path_11());
test_path(dt, drawContext.get(), rp, create_path_12());
test_path(dt, drawContext.get(), rp, create_path_13());
test_path(dt, drawContext.get(), rp, create_path_14());
test_path(dt, drawContext.get(), rp, create_path_15());
}
#endif

View File

@ -52,39 +52,21 @@ void SetupAlwaysEvictAtlas(GrContext* context) {
}
};
void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, GrRenderTarget* rt) {
void GrTestTarget::init(GrContext* ctx, sk_sp<GrDrawContext> drawContext) {
SkASSERT(!fContext);
fContext.reset(SkRef(ctx));
fDrawTarget.reset(SkRef(target));
fRenderTarget.reset(SkRef(rt));
fDrawContext = drawContext;
}
void GrContext::getTestTarget(GrTestTarget* tar, GrRenderTarget* rt) {
void GrContext::getTestTarget(GrTestTarget* tar, sk_sp<GrDrawContext> drawContext) {
this->flush();
SkASSERT(drawContext);
// We could create a proxy GrDrawTarget that passes through to fGpu until ~GrTextTarget() and
// then disconnects. This would help prevent test writers from mixing using the returned
// GrDrawTarget and regular drawing. We could also assert or fail in GrContext drawing methods
// until ~GrTestTarget().
if (!rt) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = 32;
desc.fHeight = 32;
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSampleCnt = 0;
SkAutoTUnref<GrTexture> texture(this->textureProvider()->createTexture(
desc, SkBudgeted::kNo, nullptr, 0));
if (nullptr == texture) {
return;
}
SkASSERT(nullptr != texture->asRenderTarget());
rt = texture->asRenderTarget();
}
SkAutoTUnref<GrDrawTarget> dt(fDrawingManager->newDrawTarget(rt));
tar->init(this, dt, rt);
tar->init(this, std::move(drawContext));
}
void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) {

View File

@ -9,8 +9,7 @@
#define GrTest_DEFINED
#include "GrContext.h"
#include "GrDrawTarget.h"
#include "gl/GrGLContext.h"
#include "GrDrawContext.h"
namespace GrTest {
/**
@ -28,15 +27,14 @@ class GrTestTarget {
public:
GrTestTarget() {};
void init(GrContext*, GrDrawTarget*, GrRenderTarget*);
void init(GrContext*, sk_sp<GrDrawContext>);
GrDrawTarget* target() { return fDrawTarget.get(); }
GrDrawTarget* target() { return fDrawContext->getDrawTarget(); }
GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); }
private:
SkAutoTUnref<GrContext> fContext;
SkAutoTUnref<GrDrawTarget> fDrawTarget;
SkAutoTUnref<GrRenderTarget> fRenderTarget;
sk_sp<GrDrawContext> fDrawContext;
};
#endif