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

Unified Diff: src/core/SkLinearBitmapPipeline_matrix.h

Issue 1765953002: break out the tile and matrix strategies (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkLinearBitmapPipeline_core.h ('k') | src/core/SkLinearBitmapPipeline_tile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLinearBitmapPipeline_matrix.h
diff --git a/src/core/SkLinearBitmapPipeline_matrix.h b/src/core/SkLinearBitmapPipeline_matrix.h
new file mode 100644
index 0000000000000000000000000000000000000000..b1bd81f1630f655a2a0dd8e208c3f3bf11651288
--- /dev/null
+++ b/src/core/SkLinearBitmapPipeline_matrix.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkLinearBitmapPipeline_matrix_DEFINED
+#define SkLinearBitmapPipeline_matrix_DEFINED
+
+#include "SkLinearBitmapPipeline_core.h"
+
+namespace {
+class TranslateMatrixStrategy {
+public:
+ TranslateMatrixStrategy(SkVector offset)
+ : fXOffset{X(offset)}
+ , fYOffset{Y(offset)} { }
+
+ void processPoints(Sk4s* xs, Sk4s* ys) {
+ *xs = *xs + fXOffset;
+ *ys = *ys + fYOffset;
+ }
+
+ template <typename Next>
+ bool maybeProcessSpan(Span span, Next* next) {
+ SkPoint start; SkScalar length; int count;
+ std::tie(start, length, count) = span;
+ next->pointSpan(Span{start + SkPoint{fXOffset[0], fYOffset[0]}, length, count});
+ return true;
+ }
+
+private:
+ const Sk4s fXOffset, fYOffset;
+};
+
+class ScaleMatrixStrategy {
+public:
+ ScaleMatrixStrategy(SkVector offset, SkVector scale)
+ : fXOffset{X(offset)}, fYOffset{Y(offset)}
+ , fXScale{X(scale)}, fYScale{Y(scale)} { }
+ void processPoints(Sk4s* xs, Sk4s* ys) {
+ *xs = *xs * fXScale + fXOffset;
+ *ys = *ys * fYScale + fYOffset;
+ }
+
+ template <typename Next>
+ bool maybeProcessSpan(Span span, Next* next) {
+ SkPoint start; SkScalar length; int count;
+ std::tie(start, length, count) = span;
+ SkPoint newStart =
+ SkPoint{X(start) * fXScale[0] + fXOffset[0], Y(start) * fYScale[0] + fYOffset[0]};
+ SkScalar newLength = length * fXScale[0];
+ next->pointSpan(Span{newStart, newLength, count});
+ return true;
+ }
+
+private:
+ const Sk4s fXOffset, fYOffset;
+ const Sk4s fXScale, fYScale;
+};
+
+class AffineMatrixStrategy {
+public:
+ AffineMatrixStrategy(SkVector offset, SkVector scale, SkVector skew)
+ : fXOffset{X(offset)}, fYOffset{Y(offset)}
+ , fXScale{X(scale)}, fYScale{Y(scale)}
+ , fXSkew{X(skew)}, fYSkew{Y(skew)} { }
+ void processPoints(Sk4s* xs, Sk4s* ys) {
+ Sk4s newXs = fXScale * *xs + fXSkew * *ys + fXOffset;
+ Sk4s newYs = fYSkew * *xs + fYScale * *ys + fYOffset;
+
+ *xs = newXs;
+ *ys = newYs;
+ }
+
+ template <typename Next>
+ bool maybeProcessSpan(Span span, Next* next) {
+ return false;
+ }
+
+private:
+ const Sk4s fXOffset, fYOffset;
+ const Sk4s fXScale, fYScale;
+ const Sk4s fXSkew, fYSkew;
+};
+
+} // namespace
+
+#endif // SkLinearBitmapPipeline_matrix_DEFINED
« no previous file with comments | « src/core/SkLinearBitmapPipeline_core.h ('k') | src/core/SkLinearBitmapPipeline_tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698