OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #include "GrDebugGL.h" | 9 #include "GrDebugGL.h" |
10 #include "GrTextureObj.h" | 10 #include "GrTextureObj.h" |
11 #include "GrBufferObj.h" | 11 #include "GrBufferObj.h" |
12 #include "GrRenderBufferObj.h" | 12 #include "GrRenderBufferObj.h" |
13 #include "GrFrameBufferObj.h" | 13 #include "GrFrameBufferObj.h" |
14 #include "GrShaderObj.h" | 14 #include "GrShaderObj.h" |
15 #include "GrProgramObj.h" | 15 #include "GrProgramObj.h" |
16 #include "GrTextureUnitObj.h" | 16 #include "GrTextureUnitObj.h" |
17 #include "GrVertexArrayObj.h" | 17 #include "GrVertexArrayObj.h" |
18 | 18 |
19 GrDebugGL* GrDebugGL::gObj = NULL; | 19 GrDebugGL* GrDebugGL::gObj = nullptr; |
20 int GrDebugGL::gStaticRefCount = 0; | 20 int GrDebugGL::gStaticRefCount = 0; |
21 GrDebugGL::Create GrDebugGL::gFactoryFunc[kObjTypeCount] = { | 21 GrDebugGL::Create GrDebugGL::gFactoryFunc[kObjTypeCount] = { |
22 GrTextureObj::createGrTextureObj, | 22 GrTextureObj::createGrTextureObj, |
23 GrBufferObj::createGrBufferObj, | 23 GrBufferObj::createGrBufferObj, |
24 GrRenderBufferObj::createGrRenderBufferObj, | 24 GrRenderBufferObj::createGrRenderBufferObj, |
25 GrFrameBufferObj::createGrFrameBufferObj, | 25 GrFrameBufferObj::createGrFrameBufferObj, |
26 GrShaderObj::createGrShaderObj, | 26 GrShaderObj::createGrShaderObj, |
27 GrProgramObj::createGrProgramObj, | 27 GrProgramObj::createGrProgramObj, |
28 GrTextureUnitObj::createGrTextureUnitObj, | 28 GrTextureUnitObj::createGrTextureUnitObj, |
29 GrVertexArrayObj::createGrVertexArrayObj, | 29 GrVertexArrayObj::createGrVertexArrayObj, |
30 }; | 30 }; |
31 | 31 |
32 | 32 |
33 GrDebugGL::GrDebugGL() | 33 GrDebugGL::GrDebugGL() |
34 : fPackRowLength(0) | 34 : fPackRowLength(0) |
35 , fUnPackRowLength(0) | 35 , fUnPackRowLength(0) |
36 , fCurTextureUnit(0) | 36 , fCurTextureUnit(0) |
37 , fArrayBuffer(NULL) | 37 , fArrayBuffer(nullptr) |
38 , fElementArrayBuffer(NULL) | 38 , fElementArrayBuffer(nullptr) |
39 , fFrameBuffer(NULL) | 39 , fFrameBuffer(nullptr) |
40 , fRenderBuffer(NULL) | 40 , fRenderBuffer(nullptr) |
41 , fProgram(NULL) | 41 , fProgram(nullptr) |
42 , fTexture(NULL) | 42 , fTexture(nullptr) |
43 , fVertexArray(NULL) | 43 , fVertexArray(nullptr) |
44 , fAbandoned(false) { | 44 , fAbandoned(false) { |
45 | 45 |
46 for (int i = 0; i < kDefaultMaxTextureUnits; ++i) { | 46 for (int i = 0; i < kDefaultMaxTextureUnits; ++i) { |
47 | 47 |
48 fTextureUnits[i] = reinterpret_cast<GrTextureUnitObj *>( | 48 fTextureUnits[i] = reinterpret_cast<GrTextureUnitObj *>( |
49 createObj(GrDebugGL::kTextureUnit_ObjTypes)); | 49 createObj(GrDebugGL::kTextureUnit_ObjTypes)); |
50 fTextureUnits[i]->ref(); | 50 fTextureUnits[i]->ref(); |
51 | 51 |
52 fTextureUnits[i]->setNumber(i); | 52 fTextureUnits[i]->setNumber(i); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 GrDebugGL::~GrDebugGL() { | 56 GrDebugGL::~GrDebugGL() { |
57 // unref & delete the texture units first so they don't show up on the leak
report | 57 // unref & delete the texture units first so they don't show up on the leak
report |
58 for (int i = 0; i < kDefaultMaxTextureUnits; ++i) { | 58 for (int i = 0; i < kDefaultMaxTextureUnits; ++i) { |
59 fTextureUnits[i]->unref(); | 59 fTextureUnits[i]->unref(); |
60 fTextureUnits[i]->deleteAction(); | 60 fTextureUnits[i]->deleteAction(); |
61 } | 61 } |
62 | 62 |
63 this->report(); | 63 this->report(); |
64 | 64 |
65 for (int i = 0; i < fObjects.count(); ++i) { | 65 for (int i = 0; i < fObjects.count(); ++i) { |
66 delete fObjects[i]; | 66 delete fObjects[i]; |
67 } | 67 } |
68 fObjects.reset(); | 68 fObjects.reset(); |
69 | 69 |
70 fArrayBuffer = NULL; | 70 fArrayBuffer = nullptr; |
71 fElementArrayBuffer = NULL; | 71 fElementArrayBuffer = nullptr; |
72 fFrameBuffer = NULL; | 72 fFrameBuffer = nullptr; |
73 fRenderBuffer = NULL; | 73 fRenderBuffer = nullptr; |
74 fProgram = NULL; | 74 fProgram = nullptr; |
75 fTexture = NULL; | 75 fTexture = nullptr; |
76 fVertexArray = NULL; | 76 fVertexArray = nullptr; |
77 } | 77 } |
78 | 78 |
79 GrFakeRefObj *GrDebugGL::findObject(GrGLuint ID, GrObjTypes type) { | 79 GrFakeRefObj *GrDebugGL::findObject(GrGLuint ID, GrObjTypes type) { |
80 for (int i = 0; i < fObjects.count(); ++i) { | 80 for (int i = 0; i < fObjects.count(); ++i) { |
81 if (fObjects[i]->getID() == ID) { // && fObjects[i]->getType() == type)
{ | 81 if (fObjects[i]->getID() == ID) { // && fObjects[i]->getType() == type)
{ |
82 // The application shouldn't be accessing objects | 82 // The application shouldn't be accessing objects |
83 // that (as far as OpenGL knows) were already deleted | 83 // that (as far as OpenGL knows) were already deleted |
84 GrAlwaysAssert(!fObjects[i]->getDeleted()); | 84 GrAlwaysAssert(!fObjects[i]->getDeleted()); |
85 GrAlwaysAssert(!fObjects[i]->getMarkedForDeletion()); | 85 GrAlwaysAssert(!fObjects[i]->getMarkedForDeletion()); |
86 return fObjects[i]; | 86 return fObjects[i]; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 return NULL; | 90 return nullptr; |
91 } | 91 } |
92 | 92 |
93 void GrDebugGL::setArrayBuffer(GrBufferObj *arrayBuffer) { | 93 void GrDebugGL::setArrayBuffer(GrBufferObj *arrayBuffer) { |
94 if (fArrayBuffer) { | 94 if (fArrayBuffer) { |
95 // automatically break the binding of the old buffer | 95 // automatically break the binding of the old buffer |
96 GrAlwaysAssert(fArrayBuffer->getBound()); | 96 GrAlwaysAssert(fArrayBuffer->getBound()); |
97 fArrayBuffer->resetBound(); | 97 fArrayBuffer->resetBound(); |
98 | 98 |
99 GrAlwaysAssert(!fArrayBuffer->getDeleted()); | 99 GrAlwaysAssert(!fArrayBuffer->getDeleted()); |
100 fArrayBuffer->unref(); | 100 fArrayBuffer->unref(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 void GrDebugGL::report() const { | 206 void GrDebugGL::report() const { |
207 for (int i = 0; i < fObjects.count(); ++i) { | 207 for (int i = 0; i < fObjects.count(); ++i) { |
208 if (!fAbandoned) { | 208 if (!fAbandoned) { |
209 GrAlwaysAssert(0 == fObjects[i]->getRefCount()); | 209 GrAlwaysAssert(0 == fObjects[i]->getRefCount()); |
210 GrAlwaysAssert(fObjects[i]->getDeleted()); | 210 GrAlwaysAssert(fObjects[i]->getDeleted()); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
OLD | NEW |