gfx/skia/trunk/src/gpu/GrResource.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/gpu/GrResource.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#include "GrResource.h"
    1.14 +#include "GrGpu.h"
    1.15 +
    1.16 +GrResource::GrResource(GrGpu* gpu, bool isWrapped) {
    1.17 +    fGpu              = gpu;
    1.18 +    fCacheEntry       = NULL;
    1.19 +    fDeferredRefCount = 0;
    1.20 +    if (isWrapped) {
    1.21 +        fFlags = kWrapped_FlagBit;
    1.22 +    } else {
    1.23 +        fFlags = 0;
    1.24 +    }
    1.25 +    fGpu->insertResource(this);
    1.26 +}
    1.27 +
    1.28 +GrResource::~GrResource() {
    1.29 +    // subclass should have released this.
    1.30 +    SkASSERT(0 == fDeferredRefCount);
    1.31 +    SkASSERT(!this->isValid());
    1.32 +}
    1.33 +
    1.34 +void GrResource::release() {
    1.35 +    if (NULL != fGpu) {
    1.36 +        this->onRelease();
    1.37 +        fGpu->removeResource(this);
    1.38 +        fGpu = NULL;
    1.39 +    }
    1.40 +}
    1.41 +
    1.42 +void GrResource::abandon() {
    1.43 +    if (NULL != fGpu) {
    1.44 +        this->onAbandon();
    1.45 +        fGpu->removeResource(this);
    1.46 +        fGpu = NULL;
    1.47 +    }
    1.48 +}
    1.49 +
    1.50 +const GrContext* GrResource::getContext() const {
    1.51 +    if (NULL != fGpu) {
    1.52 +        return fGpu->getContext();
    1.53 +    } else {
    1.54 +        return NULL;
    1.55 +    }
    1.56 +}
    1.57 +
    1.58 +GrContext* GrResource::getContext() {
    1.59 +    if (NULL != fGpu) {
    1.60 +        return fGpu->getContext();
    1.61 +    } else {
    1.62 +        return NULL;
    1.63 +    }
    1.64 +}

mercurial