Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: src/gpu/gl/SkNullGLContext.cpp

Issue 1217573002: remove SkInstCnt (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "gl/SkNullGLContext.h" 9 #include "gl/SkNullGLContext.h"
10 #include "gl/GrGLInterface.h" 10 #include "gl/GrGLInterface.h"
11 #include "GrGLDefines.h" 11 #include "GrGLDefines.h"
12 #include "GrGLNoOpInterface.h" 12 #include "GrGLNoOpInterface.h"
13 #include "SkTDArray.h" 13 #include "SkTDArray.h"
14 #include "SkTLS.h" 14 #include "SkTLS.h"
15 15
16 static SkNullGLContext::ContextState* current_context(); 16 static SkNullGLContext::ContextState* current_context();
17 17
18 //////////////////////////////////////////////////////////////////////////////// ///////////////// 18 //////////////////////////////////////////////////////////////////////////////// /////////////////
19 19
20 class BufferObj { 20 class BufferObj {
21 public: 21 public:
22 SK_DECLARE_INST_COUNT(BufferObj); 22
23 23
24 BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) { } 24 BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) { }
25 ~BufferObj() { SkDELETE_ARRAY(fDataPtr); } 25 ~BufferObj() { SkDELETE_ARRAY(fDataPtr); }
26 26
27 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) { 27 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
28 if (fDataPtr) { 28 if (fDataPtr) {
29 SkASSERT(0 != fSize); 29 SkASSERT(0 != fSize);
30 SkDELETE_ARRAY(fDataPtr); 30 SkDELETE_ARRAY(fDataPtr);
31 } 31 }
32 32
(...skipping 11 matching lines...) Expand all
44 private: 44 private:
45 GrGLuint fID; 45 GrGLuint fID;
46 GrGLchar* fDataPtr; 46 GrGLchar* fDataPtr;
47 GrGLsizeiptr fSize; // size in bytes 47 GrGLsizeiptr fSize; // size in bytes
48 bool fMapped; 48 bool fMapped;
49 }; 49 };
50 50
51 // This class maintains a sparsely populated array of buffer pointers. 51 // This class maintains a sparsely populated array of buffer pointers.
52 class BufferManager { 52 class BufferManager {
53 public: 53 public:
54 SK_DECLARE_INST_COUNT(BufferManager); 54
55 55
56 BufferManager() : fFreeListHead(kFreeListEnd) {} 56 BufferManager() : fFreeListHead(kFreeListEnd) {}
57 57
58 ~BufferManager() { 58 ~BufferManager() {
59 // NULL out the entries that are really free list links rather than ptrs before deleting. 59 // NULL out the entries that are really free list links rather than ptrs before deleting.
60 intptr_t curr = fFreeListHead; 60 intptr_t curr = fFreeListHead;
61 while (kFreeListEnd != curr) { 61 while (kFreeListEnd != curr) {
62 intptr_t next = reinterpret_cast<intptr_t>(fBuffers[SkToS32(curr)]); 62 intptr_t next = reinterpret_cast<intptr_t>(fBuffers[SkToS32(curr)]);
63 fBuffers[SkToS32(curr)] = NULL; 63 fBuffers[SkToS32(curr)] = NULL;
64 curr = next; 64 curr = next;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // the next free slot. The last free slot has a value of kFreeListEnd. 110 // the next free slot. The last free slot has a value of kFreeListEnd.
111 intptr_t fFreeListHead; 111 intptr_t fFreeListHead;
112 SkTDArray<BufferObj*> fBuffers; 112 SkTDArray<BufferObj*> fBuffers;
113 }; 113 };
114 114
115 /** 115 /**
116 * The state object for the null interface. 116 * The state object for the null interface.
117 */ 117 */
118 class SkNullGLContext::ContextState : public SkRefCnt { 118 class SkNullGLContext::ContextState : public SkRefCnt {
119 public: 119 public:
120 SK_DECLARE_INST_COUNT(ContextState); 120
121 121
122 BufferManager fBufferManager; 122 BufferManager fBufferManager;
123 GrGLuint fCurrArrayBuffer; 123 GrGLuint fCurrArrayBuffer;
124 GrGLuint fCurrElementArrayBuffer; 124 GrGLuint fCurrElementArrayBuffer;
125 GrGLuint fCurrProgramID; 125 GrGLuint fCurrProgramID;
126 GrGLuint fCurrShaderID; 126 GrGLuint fCurrShaderID;
127 127
128 128
129 ContextState() 129 ContextState()
130 : fCurrArrayBuffer(0) 130 : fCurrArrayBuffer(0)
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(fStat e); 553 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(fStat e);
554 #endif 554 #endif
555 } 555 }
556 556
557 SkNullGLContext::~SkNullGLContext() { 557 SkNullGLContext::~SkNullGLContext() {
558 this->teardown(); 558 this->teardown();
559 fState->unref(); 559 fState->unref();
560 } 560 }
561 561
562 void SkNullGLContext::onPlatformMakeCurrent() const { set_current_context(fState ); } 562 void SkNullGLContext::onPlatformMakeCurrent() const { set_current_context(fState ); }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698