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

Side by Side Diff: src/gpu/batches/GrAAFillRectBatch.cpp

Issue 2023693002: Handle stroked single line special case in Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bugs Created 4 years, 6 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 2015 Google Inc. 2 * Copyright 2015 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 "GrAAFillRectBatch.h" 8 #include "GrAAFillRectBatch.h"
9 9
10 #include "GrColor.h" 10 #include "GrColor.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 size_t vertexStride, 77 size_t vertexStride,
78 GrColor color, 78 GrColor color,
79 const SkMatrix& viewMatrix, 79 const SkMatrix& viewMatrix,
80 const SkRect& rect, 80 const SkRect& rect,
81 const SkRect& devRect, 81 const SkRect& devRect,
82 const GrXPOverridesForBatch& override s, 82 const GrXPOverridesForBatch& override s,
83 const SkMatrix* localMatrix) { 83 const SkMatrix* localMatrix) {
84 SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts); 84 SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
85 SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride); 85 SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
86 86
87 SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1); 87 SkScalar inset;
88 inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
89 88
90 if (viewMatrix.rectStaysRect()) { 89 if (viewMatrix.rectStaysRect()) {
90 inset = SkMinScalar(devRect.width(), SK_Scalar1);
91 inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
92
91 set_inset_fan(fan0Pos, vertexStride, devRect, -SK_ScalarHalf, -SK_Scalar Half); 93 set_inset_fan(fan0Pos, vertexStride, devRect, -SK_ScalarHalf, -SK_Scalar Half);
92 set_inset_fan(fan1Pos, vertexStride, devRect, inset, inset); 94 set_inset_fan(fan1Pos, vertexStride, devRect, inset, inset);
93 } else { 95 } else {
94 // compute transformed (1, 0) and (0, 1) vectors 96 // compute transformed (1, 0) and (0, 1) vectors
95 SkVector vec[2] = { 97 SkVector vec[2] = {
96 { viewMatrix[SkMatrix::kMScaleX], viewMatrix[SkMatrix::kMSkewY] }, 98 { viewMatrix[SkMatrix::kMScaleX], viewMatrix[SkMatrix::kMSkewY] },
97 { viewMatrix[SkMatrix::kMSkewX], viewMatrix[SkMatrix::kMScaleY] } 99 { viewMatrix[SkMatrix::kMSkewX], viewMatrix[SkMatrix::kMScaleY] }
98 }; 100 };
99 101
100 vec[0].normalize(); 102 SkScalar len1 = SkPoint::Normalize(&vec[0]);
101 vec[0].scale(SK_ScalarHalf); 103 vec[0].scale(SK_ScalarHalf);
102 vec[1].normalize(); 104 SkScalar len2 = SkPoint::Normalize(&vec[1]);
103 vec[1].scale(SK_ScalarHalf); 105 vec[1].scale(SK_ScalarHalf);
104 106
107 inset = SkMinScalar(len1 * rect.width(), SK_Scalar1);
108 inset = SK_ScalarHalf * SkMinScalar(inset, len2 * rect.height());
109
105 // create the rotated rect 110 // create the rotated rect
106 fan0Pos->setRectFan(rect.fLeft, rect.fTop, 111 fan0Pos->setRectFan(rect.fLeft, rect.fTop,
107 rect.fRight, rect.fBottom, vertexStride); 112 rect.fRight, rect.fBottom, vertexStride);
108 viewMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4); 113 viewMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4);
109 114
110 // Now create the inset points and then outset the original 115 // Now create the inset points and then outset the original
111 // rotated points 116 // rotated points
112 117
113 // TL 118 // TL
114 *((SkPoint*)((intptr_t)fan1Pos + 0 * vertexStride)) = 119 *((SkPoint*)((intptr_t)fan1Pos + 0 * vertexStride)) =
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) { 417 DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
413 GrColor color = GrRandomColor(random); 418 GrColor color = GrRandomColor(random);
414 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); 419 SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
415 SkMatrix localMatrix = GrTest::TestMatrix(random); 420 SkMatrix localMatrix = GrTest::TestMatrix(random);
416 SkRect rect = GrTest::TestRect(random); 421 SkRect rect = GrTest::TestRect(random);
417 SkRect devRect = GrTest::TestRect(random); 422 SkRect devRect = GrTest::TestRect(random);
418 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct); 423 return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRe ct);
419 } 424 }
420 425
421 #endif 426 #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