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) {
}
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++) {
GrAuditTrail::AutoEnable ae(at);
canvas->flush();
}
-#endif
}
+#endif
}
void SkDebugCanvas::cleanupAuditTrail(SkCanvas* canvas) {
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);
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;
, 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) {
}
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
}
GrContext* Request::getContext() {
+#if SK_SUPPORT_GPU
return fContextFactory->get(GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions);
+#else
+ return nullptr;
+#endif
}
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);
#ifndef Request_DEFINED
#define Request_DEFINED
+#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
+#endif
#include "SkDebugCanvas.h"
#include "SkPicture.h"
#include "UrlDataManager.h"
+class GrContextFactory;
struct MHD_Connection;
struct MHD_PostProcessor;
};
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);
GrContext* getContext();
SkAutoTUnref<SkPicture> fPicture;
- SkAutoTDelete<GrContextFactory> fContextFactory;
+ GrContextFactory* fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
bool fGPUEnabled;
};