Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: tools/skiaserve/Request.cpp

Issue 1787843002: Fix up no gpu build (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/skiaserve/Request.h ('K') | « tools/skiaserve/Request.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skiaserve/Request.cpp
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index a0580754107667994ee4d12b03a8521a4d7a6ccb..f9ad867028f095081a7c9afc71c462243f038333 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);
« tools/skiaserve/Request.h ('K') | « tools/skiaserve/Request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698