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

Side by Side Diff: src/gpu/effects/GrDashingEffect.cpp

Issue 858343002: Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits Created 5 years, 11 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/effects/GrDashingEffect.h ('k') | src/gpu/gl/GrGLGpu.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 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 #include "GrDashingEffect.h" 8 #include "GrDashingEffect.h"
9 9
10 #include "../GrAARectRenderer.h" 10 #include "../GrAARectRenderer.h"
(...skipping 10 matching lines...) Expand all
21 #include "SkGr.h" 21 #include "SkGr.h"
22 #include "gl/GrGLGeometryProcessor.h" 22 #include "gl/GrGLGeometryProcessor.h"
23 #include "gl/GrGLProcessor.h" 23 #include "gl/GrGLProcessor.h"
24 #include "gl/GrGLSL.h" 24 #include "gl/GrGLSL.h"
25 #include "gl/builders/GrGLProgramBuilder.h" 25 #include "gl/builders/GrGLProgramBuilder.h"
26 26
27 /////////////////////////////////////////////////////////////////////////////// 27 ///////////////////////////////////////////////////////////////////////////////
28 28
29 // Returns whether or not the gpu can fast path the dash line effect. 29 // Returns whether or not the gpu can fast path the dash line effect.
30 static bool can_fast_path_dash(const SkPoint pts[2], const GrStrokeInfo& strokeI nfo, 30 static bool can_fast_path_dash(const SkPoint pts[2], const GrStrokeInfo& strokeI nfo,
31 const GrDrawTarget& target, const GrDrawState& ds , 31 const GrDrawTarget& target, const GrPipelineBuild er& pipelineBuilder,
32 const SkMatrix& viewMatrix) { 32 const SkMatrix& viewMatrix) {
33 if (ds.getRenderTarget()->isMultisampled()) { 33 if (pipelineBuilder.getRenderTarget()->isMultisampled()) {
34 return false; 34 return false;
35 } 35 }
36 36
37 // Pts must be either horizontal or vertical in src space 37 // Pts must be either horizontal or vertical in src space
38 if (pts[0].fX != pts[1].fX && pts[0].fY != pts[1].fY) { 38 if (pts[0].fX != pts[1].fX && pts[0].fY != pts[1].fY) {
39 return false; 39 return false;
40 } 40 }
41 41
42 // May be able to relax this to include skew. As of now cannot do perspectiv e 42 // May be able to relax this to include skew. As of now cannot do perspectiv e
43 // because of the non uniform scaling of bloating a rect 43 // because of the non uniform scaling of bloating a rect
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m atrix, 158 static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m atrix,
159 SkPoint* verts) { 159 SkPoint* verts) {
160 verts[idx] = SkPoint::Make(rect.fLeft, rect.fTop); 160 verts[idx] = SkPoint::Make(rect.fLeft, rect.fTop);
161 verts[idx + 1] = SkPoint::Make(rect.fLeft, rect.fBottom); 161 verts[idx + 1] = SkPoint::Make(rect.fLeft, rect.fBottom);
162 verts[idx + 2] = SkPoint::Make(rect.fRight, rect.fBottom); 162 verts[idx + 2] = SkPoint::Make(rect.fRight, rect.fBottom);
163 verts[idx + 3] = SkPoint::Make(rect.fRight, rect.fTop); 163 verts[idx + 3] = SkPoint::Make(rect.fRight, rect.fTop);
164 matrix.mapPoints(&verts[idx], 4); 164 matrix.mapPoints(&verts[idx], 4);
165 } 165 }
166 166
167 bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, GrDrawState * drawState, 167 bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target,
168 GrColor color, const SkMatrix& viewMatrix, co nst SkPoint pts[2], 168 GrPipelineBuilder* pipelineBuilder, GrColor c olor,
169 const SkMatrix& viewMatrix, const SkPoint pts [2],
169 const GrPaint& paint, const GrStrokeInfo& str okeInfo) { 170 const GrPaint& paint, const GrStrokeInfo& str okeInfo) {
170 if (!can_fast_path_dash(pts, strokeInfo, *target, *drawState, viewMatrix)) { 171 if (!can_fast_path_dash(pts, strokeInfo, *target, *pipelineBuilder, viewMatr ix)) {
171 return false; 172 return false;
172 } 173 }
173 174
174 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); 175 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo();
175 176
176 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap(); 177 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap();
177 178
178 SkScalar srcStrokeWidth = strokeInfo.getStrokeRec().getWidth(); 179 SkScalar srcStrokeWidth = strokeInfo.getStrokeRec().getWidth();
179 180
180 // the phase should be normalized to be [0, sum of all intervals) 181 // the phase should be normalized to be [0, sum of all intervals)
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 devIntervals[0], halfDevStroke); 436 devIntervals[0], halfDevStroke);
436 } else { 437 } else {
437 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices()); 438 SkPoint* verts = reinterpret_cast<SkPoint*>(geo.vertices());
438 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); 439 SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
439 setup_dashed_rect_pos(endRect, curVIdx, combinedMatrix, verts); 440 setup_dashed_rect_pos(endRect, curVIdx, combinedMatrix, verts);
440 } 441 }
441 442
442 } 443 }
443 444
444 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer()); 445 target->setIndexSourceToBuffer(gpu->getContext()->getQuadIndexBuffer());
445 target->drawIndexedInstances(drawState, gp, kTriangles_GrPrimitiveType, tota lRectCnt, 4, 6); 446 target->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType ,
447 totalRectCnt, 4, 6);
446 target->resetIndexSource(); 448 target->resetIndexSource();
447 return true; 449 return true;
448 } 450 }
449 451
450 ////////////////////////////////////////////////////////////////////////////// 452 //////////////////////////////////////////////////////////////////////////////
451 453
452 class GLDashingCircleEffect; 454 class GLDashingCircleEffect;
453 455
454 struct DashingCircleBatchTracker { 456 struct DashingCircleBatchTracker {
455 GrGPInput fInputColorType; 457 GrGPInput fInputColorType;
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 return DashingCircleEffect::Create(color, edgeType, info, 1065 return DashingCircleEffect::Create(color, edgeType, info,
1064 SkScalarHalf(strokeWidth), 1066 SkScalarHalf(strokeWidth),
1065 localMatrix); 1067 localMatrix);
1066 case GrDashingEffect::kNonRound_DashCap: 1068 case GrDashingEffect::kNonRound_DashCap:
1067 return DashingLineEffect::Create(color, edgeType, info, strokeWidth, localMatrix); 1069 return DashingLineEffect::Create(color, edgeType, info, strokeWidth, localMatrix);
1068 default: 1070 default:
1069 SkFAIL("Unexpected dashed cap."); 1071 SkFAIL("Unexpected dashed cap.");
1070 } 1072 }
1071 return NULL; 1073 return NULL;
1072 } 1074 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDashingEffect.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698