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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 drawState->setRenderTarget(texture->asRenderTarget()); | 347 drawState->setRenderTarget(texture->asRenderTarget()); |
348 | 348 |
349 // if filtering is not desired then we want to ensure all | 349 // if filtering is not desired then we want to ensure all |
350 // texels in the resampled image are copies of texels from | 350 // texels in the resampled image are copies of texels from |
351 // the original. | 351 // the original. |
352 GrTextureParams params(SkShader::kClamp_TileMode, needsFiltering); | 352 GrTextureParams params(SkShader::kClamp_TileMode, needsFiltering); |
353 drawState->createTextureEffect(0, clampedTexture, SkMatrix::I(), params) ; | 353 drawState->createTextureEffect(0, clampedTexture, SkMatrix::I(), params) ; |
354 | 354 |
355 // position + texture coordinate | 355 // position + texture coordinate |
356 static const GrVertexAttrib kVertexAttribs[] = { | 356 static const GrVertexAttrib kVertexAttribs[] = { |
357 GrVertexAttrib(kVec2f_GrVertexAttribType, 0), | 357 {kVec2f_GrVertexAttribType, 0}, |
358 GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint)) | 358 {kVec2f_GrVertexAttribType, sizeof(GrPoint)} |
359 }; | 359 }; |
360 static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTex CoordAttribBindingsBit(0); | 360 static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTex CoordAttribBindingsBit(0); |
361 drawState->setAttribBindings(kAttribBindings); | 361 drawState->setAttribBindings(kAttribBindings); |
362 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttrib s)); | 362 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttrib s)); |
363 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); | 363 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); |
364 drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, 1); | 364 drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, 1); |
365 GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0); | 365 GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0); |
366 | 366 |
367 if (arg.succeeded()) { | 367 if (arg.succeeded()) { |
368 GrPoint* verts = (GrPoint*) arg.vertices(); | 368 GrPoint* verts = (GrPoint*) arg.vertices(); |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 | 922 |
923 GrDrawState* drawState = target->drawState(); | 923 GrDrawState* drawState = target->drawState(); |
924 | 924 |
925 GrVertexAttribArray<3> attribs; | 925 GrVertexAttribArray<3> attribs; |
926 size_t currentOffset = 0; | 926 size_t currentOffset = 0; |
927 int colorOffset = -1, texOffset = -1; | 927 int colorOffset = -1, texOffset = -1; |
928 GrAttribBindings bindings = GrDrawState::kDefault_AttribBindings; | 928 GrAttribBindings bindings = GrDrawState::kDefault_AttribBindings; |
929 | 929 |
930 // set position attribute | 930 // set position attribute |
931 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count( )); | 931 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count( )); |
932 attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset)); | 932 GrVertexAttrib currAttrib = {kVec2f_GrVertexAttribType, currentOffset}; |
933 attribs.push_back(currAttrib); | |
bsalomon
2013/03/01 19:55:39
No need to change but just FYI, this would work:
| |
933 currentOffset += sizeof(GrPoint); | 934 currentOffset += sizeof(GrPoint); |
934 | 935 |
935 // set up optional texture coordinate attributes | 936 // set up optional texture coordinate attributes |
936 if (NULL != texCoords) { | 937 if (NULL != texCoords) { |
937 bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(0); | 938 bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(0); |
938 drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.co unt()); | 939 drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.co unt()); |
939 attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffse t)); | 940 currAttrib.set(kVec2f_GrVertexAttribType, currentOffset); |
941 attribs.push_back(currAttrib); | |
940 texOffset = currentOffset; | 942 texOffset = currentOffset; |
941 currentOffset += sizeof(GrPoint); | 943 currentOffset += sizeof(GrPoint); |
942 } | 944 } |
943 | 945 |
944 // set up optional color attributes | 946 // set up optional color attributes |
945 if (NULL != colors) { | 947 if (NULL != colors) { |
946 bindings |= GrDrawState::kColor_AttribBindingsBit; | 948 bindings |= GrDrawState::kColor_AttribBindingsBit; |
947 drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count ()); | 949 drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count ()); |
948 attribs.push_back(GrVertexAttrib(kVec4ub_GrVertexAttribType, currentOffs et)); | 950 currAttrib.set(kVec4ub_GrVertexAttribType, currentOffset); |
951 attribs.push_back(currAttrib); | |
949 colorOffset = currentOffset; | 952 colorOffset = currentOffset; |
950 currentOffset += sizeof(GrColor); | 953 currentOffset += sizeof(GrColor); |
951 } | 954 } |
952 | 955 |
953 drawState->setVertexAttribs(attribs.begin(), attribs.count()); | 956 drawState->setVertexAttribs(attribs.begin(), attribs.count()); |
954 drawState->setAttribBindings(bindings); | 957 drawState->setAttribBindings(bindings); |
955 | 958 |
956 size_t vertexSize = drawState->getVertexSize(); | 959 size_t vertexSize = drawState->getVertexSize(); |
957 GrAssert(vertexSize == currentOffset); | 960 GrAssert(vertexSize == currentOffset); |
958 if (sizeof(GrPoint) != vertexSize) { | 961 if (sizeof(GrPoint) != vertexSize) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1066 return; | 1069 return; |
1067 } | 1070 } |
1068 | 1071 |
1069 GrDrawState::AutoDeviceCoordDraw adcd(drawState); | 1072 GrDrawState::AutoDeviceCoordDraw adcd(drawState); |
1070 if (!adcd.succeeded()) { | 1073 if (!adcd.succeeded()) { |
1071 return; | 1074 return; |
1072 } | 1075 } |
1073 | 1076 |
1074 // position + edge | 1077 // position + edge |
1075 static const GrVertexAttrib kVertexAttribs[] = { | 1078 static const GrVertexAttrib kVertexAttribs[] = { |
1076 GrVertexAttrib(kVec2f_GrVertexAttribType, 0), | 1079 {kVec2f_GrVertexAttribType, 0}, |
1077 GrVertexAttrib(kVec4f_GrVertexAttribType, sizeof(GrPoint)) | 1080 {kVec4f_GrVertexAttribType, sizeof(GrPoint)} |
1078 }; | 1081 }; |
1079 static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_Attrib BindingsBit; | 1082 static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_Attrib BindingsBit; |
1080 | 1083 |
1081 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); | 1084 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); |
1082 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); | 1085 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); |
1083 drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); | 1086 drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); |
1084 drawState->setAttribBindings(kAttributeBindings); | 1087 drawState->setAttribBindings(kAttributeBindings); |
1085 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); | 1088 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); |
1086 | 1089 |
1087 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 1090 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1978 return srcTexture; | 1981 return srcTexture; |
1979 } | 1982 } |
1980 } | 1983 } |
1981 | 1984 |
1982 /////////////////////////////////////////////////////////////////////////////// | 1985 /////////////////////////////////////////////////////////////////////////////// |
1983 #if GR_CACHE_STATS | 1986 #if GR_CACHE_STATS |
1984 void GrContext::printCacheStats() const { | 1987 void GrContext::printCacheStats() const { |
1985 fTextureCache->printStats(); | 1988 fTextureCache->printStats(); |
1986 } | 1989 } |
1987 #endif | 1990 #endif |
OLD | NEW |