aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Khushal <khushalsagar@chromium.org>2018-06-26 14:38:34 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-27 01:08:45 +0000
commitc421ca1d6e41214f09c0e6311c8519a15e44edd4 (patch)
treeae029083d130acb979f9e1c15c862f6436908d7b
parentef12509ff2668027664308653ced36039af800ad (diff)
gpu: Expose GrContextPriv::abandoned in the public API.
TBR=bsalomon@google.com Bug: 854416 Change-Id: Iab71ca6e4724a925b0b9791267aac5ddc34f5b15 Reviewed-on: https://skia-review.googlesource.com/137692 Reviewed-by: Khusal Sagar <khushalsagar@chromium.org> Commit-Queue: Khusal Sagar <khushalsagar@chromium.org>
-rw-r--r--dm/DMSrcSink.cpp2
-rw-r--r--gm/imagefromyuvtextures.cpp4
-rw-r--r--gm/rectangletexture.cpp2
-rw-r--r--include/gpu/GrContext.h5
-rw-r--r--src/core/SkSpecialImage.cpp2
-rw-r--r--src/gpu/GrAHardwareBufferImageGenerator.cpp3
-rw-r--r--src/gpu/GrBlurUtils.cpp2
-rw-r--r--src/gpu/GrContext.cpp12
-rw-r--r--src/gpu/GrContextPriv.h2
-rw-r--r--src/gpu/SkGpuDevice.cpp2
-rw-r--r--src/gpu/text/GrTextContext.cpp4
-rw-r--r--src/image/SkImage.cpp2
-rw-r--r--src/image/SkImage_Gpu.cpp2
-rw-r--r--tools/gpu/ProxyUtils.cpp2
14 files changed, 24 insertions, 22 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 9a16e89b07..22c34aadd0 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1563,7 +1563,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
} else if (FLAGS_releaseAndAbandonGpuContext) {
factory.releaseResourcesAndAbandonContexts();
}
- if (!context->contextPriv().abandoned()) {
+ if (!context->abandoned()) {
surface.reset();
if (backendTexture.isValid()) {
context->contextPriv().getGpu()->deleteTestingOnlyBackendTexture(backendTexture);
diff --git a/gm/imagefromyuvtextures.cpp b/gm/imagefromyuvtextures.cpp
index 87ab51ec1d..9d72cc05fc 100644
--- a/gm/imagefromyuvtextures.cpp
+++ b/gm/imagefromyuvtextures.cpp
@@ -94,7 +94,7 @@ protected:
}
void createYUVTextures(GrContext* context, GrBackendTexture yuvTextures[3]) {
- if (context->contextPriv().abandoned()) {
+ if (context->abandoned()) {
return;
}
@@ -115,7 +115,7 @@ protected:
}
void deleteYUVTextures(GrContext* context, GrBackendTexture yuvTextures[3]) {
- if (context->contextPriv().abandoned()) {
+ if (context->abandoned()) {
return;
}
diff --git a/gm/rectangletexture.cpp b/gm/rectangletexture.cpp
index d6bf1fb87e..c22e420d68 100644
--- a/gm/rectangletexture.cpp
+++ b/gm/rectangletexture.cpp
@@ -60,7 +60,7 @@ protected:
if (!context) {
return nullptr;
}
- if (context->contextPriv().abandoned()) {
+ if (context->abandoned()) {
return nullptr;
}
GrGpu* gpu = context->contextPriv().getGpu();
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 73bf76a5e3..c1804e00ff 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -115,6 +115,11 @@ public:
virtual void abandonContext();
/**
+ * Returns true if the context was abandoned.
+ */
+ bool abandoned() const;
+
+ /**
* This is similar to abandonContext() however the underlying 3D context is not yet lost and
* the GrContext will cleanup all allocated resources before returning. After returning it will
* assume that the underlying context may no longer be valid.
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 0c6ec5c484..75946d0ffc 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -511,7 +511,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeDeferredFromGpu(GrContext* context,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props,
SkAlphaType at) {
- if (!context || context->contextPriv().abandoned() || !proxy) {
+ if (!context || context->abandoned() || !proxy) {
return nullptr;
}
SkASSERT_RELEASE(rect_fits(subset, proxy->width(), proxy->height()));
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index ea1da11ab0..e3ae782d9a 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -144,8 +144,7 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::onGenerateTexture(
}
sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* context) {
- if (context->contextPriv().abandoned() ||
- kOpenGL_GrBackend != context->contextPriv().getBackend()) {
+ if (context->abandoned() || kOpenGL_GrBackend != context->contextPriv().getBackend()) {
// Check if GrContext is not abandoned and the backend is GL.
return nullptr;
}
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index cc59c02843..c651c4848b 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -273,7 +273,7 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
const SkMatrix* prePathMatrix,
const SkIRect& clipBounds,
bool pathIsMutable) {
- if (context->contextPriv().abandoned()) {
+ if (context->abandoned()) {
return;
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index b4387e21a1..a34ee88a33 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -255,6 +255,11 @@ void GrContext::abandonContext() {
fTextBlobCache->freeAll();
}
+bool GrContext::abandoned() const {
+ ASSERT_SINGLE_OWNER
+ return fDrawingManager->wasAbandoned();
+}
+
void GrContext::releaseResourcesAndAbandonContext() {
ASSERT_SINGLE_OWNER
@@ -1010,7 +1015,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted) {
SkASSERT(sampleCnt > 0);
- if (this->abandoned()) {
+ if (fContext->abandoned()) {
return nullptr;
}
@@ -1044,11 +1049,6 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
return renderTargetContext;
}
-bool GrContextPriv::abandoned() const {
- ASSERT_SINGLE_OWNER_PRIV
- return fContext->fDrawingManager->wasAbandoned();
-}
-
std::unique_ptr<GrFragmentProcessor> GrContext::createPMToUPMEffect(
std::unique_ptr<GrFragmentProcessor> fp, bool useConfigConversionEffect) {
ASSERT_SINGLE_OWNER
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 8d4b1ed28f..4f392f88b3 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -246,8 +246,6 @@ public:
const SkSurfaceProps* surfaceProps = nullptr,
SkBudgeted budgeted = SkBudgeted::kYes);
- bool abandoned() const;
-
/** Reset GPU stats */
void resetGpuStats() const ;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index ca3d559e36..819acd2ef8 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1041,7 +1041,7 @@ void SkGpuDevice::drawSprite(const SkBitmap& bitmap,
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSprite", fContext.get());
- if (fContext->contextPriv().abandoned()) {
+ if (fContext->abandoned()) {
return;
}
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 6da4c0d014..a20ba4424a 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -103,7 +103,7 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target
const SkTextBlob* blob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter, const SkIRect& clipBounds) {
// If we have been abandoned, then don't draw
- if (context->contextPriv().abandoned()) {
+ if (context->abandoned()) {
return;
}
@@ -316,7 +316,7 @@ void GrTextContext::drawPosText(GrContext* context, GrTextUtils::Target* target,
int scalarsPerPosition, const SkPoint& offset,
const SkIRect& regionClipBounds) {
GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
- if (context->contextPriv().abandoned()) {
+ if (context->abandoned()) {
return;
}
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index ee0eff08a9..43c4cbaa39 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -163,7 +163,7 @@ GrBackendTexture SkImage::getBackendTexture(bool flushPendingGrContextIO,
}
bool SkImage::isValid(GrContext* context) const {
- if (context && context->contextPriv().abandoned()) {
+ if (context && context->abandoned()) {
return false;
}
return as_IB(this)->onIsValid(context);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 670b41ffe5..8a7a789ec9 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -1019,7 +1019,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColor
bool SkImage_Gpu::onIsValid(GrContext* context) const {
// The base class has already checked that context isn't abandoned (if it's not nullptr)
- if (fContext->contextPriv().abandoned()) {
+ if (fContext->abandoned()) {
return false;
}
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index 64af648068..dab3ca6b82 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -18,7 +18,7 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, in
GrColorType ct, GrSRGBEncoded srgbEncoded,
GrSurfaceOrigin origin, const void* data,
size_t rowBytes) {
- if (context->contextPriv().abandoned()) {
+ if (context->abandoned()) {
return nullptr;
}