| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "gl/GrGLInterface.h" | 9 #include "gl/GrGLInterface.h" |
| 10 #include "GrGLDefines.h" | 10 #include "GrGLDefines.h" |
| 11 #include "SkTDArray.h" | 11 #include "SkTDArray.h" |
| 12 #include "GrGLNoOpInterface.h" | 12 #include "GrGLNoOpInterface.h" |
| 13 #include "SkTLS.h" | 13 #include "SkTLS.h" |
| 14 | 14 |
| 15 class BufferObj { | 15 class BufferObj { |
| 16 public: | 16 public: |
| 17 SK_DECLARE_INST_COUNT_ROOT(BufferObj); | 17 SK_DECLARE_INST_COUNT(BufferObj); |
| 18 | 18 |
| 19 BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) { | 19 BufferObj(GrGLuint id) : fID(id), fDataPtr(NULL), fSize(0), fMapped(false) { |
| 20 } | 20 } |
| 21 ~BufferObj() { SkDELETE_ARRAY(fDataPtr); } | 21 ~BufferObj() { SkDELETE_ARRAY(fDataPtr); } |
| 22 | 22 |
| 23 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) { | 23 void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) { |
| 24 if (fDataPtr) { | 24 if (fDataPtr) { |
| 25 SkASSERT(0 != fSize); | 25 SkASSERT(0 != fSize); |
| 26 SkDELETE_ARRAY(fDataPtr); | 26 SkDELETE_ARRAY(fDataPtr); |
| 27 } | 27 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 private: | 40 private: |
| 41 GrGLuint fID; | 41 GrGLuint fID; |
| 42 GrGLchar* fDataPtr; | 42 GrGLchar* fDataPtr; |
| 43 GrGLsizeiptr fSize; // size in bytes | 43 GrGLsizeiptr fSize; // size in bytes |
| 44 bool fMapped; | 44 bool fMapped; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // This class maintains a sparsely populated array of buffer pointers. | 47 // This class maintains a sparsely populated array of buffer pointers. |
| 48 class BufferManager { | 48 class BufferManager { |
| 49 public: | 49 public: |
| 50 SK_DECLARE_INST_COUNT_ROOT(BufferManager); | 50 SK_DECLARE_INST_COUNT(BufferManager); |
| 51 | 51 |
| 52 BufferManager() : fFreeListHead(kFreeListEnd) {} | 52 BufferManager() : fFreeListHead(kFreeListEnd) {} |
| 53 | 53 |
| 54 ~BufferManager() { | 54 ~BufferManager() { |
| 55 // NULL out the entries that are really free list links rather than ptrs
before deleting. | 55 // NULL out the entries that are really free list links rather than ptrs
before deleting. |
| 56 intptr_t curr = fFreeListHead; | 56 intptr_t curr = fFreeListHead; |
| 57 while (kFreeListEnd != curr) { | 57 while (kFreeListEnd != curr) { |
| 58 intptr_t next = reinterpret_cast<intptr_t>(fBuffers[SkToS32(curr)]); | 58 intptr_t next = reinterpret_cast<intptr_t>(fBuffers[SkToS32(curr)]); |
| 59 fBuffers[SkToS32(curr)] = NULL; | 59 fBuffers[SkToS32(curr)] = NULL; |
| 60 curr = next; | 60 curr = next; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * The global-to-thread state object for the null interface. All null interfaces
on the | 112 * The global-to-thread state object for the null interface. All null interfaces
on the |
| 113 * same thread currently share one of these. This means two null contexts on the
same thread | 113 * same thread currently share one of these. This means two null contexts on the
same thread |
| 114 * can interfere with each other. It may make sense to more integrate this into
SkNullGLContext | 114 * can interfere with each other. It may make sense to more integrate this into
SkNullGLContext |
| 115 * and use it's makeCurrent mechanism. | 115 * and use it's makeCurrent mechanism. |
| 116 */ | 116 */ |
| 117 struct ThreadContext { | 117 struct ThreadContext { |
| 118 public: | 118 public: |
| 119 SK_DECLARE_INST_COUNT_ROOT(ThreadContext); | 119 SK_DECLARE_INST_COUNT(ThreadContext); |
| 120 | 120 |
| 121 BufferManager fBufferManager; | 121 BufferManager fBufferManager; |
| 122 GrGLuint fCurrArrayBuffer; | 122 GrGLuint fCurrArrayBuffer; |
| 123 GrGLuint fCurrElementArrayBuffer; | 123 GrGLuint fCurrElementArrayBuffer; |
| 124 GrGLuint fCurrProgramID; | 124 GrGLuint fCurrProgramID; |
| 125 GrGLuint fCurrShaderID; | 125 GrGLuint fCurrShaderID; |
| 126 | 126 |
| 127 static ThreadContext* Get() { | 127 static ThreadContext* Get() { |
| 128 return reinterpret_cast<ThreadContext*>(SkTLS::Get(Create, Delete)); | 128 return reinterpret_cast<ThreadContext*>(SkTLS::Get(Create, Delete)); |
| 129 } | 129 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; | 476 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; |
| 477 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuf
fer; | 477 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuf
fer; |
| 478 functions->fMatrixLoadf = noOpGLMatrixLoadf; | 478 functions->fMatrixLoadf = noOpGLMatrixLoadf; |
| 479 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity; | 479 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity; |
| 480 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed; | 480 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed; |
| 481 | 481 |
| 482 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio
ns->fGetStringi, | 482 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio
ns->fGetStringi, |
| 483 functions->fGetIntegerv); | 483 functions->fGetIntegerv); |
| 484 return interface; | 484 return interface; |
| 485 } | 485 } |
| OLD | NEW |