aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gpu')
-rw-r--r--tools/gpu/GrTest.cpp28
-rw-r--r--tools/gpu/GrTest.h10
2 files changed, 9 insertions, 29 deletions
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index fc2a9e1a20..be539cabbd 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -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) {
diff --git a/tools/gpu/GrTest.h b/tools/gpu/GrTest.h
index 53aaac34e4..217efe6b7d 100644
--- a/tools/gpu/GrTest.h
+++ b/tools/gpu/GrTest.h
@@ -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