'<(skia_src_path)/core/SkBitmapProcState_matrixProcs.cpp',
'<(skia_src_path)/core/SkBitmapProcState_sample.h',
'<(skia_src_path)/core/SkBitmapScaler.h',
- '<(skia_src_path)/core/SkBitmapScaler.cpp',
+ '<(skia_src_path)/core/SkBitmapScaler.cpp',
'<(skia_src_path)/core/SkBitmapShader16BilerpTemplate.h',
'<(skia_src_path)/core/SkBitmapShaderTemplate.h',
'<(skia_src_path)/core/SkBitmap_scroll.cpp',
int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy);
bool hasMipMap() const;
void freeMipMap();
-
+
friend struct SkBitmapProcState;
};
float invWidth() const { return fInvWidth; }
virtual float evaluate(float x) const = 0;
virtual ~SkBitmapFilter() {}
-
+
static SkBitmapFilter* Allocate();
protected:
float fWidth;
if (x <= -fWidth || x >= fWidth) {
return 0.0f; // Outside of the window.
}
- if (x > -FLT_EPSILON && x < FLT_EPSILON) {
+ if (x > -FLT_EPSILON && x < FLT_EPSILON) {
return 1.0f; // Special case the discontinuity at the origin.
}
float xpi = x * static_cast<float>(SK_ScalarPI);
return (sk_float_sin(xpi) / xpi) * // sinc(x)
sk_float_sin(xpi / fWidth) / (xpi / fWidth); // sinc(x/fWidth)
- }
+ }
};
if (fFilterQuality != kHQ_BitmapFilter) {
return;
}
-
+
// 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
+ // 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
+ // 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 = SkBitmapScaler::Resize( fOrigBitmap, SkBitmapScaler::RESIZE_BEST,
dest_width, dest_height, fConvolutionProcs );
-
+
fScaledBitmap.lockPixels();
-
+
fBitmap = &fScaledBitmap;
// set the inv matrix type to translate-only;
const uint32_t[],
int count,
uint16_t colors[]);
-
+
typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF
typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF
typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1
IntTileProc fIntTileProcY; // chooseProcs
SkFixed fFilterOneX;
SkFixed fFilterOneY;
-
+
SkConvolutionProcs* fConvolutionProcs; // possiblyScaleImage
SkPMColor fPaintPMColor; // chooseProcs - A8 config
implementation can do nothing (see SkBitmapProcState_opts_none.cpp)
*/
void platformProcs();
-
+
/** Platforms can also optionally overwrite the convolution functions
if we have SIMD versions of them.
*/
-
+
void platformConvolutionProcs();
/** Given the byte size of the index buffer to be passed to the matrix proc,
int destWidth, int destHeight,
const SkIRect& destSubset,
SkConvolutionProcs* convolveProcs);
- ~SkResizeFilter() {
- SkDELETE( fBitmapFilter );
+ ~SkResizeFilter() {
+ SkDELETE( fBitmapFilter );
}
-
+
// Returns the filled filter values.
const SkConvolutionFilter1D& xFilter() { return fXFilter; }
const SkConvolutionFilter1D& yFilter() { return fYFilter; }
private:
-
+
SkBitmapFilter* fBitmapFilter;
// Computes one set of filters either horizontally or vertically. The caller
//
// Likewise, the range of destination values to compute and the scale factor
// for the transform is also specified.
-
+
void computeFilters(int srcSize,
int destSubsetLo, int destSubsetSize,
float scale,
const SkIRect& destSubset,
SkConvolutionProcs* convolveProcs)
: fOutBounds(destSubset) {
-
+
// method will only ever refer to an "algorithm method".
SkASSERT((SkBitmapScaler::RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
(method <= SkBitmapScaler::RESIZE_LAST_ALGORITHM_METHOD));
fBitmapFilter = SkNEW_ARGS(SkMitchellFilter, (1.f/3.f, 1.f/3.f));
break;
}
-
+
float scaleX = static_cast<float>(destWidth) /
static_cast<float>(srcFullWidth);
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SkBitmapScaler_DEFINED
#define SkBitmapScaler_DEFINED
#include "SkBitmap.h"
#include "SkConvolver.h"
-
+
/** \class SkBitmapScaler
Provides the interface for high quality image resampling.
*/
-
+
class SK_API SkBitmapScaler {
-public:
+public:
enum ResizeMethod {
// Quality Methods
//
// on the capabilities (CPU, GPU) of the underlying platform.
// It is possible for all three methods to be mapped to the same
// algorithm on a given platform.
-
+
// Good quality resizing. Fastest resizing with acceptable visual quality.
// This is typically intended for use during interactive layouts
// where slower platforms may want to trade image quality for large
// High quality resizing. The algorithm is picked to favor image quality.
RESIZE_BEST,
-
+
//
// Algorithm-specific enumerations
//
-
+
// Box filter. This is a weighted average of all of the pixels touching
// the destination pixel. For enlargement, this is nearest neighbor.
//
RESIZE_LANCZOS3,
RESIZE_HAMMING,
RESIZE_MITCHELL,
-
+
// enum aliases for first and last methods by algorithm or by quality.
RESIZE_FIRST_QUALITY_METHOD = RESIZE_GOOD,
RESIZE_LAST_QUALITY_METHOD = RESIZE_BEST,
RESIZE_FIRST_ALGORITHM_METHOD = RESIZE_BOX,
RESIZE_LAST_ALGORITHM_METHOD = RESIZE_MITCHELL,
};
-
+
// Resizes the given source bitmap using the specified resize method, so that
// the entire image is (dest_size) big. The dest_subset is the rectangle in
// this destination image that should actually be returned.
//
// We only need to do this when generating the final output row (here).
int maxColorChannel = SkTMax(outRow[byteOffset + 0],
- SkTMax(outRow[byteOffset + 1],
+ SkTMax(outRow[byteOffset + 1],
outRow[byteOffset + 2]));
if (alpha < maxColorChannel) {
outRow[byteOffset + 3] = maxColorChannel;
// filter values are put into the corresponding out arguments (see AddFilter
// above for what these mean), and a pointer to the first scaling factor is
// returned. There will be |filterLength| values in this array.
- inline const ConvolutionFixed* FilterForValue(int valueOffset,
+ inline const ConvolutionFixed* FilterForValue(int valueOffset,
int* filterOffset,
int* filterLength) const {
const FilterInstance& filter = fFilters[valueOffset];
int* filterOffset,
int* filterLength) const;
- // Add another value to the fFilterValues array -- useful for
+ // Add another value to the fFilterValues array -- useful for
// SIMD padding which happens outside of this class.
-
+
void addFilterValue( ConvolutionFixed val ) {
fFilterValues.push_back( val );
}
return texture;
}
-static GrTexture* create_scratch_texture(GrGpu* gpu,
- GrResourceCache* textureCache,
+static GrTexture* create_scratch_texture(GrGpu* gpu,
+ GrResourceCache* textureCache,
const GrTextureDesc& desc) {
GrTexture* texture = gpu->createTexture(desc, NULL, 0);
if (NULL != texture) {
/**
* Set the callback the cache should use when it is still over budget
* after a purge. The 'data' provided here will be passed back to the
- * callback. Note that the cache will attempt to purge any resources newly
+ * callback. Note that the cache will attempt to purge any resources newly
* freed by the callback.
*/
void setOverbudgetCallback(PFOverbudgetCB overbudgetCB, void* data) {
void SkBitmapProcState::platformConvolutionProcs() {
// no specialization for ARM here yet.
-}
\ No newline at end of file
+}
return tool_main(argc, argv);
}
#endif
-
-