aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skiaserve
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2016-03-11 11:45:53 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-11 11:45:53 -0800
commit4083610290308faae347ed94cf7aff9895af6289 (patch)
tree2cbc0bfb1b3a69ecc022e38937ea571c67c20ecf /tools/skiaserve
parent9c3f14327a38e79ab7d0cf30dfd9bf89676fde06 (diff)
Fix up no gpu build
Diffstat (limited to 'tools/skiaserve')
-rw-r--r--tools/skiaserve/Request.cpp22
-rw-r--r--tools/skiaserve/Request.h8
2 files changed, 27 insertions, 3 deletions
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index a058075410..f9ad867028 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -56,8 +56,20 @@ Request::Request(SkString rootUrl)
, fUrlDataManager(rootUrl)
, fGPUEnabled(false) {
// create surface
+#if SK_SUPPORT_GPU
GrContextOptions grContextOpts;
- fContextFactory.reset(new GrContextFactory(grContextOpts));
+ fContextFactory = new GrContextFactory(grContextOpts);
+#else
+ fContextFactory = nullptr;
+#endif
+}
+
+Request::~Request() {
+#if SK_SUPPORT_GPU
+ if (fContextFactory) {
+ delete fContextFactory;
+ }
+#endif
}
SkBitmap* Request::getBitmapFromCanvas(SkCanvas* canvas) {
@@ -85,10 +97,12 @@ SkData* Request::writeCanvasToPng(SkCanvas* canvas) {
}
SkCanvas* Request::getCanvas() {
+#if SK_SUPPORT_GPU
GrContextFactory* factory = fContextFactory;
SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions).fGLContext;
gl->makeCurrent();
+#endif
SkASSERT(fDebugCanvas);
// create the appropriate surface if necessary
@@ -128,8 +142,12 @@ SkData* Request::writeOutSkp() {
}
GrContext* Request::getContext() {
+#if SK_SUPPORT_GPU
return fContextFactory->get(GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions);
+#else
+ return nullptr;
+#endif
}
SkIRect Request::getBounds() {
@@ -137,9 +155,11 @@ SkIRect Request::getBounds() {
if (fPicture) {
bounds = fPicture->cullRect().roundOut();
if (fGPUEnabled) {
+#if SK_SUPPORT_GPU
int maxRTSize = this->getContext()->caps()->maxRenderTargetSize();
bounds = SkIRect::MakeWH(SkTMin(bounds.width(), maxRTSize),
SkTMin(bounds.height(), maxRTSize));
+#endif
}
} else {
bounds = SkIRect::MakeWH(kDefaultWidth, kDefaultHeight);
diff --git a/tools/skiaserve/Request.h b/tools/skiaserve/Request.h
index 95e7f1568c..52ebf25c2f 100644
--- a/tools/skiaserve/Request.h
+++ b/tools/skiaserve/Request.h
@@ -8,7 +8,9 @@
#ifndef Request_DEFINED
#define Request_DEFINED
+#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
+#endif
#include "SkDebugCanvas.h"
#include "SkPicture.h"
@@ -17,6 +19,7 @@
#include "UrlDataManager.h"
+class GrContextFactory;
struct MHD_Connection;
struct MHD_PostProcessor;
@@ -27,7 +30,8 @@ struct UploadContext {
};
struct Request {
- Request(SkString rootUrl);
+ Request(SkString rootUrl);
+ ~Request();
// draws to skia draw op N, highlighting the Mth batch(-1 means no highlight)
SkData* drawToPng(int n, int m = -1);
@@ -65,7 +69,7 @@ private:
GrContext* getContext();
SkAutoTUnref<SkPicture> fPicture;
- SkAutoTDelete<GrContextFactory> fContextFactory;
+ GrContextFactory* fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
bool fGPUEnabled;
};