Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 1227153003: Remove setFromPaint from GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrPipelineBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 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 #include "GrAARectRenderer.h" 9 #include "GrAARectRenderer.h"
10 #include "GrAtlasTextContext.h" 10 #include "GrAtlasTextContext.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 inverse.mapRect(&r); 180 inverse.mapRect(&r);
181 this->drawRect(rt, clip, *paint, viewMatrix, r); 181 this->drawRect(rt, clip, *paint, viewMatrix, r);
182 } else { 182 } else {
183 SkMatrix localMatrix; 183 SkMatrix localMatrix;
184 if (!viewMatrix.invert(&localMatrix)) { 184 if (!viewMatrix.invert(&localMatrix)) {
185 SkDebugf("Could not invert matrix\n"); 185 SkDebugf("Could not invert matrix\n");
186 return; 186 return;
187 } 187 }
188 188
189 AutoCheckFlush acf(fContext); 189 AutoCheckFlush acf(fContext);
190 GrPipelineBuilder pipelineBuilder; 190 if (!this->prepareToDraw(rt)) {
191 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, paint)) {
192 return; 191 return;
193 } 192 }
194 193
194 GrPipelineBuilder pipelineBuilder(*paint, rt, clip);
195 fDrawTarget->drawBWRect(&pipelineBuilder, 195 fDrawTarget->drawBWRect(&pipelineBuilder,
196 paint->getColor(), 196 paint->getColor(),
197 SkMatrix::I(), 197 SkMatrix::I(),
198 r, 198 r,
199 NULL, 199 NULL,
200 &localMatrix); 200 &localMatrix);
201 } 201 }
202 } 202 }
203 203
204 static inline bool is_irect(const SkRect& r) { 204 static inline bool is_irect(const SkRect& r) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 RETURN_IF_ABANDONED 428 RETURN_IF_ABANDONED
429 if (strokeInfo && strokeInfo->isDashed()) { 429 if (strokeInfo && strokeInfo->isDashed()) {
430 SkPath path; 430 SkPath path;
431 path.setIsVolatile(true); 431 path.setIsVolatile(true);
432 path.addRect(rect); 432 path.addRect(rect);
433 this->drawPath(rt, clip, paint, viewMatrix, path, *strokeInfo); 433 this->drawPath(rt, clip, paint, viewMatrix, path, *strokeInfo);
434 return; 434 return;
435 } 435 }
436 436
437 AutoCheckFlush acf(fContext); 437 AutoCheckFlush acf(fContext);
438 GrPipelineBuilder pipelineBuilder; 438 if (!this->prepareToDraw(rt)) {
439 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, &paint)) {
440 return; 439 return;
441 } 440 }
442 441
442 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
443
443 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getWidth(); 444 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getWidth();
444 445
445 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking 446 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking
446 // cases where the RT is fully inside a stroke. 447 // cases where the RT is fully inside a stroke.
447 if (width < 0) { 448 if (width < 0) {
448 SkRect rtRect; 449 SkRect rtRect;
449 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect); 450 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect);
450 SkRect clipSpaceRTRect = rtRect; 451 SkRect clipSpaceRTRect = rtRect;
451 bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType(); 452 bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType();
452 if (checkClip) { 453 if (checkClip) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 530
530 void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt, 531 void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt,
531 const GrClip& clip, 532 const GrClip& clip,
532 const GrPaint& paint, 533 const GrPaint& paint,
533 const SkMatrix& viewMatrix, 534 const SkMatrix& viewMatrix,
534 const SkRect& rectToDraw, 535 const SkRect& rectToDraw,
535 const SkRect& localRect, 536 const SkRect& localRect,
536 const SkMatrix* localMatrix) { 537 const SkMatrix* localMatrix) {
537 RETURN_IF_ABANDONED 538 RETURN_IF_ABANDONED
538 AutoCheckFlush acf(fContext); 539 AutoCheckFlush acf(fContext);
539 GrPipelineBuilder pipelineBuilder; 540 if (!this->prepareToDraw(rt)) {
540 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, &paint)) {
541 return; 541 return;
542 } 542 }
543 543
544 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
544 fDrawTarget->drawBWRect(&pipelineBuilder, 545 fDrawTarget->drawBWRect(&pipelineBuilder,
545 paint.getColor(), 546 paint.getColor(),
546 viewMatrix, 547 viewMatrix,
547 rectToDraw, 548 rectToDraw,
548 &localRect, 549 &localRect,
549 localMatrix); 550 localMatrix);
550 } 551 }
551 552
552 static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords, 553 static const GrGeometryProcessor* set_vertex_attributes(bool hasLocalCoords,
553 bool hasColors, 554 bool hasColors,
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 const SkMatrix& viewMatrix, 826 const SkMatrix& viewMatrix,
826 GrPrimitiveType primitiveType, 827 GrPrimitiveType primitiveType,
827 int vertexCount, 828 int vertexCount,
828 const SkPoint positions[], 829 const SkPoint positions[],
829 const SkPoint texCoords[], 830 const SkPoint texCoords[],
830 const GrColor colors[], 831 const GrColor colors[],
831 const uint16_t indices[], 832 const uint16_t indices[],
832 int indexCount) { 833 int indexCount) {
833 RETURN_IF_ABANDONED 834 RETURN_IF_ABANDONED
834 AutoCheckFlush acf(fContext); 835 AutoCheckFlush acf(fContext);
835 GrPipelineBuilder pipelineBuilder; 836 if (!this->prepareToDraw(rt)) {
836
837 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, &paint)) {
838 return; 837 return;
839 } 838 }
840 839
840 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
841
841 // TODO clients should give us bounds 842 // TODO clients should give us bounds
842 SkRect bounds; 843 SkRect bounds;
843 if (!bounds.setBoundsCheck(positions, vertexCount)) { 844 if (!bounds.setBoundsCheck(positions, vertexCount)) {
844 SkDebugf("drawVertices call empty bounds\n"); 845 SkDebugf("drawVertices call empty bounds\n");
845 return; 846 return;
846 } 847 }
847 848
848 viewMatrix.mapRect(&bounds); 849 viewMatrix.mapRect(&bounds);
849 850
850 // If we don't have AA then we outset for a half pixel in each direction to account for 851 // If we don't have AA then we outset for a half pixel in each direction to account for
(...skipping 27 matching lines...) Expand all
878 879
879 if (strokeInfo.isDashed()) { 880 if (strokeInfo.isDashed()) {
880 SkPath path; 881 SkPath path;
881 path.setIsVolatile(true); 882 path.setIsVolatile(true);
882 path.addRRect(rrect); 883 path.addRRect(rrect);
883 this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo); 884 this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo);
884 return; 885 return;
885 } 886 }
886 887
887 AutoCheckFlush acf(fContext); 888 AutoCheckFlush acf(fContext);
888 GrPipelineBuilder pipelineBuilder; 889 if (!this->prepareToDraw(rt)) {
889 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, &paint)) {
890 return; 890 return;
891 } 891 }
892 892
893 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
893 GrColor color = paint.getColor(); 894 GrColor color = paint.getColor();
894 if (!GrOvalRenderer::DrawRRect(fDrawTarget, 895 if (!GrOvalRenderer::DrawRRect(fDrawTarget,
895 &pipelineBuilder, 896 &pipelineBuilder,
896 color, 897 color,
897 viewMatrix, 898 viewMatrix,
898 paint.isAntiAlias(), 899 paint.isAntiAlias(),
899 rrect, 900 rrect,
900 strokeInfo)) { 901 strokeInfo)) {
901 SkPath path; 902 SkPath path;
902 path.setIsVolatile(true); 903 path.setIsVolatile(true);
(...skipping 10 matching lines...) Expand all
913 const GrPaint& paint, 914 const GrPaint& paint,
914 const SkMatrix& viewMatrix, 915 const SkMatrix& viewMatrix,
915 const SkRRect& outer, 916 const SkRRect& outer,
916 const SkRRect& inner) { 917 const SkRRect& inner) {
917 RETURN_IF_ABANDONED 918 RETURN_IF_ABANDONED
918 if (outer.isEmpty()) { 919 if (outer.isEmpty()) {
919 return; 920 return;
920 } 921 }
921 922
922 AutoCheckFlush acf(fContext); 923 AutoCheckFlush acf(fContext);
923 GrPipelineBuilder pipelineBuilder; 924 if (!this->prepareToDraw(rt)) {
924 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, &paint)) {
925 return; 925 return;
926 } 926 }
927 927
928 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
928 GrColor color = paint.getColor(); 929 GrColor color = paint.getColor();
929 if (!GrOvalRenderer::DrawDRRect(fDrawTarget, 930 if (!GrOvalRenderer::DrawDRRect(fDrawTarget,
930 &pipelineBuilder, 931 &pipelineBuilder,
931 color, 932 color,
932 viewMatrix, 933 viewMatrix,
933 paint.isAntiAlias(), 934 paint.isAntiAlias(),
934 outer, 935 outer,
935 inner)) { 936 inner)) {
936 SkPath path; 937 SkPath path;
937 path.setIsVolatile(true); 938 path.setIsVolatile(true);
(...skipping 22 matching lines...) Expand all
960 961
961 if (strokeInfo.isDashed()) { 962 if (strokeInfo.isDashed()) {
962 SkPath path; 963 SkPath path;
963 path.setIsVolatile(true); 964 path.setIsVolatile(true);
964 path.addOval(oval); 965 path.addOval(oval);
965 this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo); 966 this->drawPath(rt, clip, paint, viewMatrix, path, strokeInfo);
966 return; 967 return;
967 } 968 }
968 969
969 AutoCheckFlush acf(fContext); 970 AutoCheckFlush acf(fContext);
970 GrPipelineBuilder pipelineBuilder; 971 if (!this->prepareToDraw(rt)) {
971 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, &paint)) {
972 return; 972 return;
973 } 973 }
974 974
975 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
975 GrColor color = paint.getColor(); 976 GrColor color = paint.getColor();
976 if (!GrOvalRenderer::DrawOval(fDrawTarget, 977 if (!GrOvalRenderer::DrawOval(fDrawTarget,
977 &pipelineBuilder, 978 &pipelineBuilder,
978 color, 979 color,
979 viewMatrix, 980 viewMatrix,
980 paint.isAntiAlias(), 981 paint.isAntiAlias(),
981 oval, 982 oval,
982 strokeInfo)) { 983 strokeInfo)) {
983 SkPath path; 984 SkPath path;
984 path.setIsVolatile(true); 985 path.setIsVolatile(true);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 } 1057 }
1057 1058
1058 GrColor color = paint.getColor(); 1059 GrColor color = paint.getColor();
1059 1060
1060 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 1061 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
1061 // Scratch textures can be recycled after they are returned to the texture 1062 // Scratch textures can be recycled after they are returned to the texture
1062 // cache. This presents a potential hazard for buffered drawing. However, 1063 // cache. This presents a potential hazard for buffered drawing. However,
1063 // the writePixels that uploads to the scratch will perform a flush so we're 1064 // the writePixels that uploads to the scratch will perform a flush so we're
1064 // OK. 1065 // OK.
1065 AutoCheckFlush acf(fContext); 1066 AutoCheckFlush acf(fContext);
1066 GrPipelineBuilder pipelineBuilder; 1067 if (!this->prepareToDraw(rt)) {
1067 if (!this->prepareToDraw(&pipelineBuilder, rt, clip, &paint)) {
1068 return; 1068 return;
1069 } 1069 }
1070 1070
1071 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
1071 if (!strokeInfo.isDashed()) { 1072 if (!strokeInfo.isDashed()) {
1072 bool useCoverageAA = paint.isAntiAlias() && 1073 bool useCoverageAA = paint.isAntiAlias() &&
1073 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); 1074 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
1074 1075
1075 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) { 1076 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) {
1076 // Concave AA paths are expensive - try to avoid them for special ca ses 1077 // Concave AA paths are expensive - try to avoid them for special ca ses
1077 SkRect rects[2]; 1078 SkRect rects[2];
1078 1079
1079 if (is_nested_rects(fDrawTarget, &pipelineBuilder, color, viewMatrix , path, strokeInfo, 1080 if (is_nested_rects(fDrawTarget, &pipelineBuilder, color, viewMatrix , path, strokeInfo,
1080 rects)) { 1081 rects)) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 if (NULL == pr) { 1176 if (NULL == pr) {
1176 #ifdef SK_DEBUG 1177 #ifdef SK_DEBUG
1177 SkDebugf("Unable to find path renderer compatible with path.\n"); 1178 SkDebugf("Unable to find path renderer compatible with path.\n");
1178 #endif 1179 #endif
1179 return; 1180 return;
1180 } 1181 }
1181 1182
1182 pr->drawPath(target, pipelineBuilder, color, viewMatrix, *pathPtr, *strokeIn foPtr, useCoverageAA); 1183 pr->drawPath(target, pipelineBuilder, color, viewMatrix, *pathPtr, *strokeIn foPtr, useCoverageAA);
1183 } 1184 }
1184 1185
1185 bool GrDrawContext::prepareToDraw(GrPipelineBuilder* pipelineBuilder,
1186 GrRenderTarget* rt,
1187 const GrClip& clip,
1188 const GrPaint* paint) {
1189 RETURN_FALSE_IF_ABANDONED
1190
1191 ASSERT_OWNED_RESOURCE(rt);
1192 SkASSERT(rt && paint);
1193 pipelineBuilder->setFromPaint(*paint, rt, clip);
1194 return true;
1195 }
1196
1197 bool GrDrawContext::prepareToDraw(GrRenderTarget* rt) { 1186 bool GrDrawContext::prepareToDraw(GrRenderTarget* rt) {
1198 RETURN_FALSE_IF_ABANDONED 1187 RETURN_FALSE_IF_ABANDONED
1199 1188
1200 ASSERT_OWNED_RESOURCE(rt); 1189 ASSERT_OWNED_RESOURCE(rt);
1201 SkASSERT(rt); 1190 SkASSERT(rt);
1202 return true; 1191 return true;
1203 } 1192 }
1204 1193
1205 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch ) { 1194 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch ) {
1206 fDrawTarget->drawBatch(pipelineBuilder, batch); 1195 fDrawTarget->drawBatch(pipelineBuilder, batch);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 return DrawVerticesBatch::Create(geometry, type, viewMatrix, 1315 return DrawVerticesBatch::Create(geometry, type, viewMatrix,
1327 positions.begin(), vertexCount, 1316 positions.begin(), vertexCount,
1328 indices.begin(), hasIndices ? vertexCount : 0, 1317 indices.begin(), hasIndices ? vertexCount : 0,
1329 colors.begin(), 1318 colors.begin(),
1330 texCoords.begin(), 1319 texCoords.begin(),
1331 bounds); 1320 bounds);
1332 } 1321 }
1333 1322
1334 #endif 1323 #endif
1335 1324
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrPipelineBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698