aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-15 16:53:06 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-15 21:25:16 +0000
commit6ceaafa7b9292ba2db52c105cc9692bda9970f08 (patch)
tree68ec7437add944561675451738717677cd8be415 /src/core
parentaf18f22da6c53346a326dcb0c1b237e20ca44fe4 (diff)
Handle GrContext creation failure in DDL
TBR=bsalomon@google.com Change-Id: Ib34448a60cb127ef89bcb0b1f85d07abc91af582 Reviewed-on: https://skia-review.googlesource.com/114569 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkDeferredDisplayListRecorder.cpp102
1 files changed, 60 insertions, 42 deletions
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index cfb6c0063e..3d84aeb7bb 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -7,56 +7,73 @@
#include "SkDeferredDisplayListRecorder.h"
+#include "SkDeferredDisplayList.h"
+#include "SkSurface.h"
+#include "SkSurfaceCharacterization.h"
+
+#if !SK_SUPPORT_GPU
+SkDeferredDisplayListRecorder::SkDeferredDisplayListRecorder(const SkSurfaceCharacterization&) {}
+
+SkDeferredDisplayListRecorder::~SkDeferredDisplayListRecorder() {}
+
+bool SkDeferredDisplayListRecorder::init() { return false; }
+
+SkCanvas* SkDeferredDisplayListRecorder::getCanvas() { return nullptr; }
+
+std::unique_ptr<SkDeferredDisplayList> SkDeferredDisplayListRecorder::detach() { return nullptr; }
+
+sk_sp<SkImage> SkDeferredDisplayListRecorder::makePromiseTexture(
+ const GrBackendFormat& backendFormat,
+ int width,
+ int height,
+ GrMipMapped mipMapped,
+ GrSurfaceOrigin origin,
+ SkColorType colorType,
+ SkAlphaType alphaType,
+ sk_sp<SkColorSpace> colorSpace,
+ TextureFulfillProc textureFulfillProc,
+ TextureReleaseProc textureReleaseProc,
+ TextureContext textureContext) {
+ return nullptr;
+}
+
+#else
-#if SK_SUPPORT_GPU
#include "GrContextPriv.h"
#include "GrProxyProvider.h"
#include "GrTexture.h"
-#include "SkGpuDevice.h"
#include "SkGr.h"
#include "SkImage_Gpu.h"
#include "SkSurface_Gpu.h"
-#endif
-#include "SkCanvas.h" // TODO: remove
-#include "SkDeferredDisplayList.h"
-#include "SkSurface.h"
-#include "SkSurfaceCharacterization.h"
-
-SkDeferredDisplayListRecorder::SkDeferredDisplayListRecorder(
- const SkSurfaceCharacterization& characterization)
- : fCharacterization(characterization) {
+SkDeferredDisplayListRecorder::SkDeferredDisplayListRecorder(const SkSurfaceCharacterization& c)
+ : fCharacterization(c) {
+ if (fCharacterization.isValid()) {
+ fContext = GrContextPriv::MakeDDL(fCharacterization.refContextInfo());
+ }
}
SkDeferredDisplayListRecorder::~SkDeferredDisplayListRecorder() {
-#if SK_SUPPORT_GPU
- auto proxyProvider = fContext->contextPriv().proxyProvider();
+ if (fContext) {
+ auto proxyProvider = fContext->contextPriv().proxyProvider();
- // DDL TODO: Remove this. DDL contexts should allow for deletion while still having live
- // uniquely keyed proxies.
- proxyProvider->removeAllUniqueKeys();
-#endif
+ // DDL TODO: Remove this. DDL contexts should allow for deletion while still having live
+ // uniquely keyed proxies.
+ proxyProvider->removeAllUniqueKeys();
+ }
}
bool SkDeferredDisplayListRecorder::init() {
+ SkASSERT(fContext);
+ SkASSERT(!fLazyProxyData);
SkASSERT(!fSurface);
if (!fCharacterization.isValid()) {
return false;
}
- SkASSERT(!fLazyProxyData);
-
-#if SK_SUPPORT_GPU
- if (!fContext) {
- fContext = GrContextPriv::MakeDDL(fCharacterization.refContextInfo());
- if (!fContext) {
- return false;
- }
- }
-
fLazyProxyData = sk_sp<SkDeferredDisplayList::LazyProxyData>(
new SkDeferredDisplayList::LazyProxyData);
@@ -101,31 +118,30 @@ bool SkDeferredDisplayListRecorder::init() {
fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(),
sk_ref_sp(c->asRenderTargetContext()));
return SkToBool(fSurface.get());
-#else
- return false;
-#endif
}
SkCanvas* SkDeferredDisplayListRecorder::getCanvas() {
- if (!fSurface) {
- if (!this->init()) {
- return nullptr;
- }
+ if (!fContext) {
+ return nullptr;
+ }
+
+ if (!fSurface && !this->init()) {
+ return nullptr;
}
return fSurface->getCanvas();
}
std::unique_ptr<SkDeferredDisplayList> SkDeferredDisplayListRecorder::detach() {
-#if SK_SUPPORT_GPU
+ if (!fContext) {
+ return nullptr;
+ }
+
auto ddl = std::unique_ptr<SkDeferredDisplayList>(
new SkDeferredDisplayList(fCharacterization, std::move(fLazyProxyData)));
fContext->contextPriv().moveOpListsToDDL(ddl.get());
return ddl;
-#else
- return nullptr;
-#endif
}
sk_sp<SkImage> SkDeferredDisplayListRecorder::makePromiseTexture(
@@ -140,7 +156,10 @@ sk_sp<SkImage> SkDeferredDisplayListRecorder::makePromiseTexture(
TextureFulfillProc textureFulfillProc,
TextureReleaseProc textureReleaseProc,
TextureContext textureContext) {
-#if SK_SUPPORT_GPU
+ if (!fContext) {
+ return nullptr;
+ }
+
return SkImage_Gpu::MakePromiseTexture(fContext.get(),
backendFormat,
width,
@@ -153,7 +172,6 @@ sk_sp<SkImage> SkDeferredDisplayListRecorder::makePromiseTexture(
textureFulfillProc,
textureReleaseProc,
textureContext);
-#else
- return nullptr;
-#endif
}
+
+#endif