Fix up no gpu build
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1787843002
Review URL: https://codereview.chromium.org/1787843002
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index a058075..f9ad867 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -56,8 +56,20 @@
, 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 @@
}
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 @@
}
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 @@
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);