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

Unified Diff: src/core/SkLinearBitmapPipeline_sample.h

Issue 2044373003: Use faster case for on tile sampling, and a little clean up (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments. 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLinearBitmapPipeline_sample.h
diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h
index cf13fd57be891da154f46730f8c8b61c9bfff522..15a7c359cc1ab6ace6fa15024ac43e31232f91fa 100644
--- a/src/core/SkLinearBitmapPipeline_sample.h
+++ b/src/core/SkLinearBitmapPipeline_sample.h
@@ -268,7 +268,7 @@ private:
////////////////////////////////////////////////////////////////////////////////////////////////////
// GeneralSampler handles all the different sampling scenarios. It makes runtime decisions to
-// choose the fastest stratagy given a particular job. It ultimately uses PixelGetters to access
+// choose the fastest strategy given a particular job. It ultimately uses PixelGetters to access
// the pixels.
template<SkColorType colorType, SkColorProfileType colorProfile, typename Next>
class GeneralSampler {
@@ -312,12 +312,13 @@ public:
}
}
- Sk4f bilerNonEdgePixel(SkScalar x, SkScalar y) {
+ Sk4f bilerpNonEdgePixel(SkScalar x, SkScalar y) {
Sk4f px00, px10, px01, px11;
- Sk4f xs = Sk4f{x};
- Sk4f ys = Sk4f{y};
- Sk4f sampleXs = xs + Sk4f{-0.5f, 0.5f, -0.5f, 0.5f};
- Sk4f sampleYs = ys + Sk4f{-0.5f, -0.5f, 0.5f, 0.5f};
+ // bilerp4() expects xs, ys are the top-lefts of the 2x2 kernel.
+ Sk4f xs = Sk4f{x} - 0.5f;
+ Sk4f ys = Sk4f{y} - 0.5f;
+ Sk4f sampleXs = xs + Sk4f{0.0f, 1.0f, 0.0f, 1.0f};
+ Sk4f sampleYs = ys + Sk4f{0.0f, 0.0f, 1.0f, 1.0f};
fStrategy.get4Pixels(sampleXs, sampleYs, &px00, &px10, &px01, &px11);
return bilerp4(xs, ys, px00, px10, px01, px11);
}
@@ -325,7 +326,7 @@ public:
void VECTORCALL bilerpListFew(int n, Sk4s xs, Sk4s ys) {
SkASSERT(0 < n && n < 4);
auto bilerpPixel = [&](int index) {
- return this->bilerNonEdgePixel(xs[index], ys[index]);
+ return this->bilerpNonEdgePixel(xs[index], ys[index]);
};
if (n >= 1) fNext->blendPixel(bilerpPixel(0));
@@ -335,7 +336,7 @@ public:
void VECTORCALL bilerpList4(Sk4s xs, Sk4s ys) {
auto bilerpPixel = [&](int index) {
- return this->bilerNonEdgePixel(xs[index], ys[index]);
+ return this->bilerpNonEdgePixel(xs[index], ys[index]);
};
fNext->blend4Pixels(bilerpPixel(0), bilerpPixel(1), bilerpPixel(2), bilerpPixel(3));
}
@@ -514,11 +515,9 @@ private:
SkScalar length;
int count;
std::tie(start, length, count) = span;
- SkFixed fx = SkScalarToFixed(X(start)
- -0.5f);
+ SkFixed fx = SkScalarToFixed(X(start)-0.5f);
SkFixed fdx = SkScalarToFixed(length / (count - 1));
- //start = start + SkPoint{-0.5f, -0.5f};
Sk4f xAdjust;
if (fdx >= 0) {
@@ -751,7 +750,10 @@ private:
std::tie(start, length, count) = span;
SkScalar x = X(start);
SkScalar y = Y(start);
- if (false && y == y1) {
+ // In this sampler, it is assumed that if span.StartY() and y1 are the same then both
+ // y-lines are on the same tile.
+ if (y == y1) {
+ // Both y-lines are on the same tile.
struct BilerpWrapper {
void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) {
fSampler.bilerpListFew(n, xs, ys);
@@ -766,6 +768,7 @@ private:
BilerpWrapper wrapper{*this};
span_fallback(span, &wrapper);
} else {
+ // The y-lines are on different tiles.
SkScalar dx = length / (count - 1);
Sk4f ys = {y - 0.5f, y - 0.5f, y1 + 0.5f, y1 + 0.5f};
while (count > 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698