aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-08-03 09:42:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-03 14:36:07 +0000
commit073073e4a49993818a7fc4996a7fb42f3ec79640 (patch)
tree0a1a63ffa859fc2425463e1e20d399a06c72c9ea /src
parentc18ab884ae6cf85521ed2c719d78e45308404335 (diff)
Rename append_uniform_color() to append_constant_color().
The color appended here is both uniform and constant, and it's the constantness that makes this custom append method useful over just append(SkRasterPipeline::uniform_color, ...). Uniform colors that are not constant have to be loaded from the pointer each time (the caller might have changed the color out-of-band), but constant uniform colors can be analyzed once and implemented with specalizations like black_color and white_color. Change-Id: I3cfc00ccc578dd915367bca7113010557181224c Reviewed-on: https://skia-review.googlesource.com/30560 Commit-Queue: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkColorFilter.cpp2
-rw-r--r--src/core/SkModeColorFilter.cpp2
-rw-r--r--src/core/SkRasterPipeline.cpp2
-rw-r--r--src/core/SkRasterPipeline.h9
-rw-r--r--src/core/SkRasterPipelineBlitter.cpp4
-rw-r--r--src/shaders/SkColorShader.cpp4
6 files changed, 12 insertions, 11 deletions
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 1bc3b1dd70..4291644506 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -69,7 +69,7 @@ SkColor4f SkColorFilter::filterColor4f(const SkColor4f& c) const {
SkSTArenaAlloc<128> alloc;
SkRasterPipeline pipeline(&alloc);
- pipeline.append_uniform_color(&alloc, src);
+ pipeline.append_constant_color(&alloc, src);
this->onAppendStages(&pipeline, nullptr, &alloc, c.fA == 1);
SkJumper_MemoryCtx dstPtr = { &dst, 0 };
pipeline.append(SkRasterPipeline::store_f32, &dstPtr);
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index 089bcd39e8..2d2fa93933 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -78,7 +78,7 @@ void SkModeColorFilter::onAppendStages(SkRasterPipeline* p,
SkArenaAlloc* scratch,
bool shaderIsOpaque) const {
p->append(SkRasterPipeline::move_src_dst);
- p->append_uniform_color(scratch, SkPM4f_from_SkColor(fColor, dst));
+ p->append_constant_color(scratch, SkPM4f_from_SkColor(fColor, dst));
SkBlendMode_AppendStages(fMode, p);
}
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp
index 5484c9f94c..bdb3795915 100644
--- a/src/core/SkRasterPipeline.cpp
+++ b/src/core/SkRasterPipeline.cpp
@@ -78,7 +78,7 @@ void SkRasterPipeline::dump() const {
#define INC_COLOR
#endif
-void SkRasterPipeline::append_uniform_color(SkArenaAlloc* alloc, const SkPM4f& c) {
+void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const SkPM4f& c) {
if (c.r() == 0 && c.g() == 0 && c.b() == 0 && c.a() == 1) {
this->append(black_color);
INC_BLACK;
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index e9cb886e6f..ff7bada24c 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -129,12 +129,13 @@ 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.
+ // Appends a stage for the specified matrix.
+ // Tries to optimize the stage by analyzing the type of matrix.
void append_matrix(SkArenaAlloc*, const SkMatrix&);
- // Appends a stage for the uniform color. Tries to optimize the stage based on the color.
- void append_uniform_color(SkArenaAlloc*, const SkPM4f& color);
+ // Appends a stage for a constant uniform color.
+ // Tries to optimize the stage based on the color.
+ void append_constant_color(SkArenaAlloc*, const SkPM4f& color);
bool empty() const { return fStages == nullptr; }
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index 158217e2c4..fb15014a85 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -99,7 +99,7 @@ SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst,
SkRasterPipeline_<256> shaderPipeline;
if (!shader) {
// Having no shader makes things nice and easy... just use the paint color.
- shaderPipeline.append_uniform_color(alloc, paintColor);
+ shaderPipeline.append_constant_color(alloc, paintColor);
bool is_opaque = paintColor.a() == 1.0f,
is_constant = true;
return SkRasterPipelineBlitter::Create(dst, paint, alloc,
@@ -198,7 +198,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
colorPipeline->append(SkRasterPipeline::store_f32, &constantColorPtr);
colorPipeline->run(0,0,1,1);
colorPipeline->reset();
- colorPipeline->append_uniform_color(alloc, constantColor);
+ colorPipeline->append_constant_color(alloc, constantColor);
is_opaque = constantColor.a() == 1.0f;
}
diff --git a/src/shaders/SkColorShader.cpp b/src/shaders/SkColorShader.cpp
index 6f5dc148d6..b57dc9bc35 100644
--- a/src/shaders/SkColorShader.cpp
+++ b/src/shaders/SkColorShader.cpp
@@ -257,7 +257,7 @@ bool SkColorShader::onAppendStages(SkRasterPipeline* p,
const SkMatrix&,
const SkPaint&,
const SkMatrix*) const {
- p->append_uniform_color(scratch, SkPM4f_from_SkColor(fColor, dst));
+ p->append_constant_color(scratch, SkPM4f_from_SkColor(fColor, dst));
return true;
}
@@ -267,6 +267,6 @@ bool SkColor4Shader::onAppendStages(SkRasterPipeline* p,
const SkMatrix&,
const SkPaint&,
const SkMatrix*) const {
- p->append_uniform_color(scratch, to_colorspace(fColor4, fColorSpace.get(), dst).premul());
+ p->append_constant_color(scratch, to_colorspace(fColor4, fColorSpace.get(), dst).premul());
return true;
}