Convert image width and height (used by tiling) to float once.
authorMike Klein <mtklein@chromium.org>
Fri, 9 Dec 2016 22:00:32 +0000 (17:00 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 12 Dec 2016 14:00:47 +0000 (14:00 +0000)
The storage cost is the same, so might as well do this when building the pipeline instead of when running it.  This also avoids the awkward cvtsi2ss instruction that screws with register renaming.

CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD

Change-Id: I1c7d5bad558870256a31e3da969eee5d80fb93a8
Reviewed-on: https://skia-review.googlesource.com/5782
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>

src/image/SkImageShader.cpp
src/image/SkImageShaderContext.h
src/opts/SkRasterPipeline_opts.h

index 7a1522b..ce9cbad 100644 (file)
@@ -318,8 +318,8 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dst, SkFal
     ctx->ctable  = pm.ctable();
     ctx->color4f = SkColor4f_from_SkColor(paint.getColor(), dst);
     ctx->stride  = pm.rowBytesAsPixels();
-    ctx->width   = pm.width();
-    ctx->height  = pm.height();
+    ctx->width   = (float)pm.width();
+    ctx->height  = (float)pm.height();
     if (matrix.asAffine(ctx->matrix)) {
         p->append(SkRasterPipeline::matrix_2x3, ctx->matrix);
     } else {
index 3dae6c5..24f17db 100644 (file)
@@ -23,8 +23,8 @@ struct SkImageShaderContext {
     SkColorTable* ctable;
     SkColor4f     color4f;
     int           stride;
-    int           width;
-    int           height;
+    float         width;
+    float         height;
     float         matrix[9];
     float         x[8];
     float         y[8];
index e61e6cb..e06b680 100644 (file)
@@ -796,12 +796,12 @@ SI SkNf mirror(const SkNf& v, float l/*imit*/) {
     result = SkNf::Min(result, nextafterf(l, 0));
     return assert_in_tile(result, l);
 }
-STAGE( clamp_x) { r = clamp (r, *(const int*)ctx); }
-STAGE(repeat_x) { r = repeat(r, *(const int*)ctx); }
-STAGE(mirror_x) { r = mirror(r, *(const int*)ctx); }
-STAGE( clamp_y) { g = clamp (g, *(const int*)ctx); }
-STAGE(repeat_y) { g = repeat(g, *(const int*)ctx); }
-STAGE(mirror_y) { g = mirror(g, *(const int*)ctx); }
+STAGE( clamp_x) { r = clamp (r, *(const float*)ctx); }
+STAGE(repeat_x) { r = repeat(r, *(const float*)ctx); }
+STAGE(mirror_x) { r = mirror(r, *(const float*)ctx); }
+STAGE( clamp_y) { g = clamp (g, *(const float*)ctx); }
+STAGE(repeat_y) { g = repeat(g, *(const float*)ctx); }
+STAGE(mirror_y) { g = mirror(g, *(const float*)ctx); }
 
 STAGE(save_xy) {
     auto sc = (SkImageShaderContext*)ctx;