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_ROOT(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 (NULL != fDataPtr) { | 24 if (fDataPtr) { |
25 SkASSERT(0 != fSize); | 25 SkASSERT(0 != fSize); |
26 SkDELETE_ARRAY(fDataPtr); | 26 SkDELETE_ARRAY(fDataPtr); |
27 } | 27 } |
28 | 28 |
29 fSize = size; | 29 fSize = size; |
30 fDataPtr = SkNEW_ARRAY(char, size); | 30 fDataPtr = SkNEW_ARRAY(char, size); |
31 } | 31 } |
32 | 32 |
33 GrGLuint id() const { return fID; } | 33 GrGLuint id() const { return fID; } |
34 GrGLchar* dataPtr() { return fDataPtr; } | 34 GrGLchar* dataPtr() { return fDataPtr; } |
(...skipping 23 matching lines...) Expand all Loading... |
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; |
61 } | 61 } |
62 | 62 |
63 fBuffers.deleteAll(); | 63 fBuffers.deleteAll(); |
64 } | 64 } |
65 | 65 |
66 BufferObj* lookUp(GrGLuint id) { | 66 BufferObj* lookUp(GrGLuint id) { |
67 BufferObj* buffer = fBuffers[id]; | 67 BufferObj* buffer = fBuffers[id]; |
68 SkASSERT(NULL != buffer && buffer->id() == id); | 68 SkASSERT(buffer && buffer->id() == id); |
69 return buffer; | 69 return buffer; |
70 } | 70 } |
71 | 71 |
72 BufferObj* create() { | 72 BufferObj* create() { |
73 GrGLuint id; | 73 GrGLuint id; |
74 BufferObj* buffer; | 74 BufferObj* buffer; |
75 | 75 |
76 if (kFreeListEnd == fFreeListHead) { | 76 if (kFreeListEnd == fFreeListHead) { |
77 // no free slots - create a new one | 77 // no free slots - create a new one |
78 id = fBuffers.count(); | 78 id = fBuffers.count(); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; | 473 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; |
474 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuf
fer; | 474 functions->fResolveMultisampleFramebuffer = noOpGLResolveMultisampleFramebuf
fer; |
475 functions->fMatrixLoadf = noOpGLMatrixLoadf; | 475 functions->fMatrixLoadf = noOpGLMatrixLoadf; |
476 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity; | 476 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity; |
477 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed; | 477 functions->fBindFragDataLocationIndexed = noOpGLBindFragDataLocationIndexed; |
478 | 478 |
479 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio
ns->fGetStringi, | 479 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio
ns->fGetStringi, |
480 functions->fGetIntegerv); | 480 functions->fGetIntegerv); |
481 return interface; | 481 return interface; |
482 } | 482 } |
OLD | NEW |