ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrGLTextureRenderTarget.h" |
| 9 | |
| 10 | #include "SkTraceMemoryDump.h" |
| 11 | |
| 12 | // GrGLTextureRenderTarget must dump both of its superclasses. |
| 13 | void GrGLTextureRenderTarget::dumpMemoryStatistics( |
| 14 | SkTraceMemoryDump* traceMemoryDump) const { |
| 15 | GrGLRenderTarget::dumpMemoryStatistics(traceMemoryDump); |
| 16 | |
| 17 | // Also dump the GrGLTexture's memory. Due to this resource having both a |
| 18 | // texture and a |
| 19 | // renderbuffer component, dump as skia/gpu_resources/resource_#/texture |
| 20 | SkString dumpName("skia/gpu_resources/resource_"); |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 21 | dumpName.appendS32(this->uniqueID()); |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 22 | dumpName.append("/texture"); |
| 23 | |
| 24 | // Use the texture's gpuMemorySize, not our own, which includes the |
| 25 | // renderbuffer as well. |
| 26 | size_t size = GrGLTexture::gpuMemorySize(); |
| 27 | |
| 28 | traceMemoryDump->dumpNumericValue(dumpName.c_str(), "size", "bytes", size); |
| 29 | |
| 30 | if (this->isPurgeable()) { |
| 31 | traceMemoryDump->dumpNumericValue(dumpName.c_str(), "purgeable_size", |
| 32 | "bytes", size); |
| 33 | } |
| 34 | |
| 35 | SkString texture_id; |
| 36 | texture_id.appendU32(this->textureID()); |
| 37 | traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_texture", |
| 38 | texture_id.c_str()); |
| 39 | } |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 40 | |
| 41 | bool GrGLTextureRenderTarget::canAttemptStencilAttachment() const { |
| 42 | // The RT FBO of GrGLTextureRenderTarget is never created from a |
| 43 | // wrapped FBO. |
| 44 | return true; |
| 45 | } |
| 46 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 47 | sk_sp<GrGLTextureRenderTarget> GrGLTextureRenderTarget::MakeWrapped( |
| 48 | GrGLGpu* gpu, const GrSurfaceDesc& desc, |
| 49 | const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc) |
| 50 | { |
| 51 | return sk_sp<GrGLTextureRenderTarget>( |
Robert Phillips | ccd3c89 | 2016-11-04 10:23:43 -0400 | [diff] [blame] | 52 | new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc, false)); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 53 | } |