| OLD | NEW |
| 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 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 | 846 |
| 847 GrDrawState::AutoViewMatrixRestore avmr; | 847 GrDrawState::AutoViewMatrixRestore avmr; |
| 848 if (NULL != matrix) { | 848 if (NULL != matrix) { |
| 849 GrDrawState* drawState = target->drawState(); | 849 GrDrawState* drawState = target->drawState(); |
| 850 avmr.set(drawState, *matrix); | 850 avmr.set(drawState, *matrix); |
| 851 } | 851 } |
| 852 | 852 |
| 853 target->drawNonIndexed(primType, 0, vertCount); | 853 target->drawNonIndexed(primType, 0, vertCount); |
| 854 } else { | 854 } else { |
| 855 // filled BW rect | 855 // filled BW rect |
| 856 #if GR_STATIC_RECT_VB | 856 target->drawSimpleRect(rect, matrix); |
| 857 const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer(); | |
| 858 if (NULL == sqVB) { | |
| 859 GrPrintf("Failed to create static rect vb.\n"); | |
| 860 return; | |
| 861 } | |
| 862 | |
| 863 GrDrawState* drawState = target->drawState(); | |
| 864 target->drawState()->setDefaultVertexAttribs(); | |
| 865 target->setVertexSourceToBuffer(sqVB); | |
| 866 SkMatrix m; | |
| 867 m.setAll(rect.width(), 0, rect.fLeft, | |
| 868 0, rect.height(), rect.fTop, | |
| 869 0, 0, SkMatrix::I()[8]); | |
| 870 | |
| 871 if (NULL != matrix) { | |
| 872 m.postConcat(*matrix); | |
| 873 } | |
| 874 GrDrawState::AutoViewMatrixRestore avmr(drawState, m); | |
| 875 | |
| 876 target->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4); | |
| 877 #else | |
| 878 target->drawSimpleRect(rect, matrix); | |
| 879 #endif | |
| 880 } | 857 } |
| 881 } | 858 } |
| 882 | 859 |
| 883 void GrContext::drawRectToRect(const GrPaint& paint, | 860 void GrContext::drawRectToRect(const GrPaint& paint, |
| 884 const GrRect& dstRect, | 861 const GrRect& dstRect, |
| 885 const GrRect& localRect, | 862 const GrRect& localRect, |
| 886 const SkMatrix* dstMatrix, | 863 const SkMatrix* dstMatrix, |
| 887 const SkMatrix* localMatrix) { | 864 const SkMatrix* localMatrix) { |
| 888 SK_TRACE_EVENT0("GrContext::drawRectToRect"); | 865 SK_TRACE_EVENT0("GrContext::drawRectToRect"); |
| 889 | 866 |
| 890 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); | 867 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); |
| 891 GrDrawState::AutoStageDisable atr(fDrawState); | 868 GrDrawState::AutoStageDisable atr(fDrawState); |
| 892 | 869 |
| 893 #if GR_STATIC_RECT_VB | |
| 894 GrDrawState* drawState = target->drawState(); | |
| 895 | |
| 896 SkMatrix m; | |
| 897 | |
| 898 m.setAll(dstRect.width(), 0, dstRect.fLeft, | |
| 899 0, dstRect.height(), dstRect.fTop, | |
| 900 0, 0, SkMatrix::I()[8]); | |
| 901 if (NULL != dstMatrix) { | |
| 902 m.postConcat(*dstMatrix); | |
| 903 } | |
| 904 | |
| 905 // This code path plays a little fast and loose with the notion of local coo
rds and coord | |
| 906 // change matrices in order to account for localRect and localMatrix. The un
it square VB only | |
| 907 // has one set of coords. Rather than using AutoViewMatrixRestore we instead
directly set concat | |
| 908 // with m and then call GrDrawState::localCoordChange() with a matrix that a
ccounts for | |
| 909 // localRect and localMatrix. This code path is preventing some encapsulatio
n in GrDrawState. | |
| 910 SkMatrix savedViewMatrix = drawState->getViewMatrix(); | |
| 911 drawState->preConcatViewMatrix(m); | |
| 912 | |
| 913 m.setAll(localRect.width(), 0, localRect.fLeft, | |
| 914 0, localRect.height(), localRect.fTop, | |
| 915 0, 0, SkMatrix::I()[8]); | |
| 916 if (NULL != localMatrix) { | |
| 917 m.postConcat(*localMatrix); | |
| 918 } | |
| 919 drawState->localCoordChange(m); | |
| 920 | |
| 921 const GrVertexBuffer* sqVB = fGpu->getUnitSquareVertexBuffer(); | |
| 922 if (NULL == sqVB) { | |
| 923 GrPrintf("Failed to create static rect vb.\n"); | |
| 924 return; | |
| 925 } | |
| 926 drawState->setDefaultVertexAttribs(); | |
| 927 target->setVertexSourceToBuffer(sqVB); | |
| 928 target->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4); | |
| 929 drawState->setViewMatrix(savedViewMatrix); | |
| 930 #else | |
| 931 target->drawRect(dstRect, dstMatrix, &localRect, localMatrix); | 870 target->drawRect(dstRect, dstMatrix, &localRect, localMatrix); |
| 932 #endif | |
| 933 } | 871 } |
| 934 | 872 |
| 935 void GrContext::drawVertices(const GrPaint& paint, | 873 void GrContext::drawVertices(const GrPaint& paint, |
| 936 GrPrimitiveType primitiveType, | 874 GrPrimitiveType primitiveType, |
| 937 int vertexCount, | 875 int vertexCount, |
| 938 const GrPoint positions[], | 876 const GrPoint positions[], |
| 939 const GrPoint texCoords[], | 877 const GrPoint texCoords[], |
| 940 const GrColor colors[], | 878 const GrColor colors[], |
| 941 const uint16_t indices[], | 879 const uint16_t indices[], |
| 942 int indexCount) { | 880 int indexCount) { |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 return srcTexture; | 1768 return srcTexture; |
| 1831 } | 1769 } |
| 1832 } | 1770 } |
| 1833 | 1771 |
| 1834 /////////////////////////////////////////////////////////////////////////////// | 1772 /////////////////////////////////////////////////////////////////////////////// |
| 1835 #if GR_CACHE_STATS | 1773 #if GR_CACHE_STATS |
| 1836 void GrContext::printCacheStats() const { | 1774 void GrContext::printCacheStats() const { |
| 1837 fTextureCache->printStats(); | 1775 fTextureCache->printStats(); |
| 1838 } | 1776 } |
| 1839 #endif | 1777 #endif |
| OLD | NEW |