Fix up no gpu build
authorjoshualitt <joshualitt@chromium.org>
Fri, 11 Mar 2016 19:45:53 +0000 (11:45 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 11 Mar 2016 19:45:53 +0000 (11:45 -0800)
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

tools/debugger/SkDebugCanvas.cpp
tools/skiaserve/Request.cpp
tools/skiaserve/Request.h

index cf2652cce4c625f2d03c4351d20262bff1106255..4c58b966080b56aaf047fc987da068bdb1dc9554 100644 (file)
@@ -225,11 +225,13 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index, int m) {
         this->markActiveCommands(index);
     }
    
+#if SK_SUPPORT_GPU
     // If we have a GPU backend we can also visualize the batching information
     GrAuditTrail* at = nullptr;
     if (fDrawGpuBatchBounds || m != -1) {
         at = this->getAuditTrail(canvas);
     }
+#endif
 
     for (int i = 0; i <= index; i++) {
         if (i == index && fFilter) {
@@ -424,9 +426,9 @@ GrAuditTrail* SkDebugCanvas::getAuditTrail(SkCanvas* canvas) {
 }
 
 void SkDebugCanvas::drawAndCollectBatches(int n, SkCanvas* canvas) {
+#if SK_SUPPORT_GPU
     GrAuditTrail* at = this->getAuditTrail(canvas);
     if (at) {
-#if SK_SUPPORT_GPU
         // loop over all of the commands and draw them, this is to collect reordering
         // information
         for (int i = 0; i < this->getSize() && i <= n; i++) {
@@ -439,8 +441,8 @@ void SkDebugCanvas::drawAndCollectBatches(int n, SkCanvas* canvas) {
             GrAuditTrail::AutoEnable ae(at);
             canvas->flush();
         }
-#endif
     }
+#endif
 }
 
 void SkDebugCanvas::cleanupAuditTrail(SkCanvas* canvas) {
@@ -457,7 +459,9 @@ Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n, SkCanva
     this->drawAndCollectBatches(n, canvas);
     
     // now collect json
+#if SK_SUPPORT_GPU
     GrAuditTrail* at = this->getAuditTrail(canvas);
+#endif
     Json::Value result = Json::Value(Json::objectValue);
     result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION);
     Json::Value commands = Json::Value(Json::arrayValue);
@@ -484,8 +488,8 @@ Json::Value SkDebugCanvas::toJSONBatchList(int n, SkCanvas* canvas) {
     this->drawAndCollectBatches(n, canvas);
 
     Json::Value parsedFromString;
-    GrAuditTrail* at = this->getAuditTrail(canvas);
 #if SK_SUPPORT_GPU
+    GrAuditTrail* at = this->getAuditTrail(canvas);
     if (at) {
         GrAuditTrail::AutoManageBatchList enable(at);
         Json::Reader reader;
index a0580754107667994ee4d12b03a8521a4d7a6ccb..f9ad867028f095081a7c9afc71c462243f038333 100644 (file)
@@ -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);
index 95e7f1568cdbcb17e5e23f4feaa553cb506461d7..52ebf25c2f0d0d1a0fce9ca213b551910e89e421 100644 (file)
@@ -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;
 };