Left: | ||
Right: |
OLD | NEW |
---|---|
1 // | 1 // |
2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. | 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 // | 5 // |
6 | 6 |
7 // Context.cpp: Implements the gl::Context class, managing all GL state and perf orming | 7 // Context.cpp: Implements the gl::Context class, managing all GL state and perf orming |
8 // rendering operations. It is the GLES2 specific implementation of EGLContext. | 8 // rendering operations. It is the GLES2 specific implementation of EGLContext. |
9 | 9 |
10 #include "libGLESv2/Context.h" | 10 #include "libGLESv2/Context.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "libGLESv2/Program.h" | 24 #include "libGLESv2/Program.h" |
25 #include "libGLESv2/RenderBuffer.h" | 25 #include "libGLESv2/RenderBuffer.h" |
26 #include "libGLESv2/Shader.h" | 26 #include "libGLESv2/Shader.h" |
27 #include "libGLESv2/Texture.h" | 27 #include "libGLESv2/Texture.h" |
28 #include "libGLESv2/VertexDataManager.h" | 28 #include "libGLESv2/VertexDataManager.h" |
29 #include "libGLESv2/IndexDataManager.h" | 29 #include "libGLESv2/IndexDataManager.h" |
30 | 30 |
31 #undef near | 31 #undef near |
32 #undef far | 32 #undef far |
33 | 33 |
34 namespace | |
35 { | |
36 enum { CLOSING_INDEX_BUFFER_SIZE = 4096 }; | |
37 } | |
38 | |
34 namespace gl | 39 namespace gl |
35 { | 40 { |
36 Context::Context(const egl::Config *config, const gl::Context *shareContext) : m Config(config) | 41 Context::Context(const egl::Config *config, const gl::Context *shareContext) : m Config(config) |
37 { | 42 { |
38 setClearColor(0.0f, 0.0f, 0.0f, 0.0f); | 43 setClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
39 | 44 |
40 mState.depthClearValue = 1.0f; | 45 mState.depthClearValue = 1.0f; |
41 mState.stencilClearValue = 0; | 46 mState.stencilClearValue = 0; |
42 | 47 |
43 mState.cullFace = false; | 48 mState.cullFace = false; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 bindRenderbuffer(0); | 137 bindRenderbuffer(0); |
133 | 138 |
134 mState.currentProgram = 0; | 139 mState.currentProgram = 0; |
135 | 140 |
136 mState.packAlignment = 4; | 141 mState.packAlignment = 4; |
137 mState.unpackAlignment = 4; | 142 mState.unpackAlignment = 4; |
138 | 143 |
139 mVertexDataManager = NULL; | 144 mVertexDataManager = NULL; |
140 mIndexDataManager = NULL; | 145 mIndexDataManager = NULL; |
141 mBlit = NULL; | 146 mBlit = NULL; |
147 mClosingIB = NULL; | |
142 | 148 |
143 mInvalidEnum = false; | 149 mInvalidEnum = false; |
144 mInvalidValue = false; | 150 mInvalidValue = false; |
145 mInvalidOperation = false; | 151 mInvalidOperation = false; |
146 mOutOfMemory = false; | 152 mOutOfMemory = false; |
147 mInvalidFramebufferOperation = false; | 153 mInvalidFramebufferOperation = false; |
148 | 154 |
149 mHasBeenCurrent = false; | 155 mHasBeenCurrent = false; |
150 | 156 |
151 mSupportsCompressedTextures = false; | 157 mSupportsCompressedTextures = false; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 mState.arrayBuffer.set(NULL); | 210 mState.arrayBuffer.set(NULL); |
205 mState.elementArrayBuffer.set(NULL); | 211 mState.elementArrayBuffer.set(NULL); |
206 mState.renderbuffer.set(NULL); | 212 mState.renderbuffer.set(NULL); |
207 | 213 |
208 mTexture2DZero.set(NULL); | 214 mTexture2DZero.set(NULL); |
209 mTextureCubeMapZero.set(NULL); | 215 mTextureCubeMapZero.set(NULL); |
210 | 216 |
211 delete mVertexDataManager; | 217 delete mVertexDataManager; |
212 delete mIndexDataManager; | 218 delete mIndexDataManager; |
213 delete mBlit; | 219 delete mBlit; |
220 delete mClosingIB; | |
214 | 221 |
215 if (mMaskedClearSavedState) | 222 if (mMaskedClearSavedState) |
216 { | 223 { |
217 mMaskedClearSavedState->Release(); | 224 mMaskedClearSavedState->Release(); |
218 } | 225 } |
219 | 226 |
220 mResourceManager->release(); | 227 mResourceManager->release(); |
221 } | 228 } |
222 | 229 |
223 void Context::makeCurrent(egl::Display *display, egl::Surface *surface) | 230 void Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
(...skipping 2519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2743 { | 2750 { |
2744 error(GL_OUT_OF_MEMORY); | 2751 error(GL_OUT_OF_MEMORY); |
2745 } | 2752 } |
2746 } | 2753 } |
2747 } | 2754 } |
2748 | 2755 |
2749 void Context::drawClosingLine(unsigned int first, unsigned int last) | 2756 void Context::drawClosingLine(unsigned int first, unsigned int last) |
2750 { | 2757 { |
2751 IDirect3DDevice9 *device = getDevice(); | 2758 IDirect3DDevice9 *device = getDevice(); |
2752 IDirect3DIndexBuffer9 *indexBuffer = NULL; | 2759 IDirect3DIndexBuffer9 *indexBuffer = NULL; |
2753 HRESULT result = D3DERR_INVALIDCALL; | 2760 bool succeeded = false; |
2761 UINT offset; | |
2754 | 2762 |
2755 if (supports32bitIndices()) | 2763 if (supports32bitIndices()) |
2756 { | 2764 { |
2757 result = device->CreateIndexBuffer(8, D3DUSAGE_WRITEONLY, D3DFMT_INDEX32 , D3DPOOL_DEFAULT, &indexBuffer, 0); | 2765 const int spaceNeeded = 2 * sizeof(int); |
dgkoch
2011/04/28 03:07:31
technically this should probably be "2 * sizeof(un
| |
2758 | 2766 |
2759 if (SUCCEEDED(result)) | 2767 if (!mClosingIB) |
2760 { | 2768 { |
2761 unsigned int *data; | 2769 mClosingIB = new StreamingIndexBuffer(device, CLOSING_INDEX_BUFFER_S IZE, D3DFMT_INDEX32); |
2762 result = indexBuffer->Lock(0, 0, (void**)&data, 0); | 2770 } |
2763 | 2771 |
2764 if (SUCCEEDED(result)) | 2772 mClosingIB->reserveSpace(spaceNeeded, GL_UNSIGNED_INT); |
2765 { | 2773 |
2766 data[0] = last; | 2774 unsigned int *data = static_cast<unsigned int*>(mClosingIB->map(spaceNee ded, &offset)); |
2767 data[1] = first; | 2775 if (data) |
2768 } | 2776 { |
2777 data[0] = last; | |
2778 data[1] = first; | |
2779 mClosingIB->unmap(); | |
2780 offset /= 4; | |
2781 succeeded = true; | |
2769 } | 2782 } |
2770 } | 2783 } |
2771 else | 2784 else |
2772 { | 2785 { |
2773 result = device->CreateIndexBuffer(4, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16 , D3DPOOL_DEFAULT, &indexBuffer, 0); | 2786 const int spaceNeeded = 2 * sizeof(short); |
dgkoch
2011/04/28 03:07:31
this should be "2 * sizeof (unsigned short)"
| |
2774 | 2787 |
2775 if (SUCCEEDED(result)) | 2788 if (!mClosingIB) |
2776 { | 2789 { |
2777 unsigned short *data; | 2790 mClosingIB = new StreamingIndexBuffer(device, CLOSING_INDEX_BUFFER_S IZE, D3DFMT_INDEX16); |
2778 result = indexBuffer->Lock(0, 0, (void**)&data, 0); | 2791 } |
2779 | 2792 |
2780 if (SUCCEEDED(result)) | 2793 mClosingIB->reserveSpace(spaceNeeded, GL_UNSIGNED_SHORT); |
2781 { | 2794 |
2782 data[0] = last; | 2795 unsigned short *data = static_cast<unsigned short*>(mClosingIB->map(spac eNeeded, &offset)); |
2783 data[1] = first; | 2796 if (data) |
2784 } | 2797 { |
2798 data[0] = last; | |
2799 data[1] = first; | |
2800 mClosingIB->unmap(); | |
2801 offset /= 2; | |
2802 succeeded = true; | |
2785 } | 2803 } |
2786 } | 2804 } |
2787 ···· | 2805 ···· |
2788 if (SUCCEEDED(result)) | 2806 if (succeeded) |
2789 { | 2807 { |
2790 indexBuffer->Unlock(); | 2808 device->SetIndices(mClosingIB->getBuffer()); |
2791 device->SetIndices(indexBuffer); | |
2792 | 2809 |
2793 device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, 2, 0, 1); | 2810 device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, 2, offset, 1); |
2794 | |
2795 indexBuffer->Release(); | |
2796 } | 2811 } |
2797 else | 2812 else |
2798 { | 2813 { |
2799 ERR("Could not create an index buffer for closing a line loop."); | 2814 ERR("Could not create an index buffer for closing a line loop."); |
2800 error(GL_OUT_OF_MEMORY); | 2815 error(GL_OUT_OF_MEMORY); |
2801 } | 2816 } |
2802 } | 2817 } |
2803 | 2818 |
2804 void Context::drawClosingLine(GLsizei count, GLenum type, const void *indices) | 2819 void Context::drawClosingLine(GLsizei count, GLenum type, const void *indices) |
2805 { | 2820 { |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3646 void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *su rface) | 3661 void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *su rface) |
3647 { | 3662 { |
3648 gl::makeCurrent(context, display, surface); | 3663 gl::makeCurrent(context, display, surface); |
3649 } | 3664 } |
3650 | 3665 |
3651 gl::Context *glGetCurrentContext() | 3666 gl::Context *glGetCurrentContext() |
3652 { | 3667 { |
3653 return gl::getContext(); | 3668 return gl::getContext(); |
3654 } | 3669 } |
3655 } | 3670 } |
OLD | NEW |