diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-02 21:38:22 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-02 21:38:22 +0000 |
commit | 089a780c3355129eefc942246534bc1f126b8ccb (patch) | |
tree | 717d71a73ad4ce8d8810cf8344d67c6ddb143507 /src/gpu/GrResource.cpp | |
parent | 40f6e3a25c0d35b9416346b72f1b6ba07778d173 (diff) |
Split GrResource into GrCacheable/GrGpuObject
Before this change, an object needed to inherit from GrResource (and
thus be a GPU object) in order to live in the GrResourceCache. That
was a problem for caching items that weren't GPU objects themselves,
but owned GPU objects.
This change splits GrResource into two classes:
1. GrCacheable: The base class for objects that can live in the
GrResourceCache.
2. GrGpuObject, which inherits from GrCacheable: The base class for
objects that get tracked by GrGpu.
This change is purely a refactor; there is no change in functionality.
Change-Id: I3e8daeb1f123041f414aa306c1366e959ae9e39e
BUG=skia:
R=bsalomon@google.com
Author: cdalton@nvidia.com
Review URL: https://codereview.chromium.org/251013002
git-svn-id: http://skia.googlecode.com/svn/trunk@14553 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrResource.cpp')
-rw-r--r-- | src/gpu/GrResource.cpp | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/gpu/GrResource.cpp b/src/gpu/GrResource.cpp deleted file mode 100644 index e20a30ffd3..0000000000 --- a/src/gpu/GrResource.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#include "GrResource.h" -#include "GrGpu.h" - -GrResource::GrResource(GrGpu* gpu, bool isWrapped) { - fGpu = gpu; - fCacheEntry = NULL; - fDeferredRefCount = 0; - if (isWrapped) { - fFlags = kWrapped_FlagBit; - } else { - fFlags = 0; - } - fGpu->insertResource(this); -} - -GrResource::~GrResource() { - // subclass should have released this. - SkASSERT(0 == fDeferredRefCount); - SkASSERT(!this->isValid()); -} - -void GrResource::release() { - if (NULL != fGpu) { - this->onRelease(); - fGpu->removeResource(this); - fGpu = NULL; - } -} - -void GrResource::abandon() { - if (NULL != fGpu) { - this->onAbandon(); - fGpu->removeResource(this); - fGpu = NULL; - } -} - -const GrContext* GrResource::getContext() const { - if (NULL != fGpu) { - return fGpu->getContext(); - } else { - return NULL; - } -} - -GrContext* GrResource::getContext() { - if (NULL != fGpu) { - return fGpu->getContext(); - } else { - return NULL; - } -} |