| 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 "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
| 10 #include "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
| 11 #include "GrGLTextureRenderTarget.h" | 11 #include "GrGLTextureRenderTarget.h" |
| 12 #include "GrGpuResourcePriv.h" | 12 #include "GrGpuResourcePriv.h" |
| 13 #include "GrPipeline.h" | 13 #include "GrPipeline.h" |
| 14 #include "GrRenderTargetPriv.h" | 14 #include "GrRenderTargetPriv.h" |
| 15 #include "GrSurfacePriv.h" | 15 #include "GrSurfacePriv.h" |
| 16 #include "GrTemplates.h" | 16 #include "GrTemplates.h" |
| 17 #include "GrTexturePriv.h" | 17 #include "GrTexturePriv.h" |
| 18 #include "GrTypes.h" | 18 #include "GrTypes.h" |
| 19 #include "GrVertices.h" |
| 19 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
| 20 #include "SkTemplates.h" | 21 #include "SkTemplates.h" |
| 21 | 22 |
| 22 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) | 23 #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) |
| 23 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) | 24 #define GL_CALL_RET(RET, X) GR_GL_CALL_RET(this->glInterface(), RET, X) |
| 24 | 25 |
| 25 #define SKIP_CACHE_CHECK true | 26 #define SKIP_CACHE_CHECK true |
| 26 | 27 |
| 27 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR | 28 #if GR_GL_CHECK_ALLOC_WITH_GET_ERROR |
| 28 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) | 29 #define CLEAR_ERROR_BEFORE_ALLOC(iface) GrGLClearErr(iface) |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); | 1402 this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); |
| 1402 | 1403 |
| 1403 // This must come after textures are flushed because a texture may need | 1404 // This must come after textures are flushed because a texture may need |
| 1404 // to be msaa-resolved (which will modify bound FBO state). | 1405 // to be msaa-resolved (which will modify bound FBO state). |
| 1405 this->flushRenderTarget(glRT, NULL); | 1406 this->flushRenderTarget(glRT, NULL); |
| 1406 | 1407 |
| 1407 return true; | 1408 return true; |
| 1408 } | 1409 } |
| 1409 | 1410 |
| 1410 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, | 1411 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, |
| 1411 const GrDrawTarget::DrawInfo& info, | 1412 const GrVertices& info, |
| 1412 size_t* indexOffsetInBytes) { | 1413 size_t* indexOffsetInBytes) { |
| 1413 GrGLVertexBuffer* vbuf; | 1414 GrGLVertexBuffer* vbuf; |
| 1414 vbuf = (GrGLVertexBuffer*) info.vertexBuffer(); | 1415 vbuf = (GrGLVertexBuffer*) info.vertexBuffer(); |
| 1415 | 1416 |
| 1416 SkASSERT(vbuf); | 1417 SkASSERT(vbuf); |
| 1417 SkASSERT(!vbuf->isMapped()); | 1418 SkASSERT(!vbuf->isMapped()); |
| 1418 | 1419 |
| 1419 GrGLIndexBuffer* ibuf = NULL; | 1420 GrGLIndexBuffer* ibuf = NULL; |
| 1420 if (info.isIndexed()) { | 1421 if (info.isIndexed()) { |
| 1421 SkASSERT(indexOffsetInBytes); | 1422 SkASSERT(indexOffsetInBytes); |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 GetWindowThreadProcessId(hwnd, &wndProcID); | 1845 GetWindowThreadProcessId(hwnd, &wndProcID); |
| 1845 if(wndProcID == procID) { | 1846 if(wndProcID == procID) { |
| 1846 SwapBuffers(GetDC(hwnd)); | 1847 SwapBuffers(GetDC(hwnd)); |
| 1847 } | 1848 } |
| 1848 hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); | 1849 hwnd = GetNextWindow(hwnd, GW_HWNDNEXT); |
| 1849 } | 1850 } |
| 1850 } | 1851 } |
| 1851 #endif | 1852 #endif |
| 1852 #endif | 1853 #endif |
| 1853 | 1854 |
| 1854 void GrGLGpu::onDraw(const DrawArgs& args, const GrDrawTarget::DrawInfo& info) { | 1855 void GrGLGpu::onDraw(const DrawArgs& args, const GrVertices& vertices) { |
| 1855 if (!this->flushGLState(args)) { | 1856 if (!this->flushGLState(args)) { |
| 1856 return; | 1857 return; |
| 1857 } | 1858 } |
| 1858 | 1859 |
| 1859 size_t indexOffsetInBytes = 0; | 1860 size_t indexOffsetInBytes = 0; |
| 1860 this->setupGeometry(*args.fPrimitiveProcessor, info, &indexOffsetInBytes); | 1861 this->setupGeometry(*args.fPrimitiveProcessor, vertices, &indexOffsetInBytes
); |
| 1861 | 1862 |
| 1862 SkASSERT((size_t)info.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GLMode
)); | 1863 SkASSERT((size_t)vertices.primitiveType() < SK_ARRAY_COUNT(gPrimitiveType2GL
Mode)); |
| 1863 | 1864 |
| 1864 if (info.isIndexed()) { | 1865 if (vertices.isIndexed()) { |
| 1865 GrGLvoid* indices = | 1866 GrGLvoid* indices = |
| 1866 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) *
info.startIndex()); | 1867 reinterpret_cast<GrGLvoid*>(indexOffsetInBytes + sizeof(uint16_t) * |
| 1868 vertices.startIndex()); |
| 1867 // info.startVertex() was accounted for by setupGeometry. | 1869 // info.startVertex() was accounted for by setupGeometry. |
| 1868 GL_CALL(DrawElements(gPrimitiveType2GLMode[info.primitiveType()], | 1870 GL_CALL(DrawElements(gPrimitiveType2GLMode[vertices.primitiveType()], |
| 1869 info.indexCount(), | 1871 vertices.indexCount(), |
| 1870 GR_GL_UNSIGNED_SHORT, | 1872 GR_GL_UNSIGNED_SHORT, |
| 1871 indices)); | 1873 indices)); |
| 1872 } else { | 1874 } else { |
| 1873 // Pass 0 for parameter first. We have to adjust glVertexAttribPointer()
to account for | 1875 // Pass 0 for parameter first. We have to adjust glVertexAttribPointer()
to account for |
| 1874 // startVertex in the DrawElements case. So we always rely on setupGeome
try to have | 1876 // startVertex in the DrawElements case. So we always rely on setupGeome
try to have |
| 1875 // accounted for startVertex. | 1877 // accounted for startVertex. |
| 1876 GL_CALL(DrawArrays(gPrimitiveType2GLMode[info.primitiveType()], 0, info.
vertexCount())); | 1878 GL_CALL(DrawArrays(gPrimitiveType2GLMode[vertices.primitiveType()], 0, |
| 1879 vertices.vertexCount())); |
| 1877 } | 1880 } |
| 1878 #if SWAP_PER_DRAW | 1881 #if SWAP_PER_DRAW |
| 1879 glFlush(); | 1882 glFlush(); |
| 1880 #if defined(SK_BUILD_FOR_MAC) | 1883 #if defined(SK_BUILD_FOR_MAC) |
| 1881 aglSwapBuffers(aglGetCurrentContext()); | 1884 aglSwapBuffers(aglGetCurrentContext()); |
| 1882 int set_a_break_pt_here = 9; | 1885 int set_a_break_pt_here = 9; |
| 1883 aglSwapBuffers(aglGetCurrentContext()); | 1886 aglSwapBuffers(aglGetCurrentContext()); |
| 1884 #elif defined(SK_BUILD_FOR_WIN32) | 1887 #elif defined(SK_BUILD_FOR_WIN32) |
| 1885 SwapBuf(); | 1888 SwapBuf(); |
| 1886 int set_a_break_pt_here = 9; | 1889 int set_a_break_pt_here = 9; |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2784 this->setVertexArrayID(gpu, 0); | 2787 this->setVertexArrayID(gpu, 0); |
| 2785 } | 2788 } |
| 2786 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2789 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2787 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2790 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2788 fDefaultVertexArrayAttribState.resize(attrCount); | 2791 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2789 } | 2792 } |
| 2790 attribState = &fDefaultVertexArrayAttribState; | 2793 attribState = &fDefaultVertexArrayAttribState; |
| 2791 } | 2794 } |
| 2792 return attribState; | 2795 return attribState; |
| 2793 } | 2796 } |
| OLD | NEW |