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" |
11 | 11 |
| 12 #include "effects/GrConfigConversionEffect.h" |
| 13 #include "effects/GrDashingEffect.h" |
12 #include "effects/GrSingleTextureEffect.h" | 14 #include "effects/GrSingleTextureEffect.h" |
13 #include "effects/GrConfigConversionEffect.h" | |
14 | 15 |
15 #include "GrAARectRenderer.h" | 16 #include "GrAARectRenderer.h" |
16 #include "GrBufferAllocPool.h" | 17 #include "GrBufferAllocPool.h" |
17 #include "GrGpu.h" | 18 #include "GrGpu.h" |
18 #include "GrDrawTargetCaps.h" | 19 #include "GrDrawTargetCaps.h" |
19 #include "GrIndexBuffer.h" | 20 #include "GrIndexBuffer.h" |
20 #include "GrInOrderDrawBuffer.h" | 21 #include "GrInOrderDrawBuffer.h" |
21 #include "GrLayerCache.h" | 22 #include "GrLayerCache.h" |
22 #include "GrOvalRenderer.h" | 23 #include "GrOvalRenderer.h" |
23 #include "GrPathRenderer.h" | 24 #include "GrPathRenderer.h" |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 const SkPoint positions[], | 965 const SkPoint positions[], |
965 const SkPoint texCoords[], | 966 const SkPoint texCoords[], |
966 const GrColor colors[], | 967 const GrColor colors[], |
967 const uint16_t indices[], | 968 const uint16_t indices[], |
968 int indexCount) { | 969 int indexCount) { |
969 AutoRestoreEffects are; | 970 AutoRestoreEffects are; |
970 AutoCheckFlush acf(this); | 971 AutoCheckFlush acf(this); |
971 GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scop
e | 972 GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scop
e |
972 | 973 |
973 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 974 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 975 GrDrawState* drawState = target->drawState(); |
974 | 976 |
975 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target); | 977 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target); |
976 | 978 |
977 GrDrawState* drawState = target->drawState(); | |
978 | |
979 int colorOffset = -1, texOffset = -1; | 979 int colorOffset = -1, texOffset = -1; |
980 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset
); | 980 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset
); |
981 | 981 |
982 size_t vertexSize = drawState->getVertexSize(); | 982 size_t vertexSize = drawState->getVertexSize(); |
983 if (sizeof(SkPoint) != vertexSize) { | 983 if (sizeof(SkPoint) != vertexSize) { |
984 if (!geo.set(target, vertexCount, 0)) { | 984 if (!geo.set(target, vertexCount, 0)) { |
985 GrPrintf("Failed to get space for vertices!\n"); | 985 GrPrintf("Failed to get space for vertices!\n"); |
986 return; | 986 return; |
987 } | 987 } |
988 void* curVertex = geo.vertices(); | 988 void* curVertex = geo.vertices(); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const GrStrok
eInfo& strokeInfo) { | 1161 void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const GrStrok
eInfo& strokeInfo) { |
1162 | 1162 |
1163 if (path.isEmpty()) { | 1163 if (path.isEmpty()) { |
1164 if (path.isInverseFillType()) { | 1164 if (path.isInverseFillType()) { |
1165 this->drawPaint(paint); | 1165 this->drawPaint(paint); |
1166 } | 1166 } |
1167 return; | 1167 return; |
1168 } | 1168 } |
1169 | 1169 |
1170 if (strokeInfo.isDashed()) { | 1170 if (strokeInfo.isDashed()) { |
| 1171 SkPoint pts[2]; |
| 1172 if (path.isLine(pts)) { |
| 1173 AutoRestoreEffects are; |
| 1174 AutoCheckFlush acf(this); |
| 1175 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &a
re, &acf); |
| 1176 GrDrawState* drawState = target->drawState(); |
| 1177 |
| 1178 SkMatrix origViewMatrix = drawState->getViewMatrix(); |
| 1179 GrDrawState::AutoViewMatrixRestore avmr; |
| 1180 if (avmr.setIdentity(target->drawState())) { |
| 1181 if (GrDashingEffect::DrawDashLine(pts, paint, strokeInfo, fGpu,
target, |
| 1182 origViewMatrix)) { |
| 1183 return; |
| 1184 } |
| 1185 } |
| 1186 } |
| 1187 |
| 1188 // Filter dashed path into new path with the dashing applied |
1171 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); | 1189 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); |
1172 SkTLazy<SkPath> effectPath; | 1190 SkTLazy<SkPath> effectPath; |
1173 GrStrokeInfo newStrokeInfo(strokeInfo, false); | 1191 GrStrokeInfo newStrokeInfo(strokeInfo, false); |
1174 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr(); | 1192 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr(); |
1175 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, in
fo)) { | 1193 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, in
fo)) { |
1176 this->drawPath(paint, *effectPath.get(), newStrokeInfo); | 1194 this->drawPath(paint, *effectPath.get(), newStrokeInfo); |
1177 return; | 1195 return; |
1178 } | 1196 } |
1179 | 1197 |
1180 this->drawPath(paint, path, newStrokeInfo); | 1198 this->drawPath(paint, path, newStrokeInfo); |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 SkSafeRef(resource); | 1903 SkSafeRef(resource); |
1886 return resource; | 1904 return resource; |
1887 } | 1905 } |
1888 | 1906 |
1889 /////////////////////////////////////////////////////////////////////////////// | 1907 /////////////////////////////////////////////////////////////////////////////// |
1890 #if GR_CACHE_STATS | 1908 #if GR_CACHE_STATS |
1891 void GrContext::printCacheStats() const { | 1909 void GrContext::printCacheStats() const { |
1892 fResourceCache->printStats(); | 1910 fResourceCache->printStats(); |
1893 } | 1911 } |
1894 #endif | 1912 #endif |
OLD | NEW |