aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/gmmain.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-19 17:22:05 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-19 17:22:05 +0000
commit971d0c8049c6bfc7a58f0b41f8f59f9ec9ca077b (patch)
tree1ad234571b6f62cd6d0a0483807c845e965b7814 /gm/gmmain.cpp
parent3008519e9f977cd60194841d558a4f45c28e9833 (diff)
Get rid of createRenderTargetFrom3DAPIState and associated glGets necessary to support it.
Review URL: http://codereview.appspot.com/4928041/ git-svn-id: http://skia.googlecode.com/svn/trunk@2144 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/gmmain.cpp')
-rw-r--r--gm/gmmain.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 5252e802ca..6f7f67be00 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -6,8 +6,16 @@
* found in the LICENSE file.
*/
#include "gm.h"
+
+#include "GrContext.h"
+#include "GrRenderTarget.h"
+
#include "SkColorPriv.h"
#include "SkData.h"
+#include "SkDevice.h"
+#include "SkEGLContext.h"
+#include "SkGpuCanvas.h"
+#include "SkGpuDevice.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
#include "SkImageEncoder.h"
@@ -15,12 +23,6 @@
#include "SkStream.h"
#include "SkRefCnt.h"
-#include "GrContext.h"
-#include "SkGpuCanvas.h"
-#include "SkGpuDevice.h"
-#include "SkEGLContext.h"
-#include "SkDevice.h"
-
#ifdef SK_SUPPORT_PDF
#include "SkPDFDevice.h"
#include "SkPDFDocument.h"
@@ -228,6 +230,7 @@ static void setup_bitmap(const ConfigData& gRec, SkISize& size,
// halt.
static bool generate_image(GM* gm, const ConfigData& gRec,
GrContext* context,
+ GrRenderTarget* rt,
SkBitmap* bitmap) {
SkISize size (gm->getISize());
setup_bitmap(gRec, size, bitmap);
@@ -239,8 +242,6 @@ static bool generate_image(GM* gm, const ConfigData& gRec,
if (NULL == context) {
return false;
}
- // not a real object, so don't unref it
- GrRenderTarget* rt = SkGpuDevice::Current3DApiRenderTarget();
SkGpuCanvas gc(context, rt);
gc.setDevice(new SkGpuDevice(context, rt))->unref();
gm->draw(&gc);
@@ -406,14 +407,15 @@ static bool test_drawing(GM* gm,
const char readPath [],
const char diffPath [],
GrContext* context,
+ GrRenderTarget* rt,
SkBitmap* bitmap) {
SkDynamicMemoryWStream pdf;
if (gRec.fBackend == kRaster_Backend ||
- gRec.fBackend == kGPU_Backend) {
+ gRec.fBackend == kGPU_Backend) {
// Early exit if we can't generate the image, but this is
// expected in some cases, so don't report a test failure.
- if (!generate_image(gm, gRec, context, bitmap)) {
+ if (!generate_image(gm, gRec, context, rt, bitmap)) {
return true;
}
} else if (gRec.fBackend == kPDF_Backend) {
@@ -555,11 +557,26 @@ int main(int argc, char * const argv[]) {
}
// setup a GL context for drawing offscreen
SkEGLContext eglContext;
+ GrRenderTarget* rt = NULL;
if (eglContext.init(maxW, maxH)) {
gGrContext = GrContext::CreateGLShaderContext();
+ if (NULL != gGrContext) {
+ GrPlatformSurfaceDesc desc;
+ desc.reset();
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
+ desc.fWidth = maxW;
+ desc.fHeight = maxH;
+ desc.fStencilBits = 8;
+ desc.fPlatformRenderTarget = eglContext.getFBOID();
+ desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
+ rt = static_cast<GrRenderTarget*>(gGrContext->createPlatformSurface(desc));
+ if (NULL == rt) {
+ gGrContext->unref();
+ gGrContext = NULL;
+ }
+ }
}
-
if (readPath) {
fprintf(stderr, "reading from %s\n", readPath);
} else if (writePath) {
@@ -585,7 +602,7 @@ int main(int argc, char * const argv[]) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
bool testSuccess = test_drawing(gm, gRec[i],
writePath, readPath, diffPath, gGrContext,
- &forwardRenderedBitmap);
+ rt, &forwardRenderedBitmap);
overallSuccess &= testSuccess;
if (doReplay && testSuccess) {