OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrRenderTarget.h" | 10 #include "GrRenderTarget.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 void GrRenderTarget::discard() { | 25 void GrRenderTarget::discard() { |
26 // go through context so that all necessary flushing occurs | 26 // go through context so that all necessary flushing occurs |
27 GrContext* context = this->getContext(); | 27 GrContext* context = this->getContext(); |
28 if (NULL == context) { | 28 if (NULL == context) { |
29 return; | 29 return; |
30 } | 30 } |
31 context->discardRenderTarget(this); | 31 context->discardRenderTarget(this); |
32 } | 32 } |
33 | 33 |
34 size_t GrRenderTarget::gpuMemorySize() const { | |
35 size_t colorBits; | |
36 if (kUnknown_GrPixelConfig == fDesc.fConfig) { | |
37 colorBits = 32; // don't know, make a guess | |
38 } else { | |
39 colorBits = GrBytesPerPixel(fDesc.fConfig) * 8; | |
40 } | |
41 uint64_t size = fDesc.fWidth; | |
42 size *= fDesc.fHeight; | |
43 size *= colorBits; | |
44 size *= SkTMax(1, fDesc.fSampleCnt); | |
45 return (size_t)(size / 8); | |
46 } | |
47 | |
48 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) { | 34 void GrRenderTarget::flagAsNeedingResolve(const SkIRect* rect) { |
49 if (kCanResolve_ResolveType == getResolveType()) { | 35 if (kCanResolve_ResolveType == getResolveType()) { |
50 if (rect) { | 36 if (rect) { |
51 fResolveRect.join(*rect); | 37 fResolveRect.join(*rect); |
52 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { | 38 if (!fResolveRect.intersect(0, 0, this->width(), this->height())) { |
53 fResolveRect.setEmpty(); | 39 fResolveRect.setEmpty(); |
54 } | 40 } |
55 } else { | 41 } else { |
56 fResolveRect.setLTRB(0, 0, this->width(), this->height()); | 42 fResolveRect.setLTRB(0, 0, this->width(), this->height()); |
57 } | 43 } |
(...skipping 19 matching lines...) Expand all Loading... |
77 this->setStencilBuffer(NULL); | 63 this->setStencilBuffer(NULL); |
78 | 64 |
79 INHERITED::onRelease(); | 65 INHERITED::onRelease(); |
80 } | 66 } |
81 | 67 |
82 void GrRenderTarget::onAbandon() { | 68 void GrRenderTarget::onAbandon() { |
83 this->setStencilBuffer(NULL); | 69 this->setStencilBuffer(NULL); |
84 | 70 |
85 INHERITED::onAbandon(); | 71 INHERITED::onAbandon(); |
86 } | 72 } |
OLD | NEW |