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

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

Issue 1128113008: Make GrStrokeInfo inherit from SkStrokeRec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address review comments Created 5 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/SkGpuDevice.cpp ('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 "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 if (!strokeInfo.isDashed() || 2 != strokeInfo.getDashCount()) { 45 if (!strokeInfo.isDashed() || 2 != strokeInfo.getDashCount()) {
46 return false; 46 return false;
47 } 47 }
48 48
49 const SkScalar* intervals = strokeInfo.getDashIntervals(); 49 const SkScalar* intervals = strokeInfo.getDashIntervals();
50 if (0 == intervals[0] && 0 == intervals[1]) { 50 if (0 == intervals[0] && 0 == intervals[1]) {
51 return false; 51 return false;
52 } 52 }
53 53
54 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap(); 54 SkPaint::Cap cap = strokeInfo.getCap();
55 // Current we do don't handle Round or Square cap dashes 55 // Current we do don't handle Round or Square cap dashes
56 if (SkPaint::kRound_Cap == cap && intervals[0] != 0.f) { 56 if (SkPaint::kRound_Cap == cap && intervals[0] != 0.f) {
57 return false; 57 return false;
58 } 58 }
59 59
60 return true; 60 return true;
61 } 61 }
62 62
63 namespace { 63 namespace {
64 struct DashLineVertex { 64 struct DashLineVertex {
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 677
678 BatchTracker fBatch; 678 BatchTracker fBatch;
679 SkSTArray<1, Geometry, true> fGeoData; 679 SkSTArray<1, Geometry, true> fGeoData;
680 }; 680 };
681 681
682 static GrBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const Sk Point pts[2], 682 static GrBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const Sk Point pts[2],
683 bool useAA, const GrStrokeInfo& strokeInfo, bool ms aaRT) { 683 bool useAA, const GrStrokeInfo& strokeInfo, bool ms aaRT) {
684 const SkScalar* intervals = strokeInfo.getDashIntervals(); 684 const SkScalar* intervals = strokeInfo.getDashIntervals();
685 SkScalar phase = strokeInfo.getDashPhase(); 685 SkScalar phase = strokeInfo.getDashPhase();
686 686
687 SkPaint::Cap cap = strokeInfo.getStrokeRec().getCap(); 687 SkPaint::Cap cap = strokeInfo.getCap();
688 688
689 DashBatch::Geometry geometry; 689 DashBatch::Geometry geometry;
690 geometry.fSrcStrokeWidth = strokeInfo.getStrokeRec().getWidth(); 690 geometry.fSrcStrokeWidth = strokeInfo.getWidth();
691 691
692 // the phase should be normalized to be [0, sum of all intervals) 692 // the phase should be normalized to be [0, sum of all intervals)
693 SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]); 693 SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]);
694 694
695 // Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[ 1].fX 695 // Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[ 1].fX
696 if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) { 696 if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) {
697 SkMatrix rotMatrix; 697 SkMatrix rotMatrix;
698 align_to_x_axis(pts, &rotMatrix, geometry.fPtsRot); 698 align_to_x_axis(pts, &rotMatrix, geometry.fPtsRot);
699 if(!rotMatrix.invert(&geometry.fSrcRotInv)) { 699 if(!rotMatrix.invert(&geometry.fSrcRotInv)) {
700 SkDebugf("Failed to create invertible rotation matrix!\n"); 700 SkDebugf("Failed to create invertible rotation matrix!\n");
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 info.fIntervals = intervals; 1303 info.fIntervals = intervals;
1304 info.fCount = 2; 1304 info.fCount = 2;
1305 info.fPhase = phase; 1305 info.fPhase = phase;
1306 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info); 1306 SkDEBUGCODE(bool success = ) strokeInfo.setDashInfo(info);
1307 SkASSERT(success); 1307 SkASSERT(success);
1308 1308
1309 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT); 1309 return create_batch(color, viewMatrix, pts, useAA, strokeInfo, msaaRT);
1310 } 1310 }
1311 1311
1312 #endif 1312 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698