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
This commit is contained in:
parent
9c3f14327a
commit
4083610290
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user