Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: src/core/SkBitmapProcState.cpp

Issue 19335002: Production quality fast image up/downsampler (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: camel case and if-statement braces Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapScaler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.cpp
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index a8a9b03d9ad7e13e00eb991d005114040c957849..57af1440347899a13a29a8522e72b6935c965b53 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -11,6 +11,7 @@
#include "SkPaint.h"
#include "SkShader.h" // for tilemodes
#include "SkUtilsArm.h"
+#include "SkBitmapScaler.h"
#if !SK_ARM_NEON_IS_NONE
// These are defined in src/opts/SkBitmapProcState_arm_neon.cpp
@@ -99,23 +100,45 @@ void SkBitmapProcState::possiblyScaleImage() {
if (fFilterQuality != kHQ_BitmapFilter) {
return;
}
-
- // STEP 1: UPSAMPLE?
-
- // Check to see if the transformation matrix is scaling up, and if
- // the matrix is simple, and if we're doing high quality scaling.
- // If so, do the bitmap scale here and remove the scaling component from the matrix.
-
- if (fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) &&
- (fInvMatrix.getScaleX() < 1 || fInvMatrix.getScaleY() < 1) &&
+
+ // see if our platform has any specialized convolution code.
+
+
+ // Set up a pointer to a local (instead of storing the structure in the
+ // proc state) to avoid introducing a header dependency; this makes
+ // recompiles a lot less painful.
+
+ SkConvolutionProcs simd;
+ fConvolutionProcs = &simd;
+
+ fConvolutionProcs->fExtraHorizontalReads = 0;
+ fConvolutionProcs->fConvolveVertically = NULL;
+ fConvolutionProcs->fConvolve4RowsHorizontally = NULL;
+ fConvolutionProcs->fConvolveHorizontally = NULL;
+ fConvolutionProcs->fApplySIMDPadding = NULL;
+
+ this->platformConvolutionProcs();
+
+ // STEP 1: Highest quality direct scale?
+
+ // Check to see if the transformation matrix is simple, and if we're
+ // doing high quality scaling. If so, do the bitmap scale here and
+ // remove the scaling component from the matrix.
+
+ if (fFilterQuality == kHQ_BitmapFilter &&
+ fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) &&
fOrigBitmap.config() == SkBitmap::kARGB_8888_Config) {
-
+
+ int dest_width = SkScalarCeilToInt(fOrigBitmap.width() / fInvMatrix.getScaleX());
+ int dest_height = SkScalarCeilToInt(fOrigBitmap.height() / fInvMatrix.getScaleY());
+
// All the criteria are met; let's make a new bitmap.
- fScaledBitmap.setConfig(SkBitmap::kARGB_8888_Config,
- (int)(fOrigBitmap.width() / fInvMatrix.getScaleX()),
- (int)(fOrigBitmap.height() / fInvMatrix.getScaleY()));
- fScaledBitmap.allocPixels();
- fOrigBitmap.scale(&fScaledBitmap);
+
+ fScaledBitmap = SkBitmapScaler::Resize( fOrigBitmap, SkBitmapScaler::RESIZE_BEST,
+ dest_width, dest_height, fConvolutionProcs );
+
+ fScaledBitmap.lockPixels();
+
fBitmap = &fScaledBitmap;
// set the inv matrix type to translate-only;
@@ -130,9 +153,9 @@ void SkBitmapProcState::possiblyScaleImage() {
return;
}
- if (!fOrigBitmap.hasMipMap()) {
+ if (!fOrigBitmap.hasMipMap() && fFilterQuality != kNone_BitmapFilter) {
- // STEP 2: DOWNSAMPLE
+ // STEP 2: MIPMAP DOWNSAMPLE?
// Check to see if the transformation matrix is scaling *down*.
// If so, automatically build mipmaps.
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | src/core/SkBitmapScaler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698