Home | History | Annotate | Download | only in gpu
      1 
      2 /*
      3  * 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.
      7  */
      8 
      9 
     10 #include "GrResource.h"
     11 #include "GrGpu.h"
     12 
     13 GrResource::GrResource(GrGpu* gpu) {
     14     fGpu        = gpu;
     15     fNext       = NULL;
     16     fPrevious   = NULL;
     17     fGpu->insertResource(this);
     18 }
     19 
     20 void GrResource::release() {
     21     if (NULL != fGpu) {
     22         this->onRelease();
     23         fGpu->removeResource(this);
     24         fGpu = NULL;
     25     }
     26 }
     27 
     28 void GrResource::abandon() {
     29     if (NULL != fGpu) {
     30         this->onAbandon();
     31         fGpu->removeResource(this);
     32         fGpu = NULL;
     33     }
     34 }
     35 
     36 const GrContext* GrResource::getContext() const {
     37     if (NULL != fGpu) {
     38         return fGpu->getContext();
     39     } else {
     40         return NULL;
     41     }
     42 }
     43 
     44 GrContext* GrResource::getContext() {
     45     if (NULL != fGpu) {
     46         return fGpu->getContext();
     47     } else {
     48         return NULL;
     49     }
     50 }
     51 
     52