blob: 63d2e7be19fd0a5b4acf9aa744400ef44f222b35 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
bsalomon@google.com8fe72472011-03-30 21:26:44 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
bsalomon@google.com8fe72472011-03-30 21:26:44 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
bsalomon@google.com8fe72472011-03-30 21:26:44 +000010#include "GrResource.h"
11#include "GrGpu.h"
12
13GrResource::GrResource(GrGpu* gpu) {
14 fGpu = gpu;
15 fNext = NULL;
16 fPrevious = NULL;
17 fGpu->insertResource(this);
18}
19
20void GrResource::release() {
21 if (NULL != fGpu) {
22 this->onRelease();
23 fGpu->removeResource(this);
24 fGpu = NULL;
25 }
26}
27
28void GrResource::abandon() {
29 if (NULL != fGpu) {
30 this->onAbandon();
31 fGpu->removeResource(this);
32 fGpu = NULL;
33 }
34}
bsalomon@google.comf7b5c1e2011-11-15 19:42:07 +000035
36const GrContext* GrResource::getContext() const {
37 if (NULL != fGpu) {
38 return fGpu->getContext();
39 } else {
40 return NULL;
41 }
42}
43
44GrContext* GrResource::getContext() {
45 if (NULL != fGpu) {
46 return fGpu->getContext();
47 } else {
48 return NULL;
49 }
50}
51