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

Unified Diff: src/core/SkLinearBitmapPipeline.cpp

Issue 2055513003: Simplify code by breaking general sampler into Nearest and Bilerp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: sync 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkLinearBitmapPipeline_core.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLinearBitmapPipeline.cpp
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp
index 0359e1fbb1c7d57c4570b5f7b43a2888a0ac9cb6..4f6985b594046ed9a8a535fe9026c56d2670dc33 100644
--- a/src/core/SkLinearBitmapPipeline.cpp
+++ b/src/core/SkLinearBitmapPipeline.cpp
@@ -20,65 +20,6 @@
#include "SkOpts.h"
#include "SkPM4f.h"
-class SkLinearBitmapPipeline::PointProcessorInterface {
-public:
- virtual ~PointProcessorInterface() { }
- // Take the first n (where 0 < n && n < 4) items from xs and ys and sample those points. For
- // nearest neighbor, that means just taking the floor xs and ys. For bilerp, this means
- // to expand the bilerp filter around the point and sample using that filter.
- virtual void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) = 0;
- // Same as pointListFew, but n = 4.
- virtual void VECTORCALL pointList4(Sk4s xs, Sk4s ys) = 0;
- // A span is a compact form of sample points that are obtained by mapping points from
- // destination space to source space. This is used for horizontal lines only, and is mainly
- // used to take advantage of memory coherence for horizontal spans.
- virtual void pointSpan(Span span) = 0;
-};
-
-class SkLinearBitmapPipeline::SampleProcessorInterface
- : public SkLinearBitmapPipeline::PointProcessorInterface {
-public:
- // Used for nearest neighbor when scale factor is 1.0. The span can just be repeated with no
- // edge pixel alignment problems. This is for handling a very common case.
- virtual void repeatSpan(Span span, int32_t repeatCount) = 0;
-
- // The x's and y's are setup in the following order:
- // +--------+--------+
- // | | |
- // | px00 | px10 |
- // | 0 | 1 |
- // +--------+--------+
- // | | |
- // | px01 | px11 |
- // | 2 | 3 |
- // +--------+--------+
- // These pixels coordinates are arranged in the following order in xs and ys:
- // px00 px10 px01 px11
- virtual void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) = 0;
-
- // A span represents sample points that have been mapped from destination space to source
- // space. Each sample point is then expanded to the four bilerp points by add +/- 0.5. The
- // resulting Y values my be off the tile. When y +/- 0.5 are more than 1 apart because of
- // tiling, the second Y is used to denote the retiled Y value.
- virtual void bilerpSpan(Span span, SkScalar y) = 0;
-};
-
-class SkLinearBitmapPipeline::DestinationInterface {
-public:
- virtual ~DestinationInterface() { }
- // Count is normally not needed, but in these early stages of development it is useful to
- // check bounds.
- // TODO(herb): 4/6/2016 - remove count when code is stable.
- virtual void setDestination(void* dst, int count) = 0;
-};
-
-class SkLinearBitmapPipeline::BlendProcessorInterface
- : public SkLinearBitmapPipeline::DestinationInterface {
-public:
- virtual void VECTORCALL blendPixel(Sk4f pixel0) = 0;
- virtual void VECTORCALL blend4Pixels(Sk4f p0, Sk4f p1, Sk4f p2, Sk4f p3) = 0;
-};
-
////////////////////////////////////////////////////////////////////////////////////////////////////
// SkLinearBitmapPipeline::Stage
template<typename Base, size_t kSize, typename Next>
@@ -469,90 +410,6 @@ static SkLinearBitmapPipeline::PointProcessorInterface* choose_tiler(
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-// Source Sampling Stage
-template <SkColorType colorType, SkColorProfileType colorProfile, typename Next>
-class NearestNeighborSampler final : public SkLinearBitmapPipeline::SampleProcessorInterface {
-public:
- template <typename... Args>
- NearestNeighborSampler(Next* next, Args&&... args)
- : fSampler{next, std::forward<Args>(args)...} { }
-
- NearestNeighborSampler(Next* next, const NearestNeighborSampler& sampler)
- : fSampler{next, sampler.fSampler} { }
-
- void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
- fSampler.nearestListFew(n, xs, ys);
- }
-
- void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
- fSampler.nearestList4(xs, ys);
- }
-
- void pointSpan(Span span) override {
- fSampler.nearestSpan(span);
- }
-
- void repeatSpan(Span span, int32_t repeatCount) override {
- while (repeatCount > 0) {
- fSampler.nearestSpan(span);
- repeatCount--;
- }
- }
-
- void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override {
- SkFAIL("Using nearest neighbor sampler, but calling a bilerpEdge.");
- }
-
- void bilerpSpan(Span span, SkScalar y) override {
- SkFAIL("Using nearest neighbor sampler, but calling a bilerpSpan.");
- }
-
-private:
- GeneralSampler<colorType, colorProfile, Next> fSampler;
-};
-
-template <SkColorType colorType, SkColorProfileType colorProfile, typename Next>
-class BilerpSampler final : public SkLinearBitmapPipeline::SampleProcessorInterface {
-public:
- template <typename... Args>
- BilerpSampler(Next* next, Args&&... args)
- : fSampler{next, std::forward<Args>(args)...} { }
-
- BilerpSampler(Next* next, const BilerpSampler& sampler)
- : fSampler{next, sampler.fSampler} { }
-
- void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
- fSampler.bilerpListFew(n, xs, ys);
- }
-
- void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
- fSampler.bilerpList4(xs, ys);
- }
-
- void pointSpan(Span span) override {
- fSampler.bilerpSpan(span);
- }
-
- void repeatSpan(Span span, int32_t repeatCount) override {
- while (repeatCount > 0) {
- fSampler.bilerpSpan(span);
- repeatCount--;
- }
- }
-
- void VECTORCALL bilerpEdge(Sk4s xs, Sk4s ys) override {
- fSampler.bilerpEdge(xs, ys);
- }
-
- void bilerpSpan(Span span, SkScalar y) override {
- fSampler.bilerpSpanWithY(span, y);
- }
-
-private:
- GeneralSampler<colorType, colorProfile, Next> fSampler;
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
// Specialized Samplers
// RGBA8888UnitRepeatSrc - A sampler that takes advantage of the fact the the src and destination
« no previous file with comments | « no previous file | src/core/SkLinearBitmapPipeline_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698