diff options
author | humper <humper@google.com> | 2014-06-27 11:27:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-27 11:27:03 -0700 |
commit | 4f96ab36180489748f4e9bb249d773414ef0d6cb (patch) | |
tree | 5b1946f21d22e8b266a4e984d2c19d7aafeb0fa6 | |
parent | 1f8ed022226c9f960b9fc95af9297d5111a07ead (diff) |
Refactor bitmap scaler to make it easier to migrate rest of chrome to use it
Previously, the set of platform-specific function pointers to do fast convolution (e.g., neon, SSE) were passed in a structure to the scaler.
I refactored this so that the scaler fills in these function pointers after it's called, so the caller doesn't have to worry about it.
R=mtklein@google.com
TBR=mtklein
NOTRY=True
Author: humper@google.com
Review URL: https://codereview.chromium.org/354193002
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 5 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.h | 7 | ||||
-rw-r--r-- | src/core/SkBitmapScaler.cpp | 4 | ||||
-rw-r--r-- | src/core/SkBitmapScaler.h | 7 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_opts_arm.cpp | 3 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_opts_none.cpp | 4 | ||||
-rw-r--r-- | src/opts/opts_check_x86.cpp | 3 |
7 files changed, 16 insertions, 17 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index f6f9f3fa06..48962cffa4 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -172,16 +172,11 @@ bool SkBitmapProcState::possiblyScaleImage() { // All the criteria are met; let's make a new bitmap. - SkConvolutionProcs simd; - sk_bzero(&simd, sizeof(simd)); - this->platformConvolutionProcs(&simd); - if (!SkBitmapScaler::Resize(&fScaledBitmap, fOrigBitmap, SkBitmapScaler::RESIZE_BEST, dest_width, dest_height, - simd, SkScaledImageCache::GetAllocator())) { // we failed to create fScaledBitmap, so just return and let // the scanline proc handle it. diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index 663bcb8be9..73d7e904b3 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -33,7 +33,6 @@ #endif class SkPaint; -struct SkConvolutionProcs; struct SkBitmapProcState { @@ -104,12 +103,6 @@ struct SkBitmapProcState { */ void platformProcs(); - /** Platforms can also optionally overwrite the convolution functions - if we have SIMD versions of them. - */ - - void platformConvolutionProcs(SkConvolutionProcs*); - /** Given the byte size of the index buffer to be passed to the matrix proc, return the maximum number of resulting pixels that can be computed (i.e. the number of SkPMColor values to be written by the sample proc). diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp index be32a891fc..35e101efa9 100644 --- a/src/core/SkBitmapScaler.cpp +++ b/src/core/SkBitmapScaler.cpp @@ -246,9 +246,11 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr, const SkBitmap& source, ResizeMethod method, float destWidth, float destHeight, - const SkConvolutionProcs& convolveProcs, SkBitmap::Allocator* allocator) { + SkConvolutionProcs convolveProcs= { 0, NULL, NULL, NULL, NULL }; + PlatformConvolutionProcs(&convolveProcs); + SkRect destSubset = { 0, 0, destWidth, destHeight }; // Ensure that the ResizeMethod enumeration is sound. diff --git a/src/core/SkBitmapScaler.h b/src/core/SkBitmapScaler.h index d6636cf34e..ef559df606 100644 --- a/src/core/SkBitmapScaler.h +++ b/src/core/SkBitmapScaler.h @@ -83,8 +83,13 @@ public: const SkBitmap& source, ResizeMethod method, float dest_width, float dest_height, - const SkConvolutionProcs&, SkBitmap::Allocator* allocator = NULL); + + /** Platforms can also optionally overwrite the convolution functions + if we have SIMD versions of them. + */ + + static void PlatformConvolutionProcs(SkConvolutionProcs*); }; #endif diff --git a/src/opts/SkBitmapProcState_opts_arm.cpp b/src/opts/SkBitmapProcState_opts_arm.cpp index ffa0ccfa8a..8f24c39a2e 100644 --- a/src/opts/SkBitmapProcState_opts_arm.cpp +++ b/src/opts/SkBitmapProcState_opts_arm.cpp @@ -6,6 +6,7 @@ */ +#include "SkBitmapScaler.h" #include "SkBitmapProcState.h" #include "SkColorPriv.h" #include "SkPaint.h" @@ -229,6 +230,6 @@ extern void platformConvolutionProcs_arm_neon(SkConvolutionProcs* procs); void platformConvolutionProcs_arm(SkConvolutionProcs* procs) { } -void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) { +void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { SK_ARM_NEON_WRAP(platformConvolutionProcs_arm)(procs); } diff --git a/src/opts/SkBitmapProcState_opts_none.cpp b/src/opts/SkBitmapProcState_opts_none.cpp index 96e711b472..88aaa93e21 100644 --- a/src/opts/SkBitmapProcState_opts_none.cpp +++ b/src/opts/SkBitmapProcState_opts_none.cpp @@ -5,6 +5,8 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + +#include "SkBitmapScaler.h" #include "SkBitmapProcState.h" /* A platform may optionally overwrite any of these with accelerated @@ -23,4 +25,4 @@ void SkBitmapProcState::platformProcs() {} // empty implementation just uses default supplied function pointers -void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs*) {} +void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs*) {} diff --git a/src/opts/opts_check_x86.cpp b/src/opts/opts_check_x86.cpp index b94969890d..603458ba26 100644 --- a/src/opts/opts_check_x86.cpp +++ b/src/opts/opts_check_x86.cpp @@ -8,6 +8,7 @@ #include "SkBitmapFilter_opts_SSE2.h" #include "SkBitmapProcState_opts_SSE2.h" #include "SkBitmapProcState_opts_SSSE3.h" +#include "SkBitmapScaler.h" #include "SkBlitMask.h" #include "SkBlitRect_opts_SSE2.h" #include "SkBlitRow.h" @@ -123,7 +124,7 @@ static inline bool supports_simd(int minLevel) { SK_CONF_DECLARE( bool, c_hqfilter_sse, "bitmap.filter.highQualitySSE", false, "Use SSE optimized version of high quality image filters"); -void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) { +void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) { procs->fExtraHorizontalReads = 3; procs->fConvolveVertically = &convolveVertically_SSE2; |