From 6b59bf424c9d9d8a72d3c002871f143e6aff623e Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Mon, 3 Jul 2017 21:26:44 -0400 Subject: consolidate logic for matrix stage Bug: skia: Change-Id: Id1559b31692a1aed9aa4d15620b2019ae9c7c22b Reviewed-on: https://skia-review.googlesource.com/21404 Commit-Queue: Mike Reed Reviewed-by: Florin Malita --- src/core/SkRasterPipeline.cpp | 11 +++++++++++ src/core/SkRasterPipeline.h | 4 ++++ 2 files changed, 15 insertions(+) (limited to 'src/core') diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp index 45d081bec5..6f5ae8c435 100644 --- a/src/core/SkRasterPipeline.cpp +++ b/src/core/SkRasterPipeline.cpp @@ -82,3 +82,14 @@ void SkRasterPipeline::append_from_srgb_dst(SkAlphaType at) { this->append(SkRasterPipeline::clamp_a_dst); } } + +void SkRasterPipeline::append_matrix(SkArenaAlloc* alloc, const SkMatrix& matrix) { + float* storage = alloc->makeArray(9); + // TODO: consider adding special stages for scale+translate and possibly just translate. + if (matrix.asAffine(storage)) { + this->append(SkRasterPipeline::matrix_2x3, storage); + } else { + matrix.get9(storage); + this->append(SkRasterPipeline::matrix_perspective, storage); + } +} diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h index a4175c65a8..9a467a5024 100644 --- a/src/core/SkRasterPipeline.h +++ b/src/core/SkRasterPipeline.h @@ -127,6 +127,10 @@ public: void append_from_srgb(SkAlphaType); void append_from_srgb_dst(SkAlphaType); + // Appends a stage for the specified matrix. Tries to optimize the stage by analyzing + // the type of matrix. + void append_matrix(SkArenaAlloc*, const SkMatrix&); + bool empty() const { return fStages == nullptr; } private: -- cgit v1.2.3