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

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

Issue 292773002: Pass in GrContext instead of SkGpuDevice for dashing and Sk2GrPaint conversion (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nit variable name Created 6 years, 7 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') | no next file » | 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 "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
11 #include "gl/GrGLSL.h" 11 #include "gl/GrGLSL.h"
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrCoordTransform.h" 13 #include "GrCoordTransform.h"
14 #include "GrDrawTargetCaps.h" 14 #include "GrDrawTargetCaps.h"
15 #include "GrEffect.h" 15 #include "GrEffect.h"
16 #include "GrTBackendEffectFactory.h" 16 #include "GrTBackendEffectFactory.h"
17 #include "SkGpuDevice.h"
18 #include "SkGr.h" 17 #include "SkGr.h"
19 18
20 /////////////////////////////////////////////////////////////////////////////// 19 ///////////////////////////////////////////////////////////////////////////////
21 20
22 static void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale, 21 static void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale,
23 const SkMatrix& viewMatrix, const SkPoint pts[2]) { 22 const SkMatrix& viewMatrix, const SkPoint pts[2]) {
24 SkVector vecSrc = pts[1] - pts[0]; 23 SkVector vecSrc = pts[1] - pts[0];
25 SkScalar magSrc = vecSrc.length(); 24 SkScalar magSrc = vecSrc.length();
26 SkScalar invSrc = magSrc ? SkScalarInvert(magSrc) : 0; 25 SkScalar invSrc = magSrc ? SkScalarInvert(magSrc) : 0;
27 vecSrc.scale(invSrc); 26 vecSrc.scale(invSrc);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (*endingInt > info.fIntervals[0]) { 79 if (*endingInt > info.fIntervals[0]) {
81 if (0 == info.fIntervals[0]) { 80 if (0 == info.fIntervals[0]) {
82 *endingInt -= 0.01f; // make sure we capture the last zero size pnt (used if has caps) 81 *endingInt -= 0.01f; // make sure we capture the last zero size pnt (used if has caps)
83 } 82 }
84 return *endingInt - info.fIntervals[0]; 83 return *endingInt - info.fIntervals[0];
85 } 84 }
86 return 0; 85 return 0;
87 } 86 }
88 87
89 88
90 bool GrDashingEffect::DrawDashLine(const SkPoint pts[2], const SkPaint& paint, S kGpuDevice* dev) { 89 bool GrDashingEffect::DrawDashLine(const SkPoint pts[2], const SkPaint& paint, G rContext* context) {
91 GrContext* context = dev->context();
92 if (context->getRenderTarget()->isMultisampled()) { 90 if (context->getRenderTarget()->isMultisampled()) {
93 return false; 91 return false;
94 } 92 }
95 93
96 const SkMatrix& viewMatrix = context->getMatrix(); 94 const SkMatrix& viewMatrix = context->getMatrix();
97 if (!viewMatrix.preservesRightAngles()) { 95 if (!viewMatrix.preservesRightAngles()) {
98 return false; 96 return false;
99 } 97 }
100 98
101 const SkPathEffect* pe = paint.getPathEffect(); 99 const SkPathEffect* pe = paint.getPathEffect();
(...skipping 30 matching lines...) Expand all
132 if(!coordTrans.invert(&srcRotInv)) { 130 if(!coordTrans.invert(&srcRotInv)) {
133 return false; 131 return false;
134 } 132 }
135 } else { 133 } else {
136 coordTrans.reset(); 134 coordTrans.reset();
137 srcRotInv.reset(); 135 srcRotInv.reset();
138 memcpy(ptsRot, pts, 2 * sizeof(SkPoint)); 136 memcpy(ptsRot, pts, 2 * sizeof(SkPoint));
139 } 137 }
140 138
141 GrPaint grPaint; 139 GrPaint grPaint;
142 SkPaint2GrPaintShader(dev, paint, true, &grPaint); 140 SkPaint2GrPaintShader(context, paint, true, &grPaint);
143 141
144 bool useAA = paint.isAntiAlias(); 142 bool useAA = paint.isAntiAlias();
145 143
146 // Scale corrections of intervals and stroke from view matrix 144 // Scale corrections of intervals and stroke from view matrix
147 SkScalar parallelScale; 145 SkScalar parallelScale;
148 SkScalar perpScale; 146 SkScalar perpScale;
149 calc_dash_scaling(&parallelScale, &perpScale, viewMatrix, ptsRot); 147 calc_dash_scaling(&parallelScale, &perpScale, viewMatrix, ptsRot);
150 148
151 bool hasCap = SkPaint::kSquare_Cap == cap && 0 != srcStrokeWidth; 149 bool hasCap = SkPaint::kSquare_Cap == cap && 0 != srcStrokeWidth;
152 150
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 effect = DashingLineEffect::Create(edgeType, info, m, strokeWidth); 486 effect = DashingLineEffect::Create(edgeType, info, m, strokeWidth);
489 return effect; 487 return effect;
490 } 488 }
491 489
492 ////////////////////////////////////////////////////////////////////////////// 490 //////////////////////////////////////////////////////////////////////////////
493 491
494 GrEffectRef* GrDashingEffect::Create(GrEffectEdgeType edgeType, const SkPathEffe ct::DashInfo& info, 492 GrEffectRef* GrDashingEffect::Create(GrEffectEdgeType edgeType, const SkPathEffe ct::DashInfo& info,
495 const SkMatrix& matrix, SkScalar strokeWidt h) { 493 const SkMatrix& matrix, SkScalar strokeWidt h) {
496 return DashingLineEffect::Create(edgeType, info, matrix, strokeWidth); 494 return DashingLineEffect::Create(edgeType, info, matrix, strokeWidth);
497 } 495 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDashingEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698