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

Side by Side Diff: src/core/SkLinearBitmapPipeline_matrix.h

Issue 2484273002: Move the matrix stage of SkLinearBitmapPipeline over to using SkSmallAllocator. (Closed)
Patch Set: rebase on new SkSmallAllocator Created 4 years, 1 month 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/core/SkLinearBitmapPipeline.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 2016 Google Inc. 2 * Copyright 2016 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 #ifndef SkLinearBitmapPipeline_matrix_DEFINED 8 #ifndef SkLinearBitmapPipeline_matrix_DEFINED
9 #define SkLinearBitmapPipeline_matrix_DEFINED 9 #define SkLinearBitmapPipeline_matrix_DEFINED
10 10
11 #include "SkLinearBitmapPipeline_core.h" 11 #include "SkLinearBitmapPipeline_core.h"
12 12
13 namespace { 13 namespace {
14 class TranslateMatrixStrategy { 14 class TranslateMatrixStrategy {
15 public: 15 public:
16 TranslateMatrixStrategy(SkVector offset) 16 TranslateMatrixStrategy(SkVector offset)
17 : fXOffset{X(offset)} 17 : fXOffset{X(offset)}
18 , fYOffset{Y(offset)} { } 18 , fYOffset{Y(offset)} { }
19 19
20 void processPoints(Sk4s* xs, Sk4s* ys) { 20 void processPoints(Sk4s* xs, Sk4s* ys) const {
21 *xs = *xs + fXOffset; 21 *xs = *xs + fXOffset;
22 *ys = *ys + fYOffset; 22 *ys = *ys + fYOffset;
23 } 23 }
24 24
25 template <typename Next> 25 template <typename Next>
26 bool maybeProcessSpan(Span span, Next* next) { 26 bool maybeProcessSpan(Span span, Next* next) const {
27 SkPoint start; SkScalar length; int count; 27 SkPoint start; SkScalar length; int count;
28 std::tie(start, length, count) = span; 28 std::tie(start, length, count) = span;
29 next->pointSpan(Span{start + SkPoint{fXOffset, fYOffset}, length, count} ); 29 next->pointSpan(Span{start + SkPoint{fXOffset, fYOffset}, length, count} );
30 return true; 30 return true;
31 } 31 }
32 32
33 private: 33 private:
34 const SkScalar fXOffset, fYOffset; 34 const SkScalar fXOffset, fYOffset;
35 }; 35 };
36 36
37 class ScaleMatrixStrategy { 37 class ScaleMatrixStrategy {
38 public: 38 public:
39 ScaleMatrixStrategy(SkVector offset, SkVector scale) 39 ScaleMatrixStrategy(SkVector offset, SkVector scale)
40 : fXOffset{X(offset)}, fYOffset{Y(offset)} 40 : fXOffset{X(offset)}, fYOffset{Y(offset)}
41 , fXScale{X(scale)}, fYScale{Y(scale)} { } 41 , fXScale{X(scale)}, fYScale{Y(scale)} { }
42 void processPoints(Sk4s* xs, Sk4s* ys) { 42 void processPoints(Sk4s* xs, Sk4s* ys) const {
43 *xs = *xs * fXScale + fXOffset; 43 *xs = *xs * fXScale + fXOffset;
44 *ys = *ys * fYScale + fYOffset; 44 *ys = *ys * fYScale + fYOffset;
45 } 45 }
46 46
47 template <typename Next> 47 template <typename Next>
48 bool maybeProcessSpan(Span span, Next* next) { 48 bool maybeProcessSpan(Span span, Next* next) const {
49 SkPoint start; SkScalar length; int count; 49 SkPoint start; SkScalar length; int count;
50 std::tie(start, length, count) = span; 50 std::tie(start, length, count) = span;
51 SkPoint newStart = 51 SkPoint newStart =
52 SkPoint{X(start) * fXScale + fXOffset, Y(start) * fYScale + fYOffset }; 52 SkPoint{X(start) * fXScale + fXOffset, Y(start) * fYScale + fYOffset };
53 SkScalar newLength = length * fXScale; 53 SkScalar newLength = length * fXScale;
54 next->pointSpan(Span{newStart, newLength, count}); 54 next->pointSpan(Span{newStart, newLength, count});
55 return true; 55 return true;
56 } 56 }
57 57
58 private: 58 private:
59 const SkScalar fXOffset, fYOffset; 59 const SkScalar fXOffset, fYOffset;
60 const SkScalar fXScale, fYScale; 60 const SkScalar fXScale, fYScale;
61 }; 61 };
62 62
63 class AffineMatrixStrategy { 63 class AffineMatrixStrategy {
64 public: 64 public:
65 AffineMatrixStrategy(SkVector offset, SkVector scale, SkVector skew) 65 AffineMatrixStrategy(SkVector offset, SkVector scale, SkVector skew)
66 : fXOffset{X(offset)}, fYOffset{Y(offset)} 66 : fXOffset{X(offset)}, fYOffset{Y(offset)}
67 , fXScale{X(scale)}, fYScale{Y(scale)} 67 , fXScale{X(scale)}, fYScale{Y(scale)}
68 , fXSkew{X(skew)}, fYSkew{Y(skew)} { } 68 , fXSkew{X(skew)}, fYSkew{Y(skew)} { }
69 void processPoints(Sk4s* xs, Sk4s* ys) { 69 void processPoints(Sk4s* xs, Sk4s* ys) const {
70 Sk4s newXs = fXScale * *xs + fXSkew * *ys + fXOffset; 70 Sk4s newXs = fXScale * *xs + fXSkew * *ys + fXOffset;
71 Sk4s newYs = fYSkew * *xs + fYScale * *ys + fYOffset; 71 Sk4s newYs = fYSkew * *xs + fYScale * *ys + fYOffset;
72 72
73 *xs = newXs; 73 *xs = newXs;
74 *ys = newYs; 74 *ys = newYs;
75 } 75 }
76 76
77 template <typename Next> 77 template <typename Next>
78 bool maybeProcessSpan(Span span, Next* next) { 78 bool maybeProcessSpan(Span span, Next* next) const {
79 return false; 79 return false;
80 } 80 }
81 81
82 private: 82 private:
83 const SkScalar fXOffset, fYOffset; 83 const SkScalar fXOffset, fYOffset;
84 const SkScalar fXScale, fYScale; 84 const SkScalar fXScale, fYScale;
85 const SkScalar fXSkew, fYSkew; 85 const SkScalar fXSkew, fYSkew;
86 }; 86 };
87 87
88 class PerspectiveMatrixStrategy { 88 class PerspectiveMatrixStrategy {
89 public: 89 public:
90 PerspectiveMatrixStrategy(SkVector offset, SkVector scale, SkVector skew, 90 PerspectiveMatrixStrategy(SkVector offset, SkVector scale, SkVector skew,
91 SkVector zSkew, SkScalar zOffset) 91 SkVector zSkew, SkScalar zOffset)
92 : fXOffset{X(offset)}, fYOffset{Y(offset)}, fZOffset{zOffset} 92 : fXOffset{X(offset)}, fYOffset{Y(offset)}, fZOffset{zOffset}
93 , fXScale{X(scale)}, fYScale{Y(scale)} 93 , fXScale{X(scale)}, fYScale{Y(scale)}
94 , fXSkew{X(skew)}, fYSkew{Y(skew)}, fZXSkew{X(zSkew)}, fZYSkew{Y(zSk ew)} { } 94 , fXSkew{X(skew)}, fYSkew{Y(skew)}, fZXSkew{X(zSkew)}, fZYSkew{Y(zSk ew)} { }
95 void processPoints(Sk4s* xs, Sk4s* ys) { 95 void processPoints(Sk4s* xs, Sk4s* ys) const {
96 Sk4s newXs = fXScale * *xs + fXSkew * *ys + fXOffset; 96 Sk4s newXs = fXScale * *xs + fXSkew * *ys + fXOffset;
97 Sk4s newYs = fYSkew * *xs + fYScale * *ys + fYOffset; 97 Sk4s newYs = fYSkew * *xs + fYScale * *ys + fYOffset;
98 Sk4s newZs = fZXSkew * *xs + fZYSkew * *ys + fZOffset; 98 Sk4s newZs = fZXSkew * *xs + fZYSkew * *ys + fZOffset;
99 99
100 *xs = newXs / newZs; 100 *xs = newXs / newZs;
101 *ys = newYs / newZs; 101 *ys = newYs / newZs;
102 } 102 }
103 103
104 template <typename Next> 104 template <typename Next>
105 bool maybeProcessSpan(Span span, Next* next) { 105 bool maybeProcessSpan(Span span, Next* next) const {
106 return false; 106 return false;
107 } 107 }
108 108
109 private: 109 private:
110 const SkScalar fXOffset, fYOffset, fZOffset; 110 const SkScalar fXOffset, fYOffset, fZOffset;
111 const SkScalar fXScale, fYScale; 111 const SkScalar fXScale, fYScale;
112 const SkScalar fXSkew, fYSkew, fZXSkew, fZYSkew; 112 const SkScalar fXSkew, fYSkew, fZXSkew, fZYSkew;
113 }; 113 };
114 114
115 115
116 } // namespace 116 } // namespace
117 117
118 #endif // SkLinearBitmapPipeline_matrix_DEFINED 118 #endif // SkLinearBitmapPipeline_matrix_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkLinearBitmapPipeline.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698