Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #include "GrResource.h" |
michael@0 | 11 | #include "GrGpu.h" |
michael@0 | 12 | |
michael@0 | 13 | GrResource::GrResource(GrGpu* gpu, bool isWrapped) { |
michael@0 | 14 | fGpu = gpu; |
michael@0 | 15 | fCacheEntry = NULL; |
michael@0 | 16 | fDeferredRefCount = 0; |
michael@0 | 17 | if (isWrapped) { |
michael@0 | 18 | fFlags = kWrapped_FlagBit; |
michael@0 | 19 | } else { |
michael@0 | 20 | fFlags = 0; |
michael@0 | 21 | } |
michael@0 | 22 | fGpu->insertResource(this); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | GrResource::~GrResource() { |
michael@0 | 26 | // subclass should have released this. |
michael@0 | 27 | SkASSERT(0 == fDeferredRefCount); |
michael@0 | 28 | SkASSERT(!this->isValid()); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | void GrResource::release() { |
michael@0 | 32 | if (NULL != fGpu) { |
michael@0 | 33 | this->onRelease(); |
michael@0 | 34 | fGpu->removeResource(this); |
michael@0 | 35 | fGpu = NULL; |
michael@0 | 36 | } |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | void GrResource::abandon() { |
michael@0 | 40 | if (NULL != fGpu) { |
michael@0 | 41 | this->onAbandon(); |
michael@0 | 42 | fGpu->removeResource(this); |
michael@0 | 43 | fGpu = NULL; |
michael@0 | 44 | } |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | const GrContext* GrResource::getContext() const { |
michael@0 | 48 | if (NULL != fGpu) { |
michael@0 | 49 | return fGpu->getContext(); |
michael@0 | 50 | } else { |
michael@0 | 51 | return NULL; |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | GrContext* GrResource::getContext() { |
michael@0 | 56 | if (NULL != fGpu) { |
michael@0 | 57 | return fGpu->getContext(); |
michael@0 | 58 | } else { |
michael@0 | 59 | return NULL; |
michael@0 | 60 | } |
michael@0 | 61 | } |