aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/debugger/SkDebugCanvas.cpp10
-rw-r--r--tools/skiaserve/Request.cpp22
-rw-r--r--tools/skiaserve/Request.h8
3 files changed, 34 insertions, 6 deletions
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp
index cf2652cce4..4c58b96608 100644
--- a/tools/debugger/SkDebugCanvas.cpp
+++ b/tools/debugger/SkDebugCanvas.cpp
@@ -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;
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;
};