diff options
author | bsalomon <bsalomon@google.com> | 2014-07-28 13:48:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-28 13:48:36 -0700 |
commit | 2354f8432a7205571f04f9638a0018fb0b1fb282 (patch) | |
tree | e342688d205bb86fff9a22305e333364f74f1545 /include/gpu | |
parent | 4beef91ec04b2edfbe983e672d50cd8f477eda7f (diff) |
Test abandoning GL context in dm/nanobench.
Rename GrContext::contextDestroyed to GrContext::abandonContext.
Remove GrContext::resetContext.
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/422903002
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrContext.h | 29 | ||||
-rw-r--r-- | include/gpu/GrContextFactory.h | 15 |
2 files changed, 26 insertions, 18 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index f533851ac3..103d76e8a2 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -85,24 +85,21 @@ public: } /** - * Abandons all GPU resources, assumes 3D API state is unknown. Call this - * if you have lost the associated GPU context, and thus internal texture, - * buffer, etc. references/IDs are now invalid. Should be called even when - * GrContext is no longer going to be used for two reasons: + * Abandons all GPU resources and assumes the underlying backend 3D API + * context is not longer usable. Call this if you have lost the associated + * GPU context, and thus internal texture, buffer, etc. references/IDs are + * now invalid. Should be called even when GrContext is no longer going to + * be used for two reasons: * 1) ~GrContext will not try to free the objects in the 3D API. - * 2) If you've created GrGpuResources that outlive the GrContext they - * will be marked as invalid (GrGpuResource::isValid()) and won't - * attempt to free their underlying resource in the 3D API. - * Content drawn since the last GrContext::flush() may be lost. + * 2) Any GrGpuResources created by this GrContext that outlive + * will be marked as invalid (GrGpuResource::wasDestroyed()) and + * when they're destroyed no 3D API calls will be made. + * Content drawn since the last GrContext::flush() may be lost. After this + * function is called the only valid action on the GrContext or + * GrGpuResources it created is to destroy them. */ - void contextLost(); - - /** - * Similar to contextLost, but makes no attempt to reset state. - * Use this method when GrContext destruction is pending, but - * the graphics context is destroyed first. - */ - void contextDestroyed(); + void abandonContext(); + void contextDestroyed() { this->abandonContext(); } // legacy alias /////////////////////////////////////////////////////////////////////////// // Resource Cache diff --git a/include/gpu/GrContextFactory.h b/include/gpu/GrContextFactory.h index 1f1f89df14..01e0239b1a 100644 --- a/include/gpu/GrContextFactory.h +++ b/include/gpu/GrContextFactory.h @@ -94,13 +94,24 @@ public: void destroyContexts() { for (int i = 0; i < fContexts.count(); ++i) { - fContexts[i].fGLContext->makeCurrent(); + if (NULL != fContexts[i].fGLContext) { // could be abandoned. + fContexts[i].fGLContext->makeCurrent(); + } fContexts[i].fGrContext->unref(); - fContexts[i].fGLContext->unref(); + if (NULL != fContexts[i].fGLContext) { + fContexts[i].fGLContext->unref(); + } } fContexts.reset(); } + void abandonContexts() { + for (int i = 0; i < fContexts.count(); ++i) { + SkSafeSetNull(fContexts[i].fGLContext); + fContexts[i].fGrContext->abandonContext(); + } + } + /** * Get a GrContext initialized with a type of GL context. It also makes the GL context current. */ |