aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRasterPipelineBlitter.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-01-20 15:11:54 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-23 20:00:23 +0000
commit319ba3d3a177498095c31696e0aec8b3af25f663 (patch)
treebed59456eaf6d87a39eed79c33df5e3fe6921e8b /src/core/SkRasterPipelineBlitter.cpp
parent889176b3a3b5b71cc05c51dad3e7d2ddac610b7e (diff)
Move shader register setup to SkRasterPipelineBlitter.
We've been seeding the initial values of our registers to x+0.5,y+0.5, 1,0, 0,0,0,0 (useful values for shaders to start with) in all pipelines. This CL changes that to do so only when blitting, and only when we have a shader. The nicest part of this change is that SkRasterPipeline itself no longer needs to have a concept of y, or what x means. It just marches x through [x,x+n), and the blitter handles y and layers the meaning of "dst x coordinate" onto x. This ought to make SkSplicer a little easier to work with too. dm --src gm --config f16 srgb 565 all draws the same. Change-Id: I69d8c1cc14a06e5dfdd6a7493364f43a18f8dec5 Reviewed-on: https://skia-review.googlesource.com/7353 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkRasterPipelineBlitter.cpp')
-rw-r--r--src/core/SkRasterPipelineBlitter.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index 7f91cbf334..bb89f76b8f 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -49,16 +49,17 @@ private:
SkRasterPipeline fShader;
// These functions are compiled lazily when first used.
- std::function<void(size_t, size_t, size_t)> fBlitH = nullptr,
- fBlitAntiH = nullptr,
- fBlitMaskA8 = nullptr,
- fBlitMaskLCD16 = nullptr;
+ std::function<void(size_t, size_t)> fBlitH = nullptr,
+ fBlitAntiH = nullptr,
+ fBlitMaskA8 = nullptr,
+ fBlitMaskLCD16 = nullptr;
// These values are pointed to by the compiled blit functions
// above, which allows us to adjust them from call to call.
void* fDstPtr = nullptr;
const void* fMaskPtr = nullptr;
float fCurrentCoverage = 0.0f;
+ int fCurrentY = 0;
// Scratch space for shaders and color filters to use.
char fScratch[64];
@@ -113,6 +114,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
bool is_opaque = paintColor->a() == 1.0f,
is_constant = true;
if (shader) {
+ pipeline->append(SkRasterPipeline::seed_shader, &blitter->fCurrentY);
if (!shader->appendStages(pipeline, dst.colorSpace(), &blitter->fArena,
ctm, paint)) {
return earlyOut();
@@ -138,7 +140,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
if (is_constant) {
pipeline->append(SkRasterPipeline::store_f32, &paintColor);
- pipeline->run(0,0, 1);
+ pipeline->run(0,1);
*pipeline = SkRasterPipeline();
pipeline->append(SkRasterPipeline::constant_color, paintColor);
@@ -156,21 +158,21 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
p.extend(*pipeline);
blitter->fDstPtr = &color;
blitter->append_store(&p);
- p.run(0,0, 1);
+ p.run(0,1);
switch (dst.shiftPerPixel()) {
case 1:
- blitter->fBlitH = [blitter,color](size_t x, size_t, size_t n) {
+ blitter->fBlitH = [blitter,color](size_t x, size_t n) {
sk_memset16((uint16_t*)blitter->fDstPtr + x, color, n);
};
break;
case 2:
- blitter->fBlitH = [blitter,color](size_t x, size_t, size_t n) {
+ blitter->fBlitH = [blitter,color](size_t x, size_t n) {
sk_memset32((uint32_t*)blitter->fDstPtr + x, color, n);
};
break;
case 3:
- blitter->fBlitH = [blitter,color](size_t x, size_t, size_t n) {
+ blitter->fBlitH = [blitter,color](size_t x, size_t n) {
sk_memset64((uint64_t*)blitter->fDstPtr + x, color, n);
};
break;
@@ -244,7 +246,8 @@ void SkRasterPipelineBlitter::blitH(int x, int y, int w) {
fBlitH = p.compile();
}
fDstPtr = fDst.writable_addr(0,y);
- fBlitH(x,y, w);
+ fCurrentY = y;
+ fBlitH(x,w);
}
void SkRasterPipelineBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t runs[]) {
@@ -266,13 +269,14 @@ void SkRasterPipelineBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const
}
fDstPtr = fDst.writable_addr(0,y);
+ fCurrentY = y;
for (int16_t run = *runs; run > 0; run = *runs) {
switch (*aa) {
case 0x00: break;
case 0xff: this->blitH(x,y,run); break;
default:
fCurrentCoverage = *aa * (1/255.0f);
- fBlitAntiH(x,y, run);
+ fBlitAntiH(x,run);
}
x += run;
runs += run;
@@ -317,15 +321,16 @@ void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
int x = clip.left();
for (int y = clip.top(); y < clip.bottom(); y++) {
fDstPtr = fDst.writable_addr(0,y);
+ fCurrentY = y;
switch (mask.fFormat) {
case SkMask::kA8_Format:
fMaskPtr = mask.getAddr8(x,y)-x;
- fBlitMaskA8(x,y, clip.width());
+ fBlitMaskA8(x,clip.width());
break;
case SkMask::kLCD16_Format:
fMaskPtr = mask.getAddrLCD16(x,y)-x;
- fBlitMaskLCD16(x,y, clip.width());
+ fBlitMaskLCD16(x,clip.width());
break;
default:
// TODO