optimize for diff matrix types
Bug: skia: Change-Id: I671e07c5bbb9e4ced92303c9959143324f7a6bdc Reviewed-on: https://skia-review.googlesource.com/21523 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
parent
1efedd948d
commit
7aad8cc2ff
@ -83,13 +83,44 @@ void SkRasterPipeline::append_from_srgb_dst(SkAlphaType at) {
|
||||
}
|
||||
}
|
||||
|
||||
//static int gCounts[5] = { 0, 0, 0, 0, 0 };
|
||||
|
||||
void SkRasterPipeline::append_matrix(SkArenaAlloc* alloc, const SkMatrix& matrix) {
|
||||
float* storage = alloc->makeArray<float>(9);
|
||||
// TODO: consider adding special stages for scale+translate and possibly just translate.
|
||||
if (matrix.asAffine(storage)) {
|
||||
this->append(SkRasterPipeline::matrix_2x3, storage);
|
||||
SkMatrix::TypeMask mt = matrix.getType();
|
||||
#if 0
|
||||
if (mt > 4) mt = 4;
|
||||
gCounts[mt] += 1;
|
||||
SkDebugf("matrices: %d %d %d %d %d\n",
|
||||
gCounts[0], gCounts[1], gCounts[2], gCounts[3], gCounts[4]);
|
||||
#endif
|
||||
|
||||
// Based on a histogram of skps, we determined the following special cases were common, more
|
||||
// or fewer can be used if client behaviors change.
|
||||
|
||||
if (mt == SkMatrix::kIdentity_Mask) {
|
||||
return;
|
||||
}
|
||||
if (mt == SkMatrix::kTranslate_Mask) {
|
||||
float* trans = alloc->makeArrayDefault<float>(2);
|
||||
trans[0] = matrix.getTranslateX();
|
||||
trans[1] = matrix.getTranslateY();
|
||||
this->append(SkRasterPipeline::matrix_translate, trans);
|
||||
} else if ((mt | (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) ==
|
||||
(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) {
|
||||
float* scaleTrans = alloc->makeArrayDefault<float>(4);
|
||||
scaleTrans[0] = matrix.getTranslateX();
|
||||
scaleTrans[1] = matrix.getTranslateY();
|
||||
scaleTrans[2] = matrix.getScaleX();
|
||||
scaleTrans[3] = matrix.getScaleY();
|
||||
this->append(SkRasterPipeline::matrix_scale_translate, scaleTrans);
|
||||
} else {
|
||||
matrix.get9(storage);
|
||||
this->append(SkRasterPipeline::matrix_perspective, storage);
|
||||
float* storage = alloc->makeArrayDefault<float>(9);
|
||||
if (matrix.asAffine(storage)) {
|
||||
// note: asAffine and the 2x3 stage really only need 6 entries
|
||||
this->append(SkRasterPipeline::matrix_2x3, storage);
|
||||
} else {
|
||||
matrix.get9(storage);
|
||||
this->append(SkRasterPipeline::matrix_perspective, storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ struct SkJumper_constants;
|
||||
M(hue) M(saturation) M(color) M(luminosity) \
|
||||
M(srcover_rgba_8888) \
|
||||
M(luminance_to_alpha) \
|
||||
M(matrix_translate) M(matrix_scale_translate) \
|
||||
M(matrix_2x3) M(matrix_3x4) M(matrix_4x5) M(matrix_4x3) \
|
||||
M(matrix_perspective) \
|
||||
M(parametric_r) M(parametric_g) M(parametric_b) \
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1046,6 +1046,18 @@ STAGE(luminance_to_alpha) {
|
||||
r = g = b = 0;
|
||||
}
|
||||
|
||||
STAGE(matrix_translate) {
|
||||
auto m = (const float*)ctx;
|
||||
|
||||
r += m[0];
|
||||
g += m[1];
|
||||
}
|
||||
STAGE(matrix_scale_translate) {
|
||||
auto m = (const float*)ctx;
|
||||
|
||||
r = mad(r,m[2], m[0]);
|
||||
g = mad(g,m[3], m[1]);
|
||||
}
|
||||
STAGE(matrix_2x3) {
|
||||
auto m = (const float*)ctx;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user