aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-01-20 08:50:37 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-20 08:50:37 -0800
commit94443b8718fa194bb2077324eade66bd68f99b54 (patch)
treef4b3f11978c9d18d8d49a9230b751f1c218b9f5d /src/core
parentc7bfd5b441c0061e4eb787a9ac97448aee58ada5 (diff)
remove dead code after HQ change
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmapFilter.cpp112
-rw-r--r--src/core/SkBitmapProcState.cpp175
-rw-r--r--src/core/SkBitmapProcState.h23
3 files changed, 0 insertions, 310 deletions
diff --git a/src/core/SkBitmapFilter.cpp b/src/core/SkBitmapFilter.cpp
index fce4c1d5fb..82494d9bbe 100644
--- a/src/core/SkBitmapFilter.cpp
+++ b/src/core/SkBitmapFilter.cpp
@@ -22,86 +22,6 @@
// the image is rotated or has some other complex transformation applied.
// Scaled images will usually be rescaled directly before rasterization.
-namespace {
-
-template <typename Color, typename ColorPacker>
-void highQualityFilter(ColorPacker pack, const SkBitmapProcState& s, int x, int y, Color* SK_RESTRICT colors, int count) {
- const int maxX = s.fBitmap->width();
- const int maxY = s.fBitmap->height();
- SkAutoTMalloc<SkScalar> xWeights(maxX);
- const SkBitmapFilter* filter = s.getBitmapFilter();
-
- while (count-- > 0) {
- SkPoint srcPt;
- s.fInvProc(s.fInvMatrix, x + 0.5f,
- y + 0.5f, &srcPt);
- srcPt.fX -= SK_ScalarHalf;
- srcPt.fY -= SK_ScalarHalf;
-
- SkScalar weight = 0;
- SkScalar fr = 0, fg = 0, fb = 0, fa = 0;
-
- int y0 = SkClampMax(SkScalarCeilToInt(srcPt.fY - filter->width()), maxY);
- int y1 = SkClampMax(SkScalarFloorToInt(srcPt.fY + filter->width() + 1), maxY);
- int x0 = SkClampMax(SkScalarCeilToInt(srcPt.fX - filter->width()), maxX);
- int x1 = SkClampMax(SkScalarFloorToInt(srcPt.fX + filter->width()) + 1, maxX);
-
- for (int srcX = x0; srcX < x1 ; srcX++) {
- // Looking these up once instead of each loop is a ~15% speedup.
- xWeights[srcX - x0] = filter->lookupScalar((srcPt.fX - srcX));
- }
-
- for (int srcY = y0; srcY < y1; srcY++) {
- SkScalar yWeight = filter->lookupScalar((srcPt.fY - srcY));
-
- for (int srcX = x0; srcX < x1 ; srcX++) {
- SkScalar xWeight = xWeights[srcX - x0];
-
- SkScalar combined_weight = SkScalarMul(xWeight, yWeight);
- weight += combined_weight;
-
- SkPMColor c = *s.fBitmap->getAddr32(srcX, srcY);
- if (!c) {
- continue;
- }
- fr += combined_weight * SkGetPackedR32(c);
- fg += combined_weight * SkGetPackedG32(c);
- fb += combined_weight * SkGetPackedB32(c);
- fa += combined_weight * SkGetPackedA32(c);
- }
- }
-
- fr = SkScalarDiv(fr, weight);
- fg = SkScalarDiv(fg, weight);
- fb = SkScalarDiv(fb, weight);
- fa = SkScalarDiv(fa, weight);
-
- int a = SkClampMax(SkScalarRoundToInt(fa), 255);
- int r = SkClampMax(SkScalarRoundToInt(fr), a);
- int g = SkClampMax(SkScalarRoundToInt(fg), a);
- int b = SkClampMax(SkScalarRoundToInt(fb), a);
-
- *colors++ = pack(a, r, g, b);
-
- x++;
- }
-}
-
-uint16_t PackTo565(int /*a*/, int r, int g, int b) {
- return SkPack888ToRGB16(r, g, b);
-}
-
-} // namespace
-
-void highQualityFilter32(const SkBitmapProcState& s, int x, int y, SkPMColor* SK_RESTRICT colors, int count) {
- highQualityFilter(&SkPackARGB32, s, x, y, colors, count);
-}
-
-void highQualityFilter16(const SkBitmapProcState& s, int x, int y, uint16_t* SK_RESTRICT colors, int count) {
- highQualityFilter(&PackTo565, s, x, y, colors, count);
-}
-
-
SK_CONF_DECLARE(const char *, c_bitmapFilter, "bitmap.filter", "mitchell", "Which scanline bitmap filter to use [mitchell, lanczos, hamming, gaussian, triangle, box]");
SkBitmapFilter *SkBitmapFilter::Allocate() {
@@ -124,35 +44,3 @@ SkBitmapFilter *SkBitmapFilter::Allocate() {
return NULL;
}
-bool SkBitmapProcState::setBitmapFilterProcs() {
- if (fFilterLevel != SkPaint::kHigh_FilterLevel) {
- return false;
- }
-
- if (fAlphaScale != 256) {
- return false;
- }
-
- // TODO: consider supporting other colortypes (e.g. 565, A8)
- if (fBitmap->colorType() != kN32_SkColorType) {
- return false;
- }
-
- // TODO: consider supporting repeat and mirror
- if (SkShader::kClamp_TileMode != fTileModeX || SkShader::kClamp_TileMode != fTileModeY) {
- return false;
- }
-
- // TODO: is this right? do we want fBitmapFilter allocated even if we can't set shader procs?
- if (fInvType & (SkMatrix::kAffine_Mask | SkMatrix::kScale_Mask)) {
- fBitmapFilter = SkBitmapFilter::Allocate();
- }
-
- if (fInvType & SkMatrix::kScale_Mask) {
- fShaderProc32 = highQualityFilter32;
- fShaderProc16 = highQualityFilter16;
- return true;
- } else {
- return false;
- }
-}
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index b2c0083261..367b3ff9f9 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -124,160 +124,6 @@ static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) {
< (maximumAllocation * invMat.getScaleX() * invMat.getScaleY());
}
-// TODO -- we may want to pass the clip into this function so we only scale
-// the portion of the image that we're going to need. This will complicate
-// the interface to the cache, but might be well worth it.
-
-bool SkBitmapProcState::possiblyScaleImage() {
- SkASSERT(NULL == fBitmap);
-
- if (fFilterLevel <= SkPaint::kLow_FilterLevel) {
- return false;
- }
- // 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 (non-fractional) scaling component from the matrix.
-
- SkScalar invScaleX = fInvMatrix.getScaleX();
- SkScalar invScaleY = fInvMatrix.getScaleY();
-
- float trueDestWidth = fOrigBitmap.width() / invScaleX;
- float trueDestHeight = fOrigBitmap.height() / invScaleY;
-
- float roundedDestWidth = SkScalarRoundToScalar(trueDestWidth);
- float roundedDestHeight = SkScalarRoundToScalar(trueDestHeight);
-
- if (SkPaint::kHigh_FilterLevel == fFilterLevel &&
- fInvMatrix.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask) &&
- kN32_SkColorType == fOrigBitmap.colorType() &&
- cache_size_okay(fOrigBitmap, fInvMatrix)) {
-
- if (SkScalarNearlyEqual(invScaleX,1.0f) &&
- SkScalarNearlyEqual(invScaleY,1.0f)) {
- // short-circuit identity scaling; the output is supposed to
- // be the same as the input, so we might as well go fast.
-
- // Note(humper): We could also probably do this if the scales
- // are close to -1 as well, since the flip doesn't require
- // any fancy re-sampling...
-
- // Set our filter level to low -- the only post-filtering this
- // image might require is some interpolation if the translation
- // is fractional.
- fFilterLevel = SkPaint::kLow_FilterLevel;
- return false;
- }
-
- if (!SkBitmapCache::Find(fOrigBitmap, roundedDestWidth, roundedDestHeight, &fScaledBitmap)) {
- // All the criteria are met; let's make a new bitmap.
-
- if (!SkBitmapScaler::Resize(&fScaledBitmap,
- fOrigBitmap,
- SkBitmapScaler::RESIZE_BEST,
- roundedDestWidth,
- roundedDestHeight,
- SkResourceCache::GetAllocator())) {
- // we failed to create fScaledBitmap, so just return and let
- // the scanline proc handle it.
- return false;
-
- }
-
- SkASSERT(fScaledBitmap.getPixels());
- fScaledBitmap.setImmutable();
- SkBitmapCache::Add(fOrigBitmap, roundedDestWidth, roundedDestHeight, fScaledBitmap);
- }
-
- SkASSERT(fScaledBitmap.getPixels());
- fBitmap = &fScaledBitmap;
-
- // clean up the inverse matrix by incorporating the scale we just performed.
-
- fInvMatrix.postScale(roundedDestWidth / fOrigBitmap.width(),
- roundedDestHeight / fOrigBitmap.height());
-
- // Set our filter level to low -- the only post-filtering this
- // image might require is some interpolation if the translation
- // is fractional or if there's any remaining scaling to be done.
- fFilterLevel = SkPaint::kLow_FilterLevel;
- return true;
- }
-
- /*
- * If High, then our special-case for scale-only did not take, and so we
- * have to make a choice:
- * 1. fall back on mipmaps + bilerp
- * 2. fall back on scanline bicubic filter
- * For now, we compute the "scale" value from the matrix, and have a
- * threshold to decide when bicubic is better, and when mips are better.
- * No doubt a fancier decision tree could be used uere.
- *
- * If Medium, then we just try to build a mipmap and select a level,
- * setting the filter-level to kLow to signal that we just need bilerp
- * to process the selected level.
- */
-
- SkScalar scaleSqd = effective_matrix_scale_sqrd(fInvMatrix);
-
- if (SkPaint::kHigh_FilterLevel == fFilterLevel) {
- // Set the limit at 0.25 for the CTM... if the CTM is scaling smaller
- // than this, then the mipmaps quality may be greater (certainly faster)
- // so we only keep High quality if the scale is greater than this.
- //
- // Since we're dealing with the inverse, we compare against its inverse.
- const SkScalar bicubicLimit = 4.0f;
- const SkScalar bicubicLimitSqd = bicubicLimit * bicubicLimit;
- if (scaleSqd < bicubicLimitSqd) { // use bicubic scanline
- return false;
- }
-
- // else set the filter-level to Medium, since we're scaling down and
- // want to reqeust mipmaps
- fFilterLevel = SkPaint::kMedium_FilterLevel;
- }
-
- SkASSERT(SkPaint::kMedium_FilterLevel == fFilterLevel);
-
- /**
- * Medium quality means use a mipmap for down-scaling, and just bilper
- * for upscaling. Since we're examining the inverse matrix, we look for
- * a scale > 1 to indicate down scaling by the CTM.
- */
- if (scaleSqd > SK_Scalar1) {
- fCurrMip.reset(SkMipMapCache::FindAndRef(fOrigBitmap));
- if (NULL == fCurrMip.get()) {
- fCurrMip.reset(SkMipMapCache::AddAndRef(fOrigBitmap));
- if (NULL == fCurrMip.get()) {
- return false;
- }
- }
- // diagnostic for a crasher...
- if (NULL == fCurrMip->data()) {
- sk_throw();
- }
-
- SkScalar levelScale = SkScalarInvert(SkScalarSqrt(scaleSqd));
- SkMipMap::Level level;
- if (fCurrMip->extractLevel(levelScale, &level)) {
- SkScalar invScaleFixup = level.fScale;
- fInvMatrix.postScale(invScaleFixup, invScaleFixup);
-
- const SkImageInfo info = fOrigBitmap.info().makeWH(level.fWidth, level.fHeight);
- // todo: if we could wrap the fCurrMip in a pixelref, then we could just install
- // that here, and not need to explicitly track it ourselves.
- fScaledBitmap.installPixels(info, level.fPixels, level.fRowBytes);
- fBitmap = &fScaledBitmap;
- fFilterLevel = SkPaint::kLow_FilterLevel;
- return true;
- } else {
- // failed to extract, so release the mipmap
- fCurrMip.reset(NULL);
- }
- }
-
- return false;
-}
-
/*
* Extract the "best" scale factors from a matrix.
*/
@@ -439,10 +285,6 @@ bool SkBitmapProcState::lockBaseBitmap() {
return true;
}
-SkBitmapProcState::~SkBitmapProcState() {
- SkDELETE(fBitmapFilter);
-}
-
static bool valid_for_drawing(const SkBitmap& bm) {
if (0 == bm.width() || 0 == bm.height()) {
return false; // nothing to draw
@@ -553,23 +395,6 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
- if (SkPaint::kHigh_FilterLevel == fFilterLevel) {
- // If this is still set, that means we wanted HQ sampling
- // but couldn't do it as a preprocess. Let's try to install
- // the scanline version of the HQ sampler. If that process fails,
- // downgrade to bilerp.
-
- // NOTE: Might need to be careful here in the future when we want
- // to have the platform proc have a shot at this; it's possible that
- // the chooseBitmapFilterProc will fail to install a shader but a
- // platform-specific one might succeed, so it might be premature here
- // to fall back to bilerp. This needs thought.
-
- if (!this->setBitmapFilterProcs()) {
- fFilterLevel = SkPaint::kLow_FilterLevel;
- }
- }
-
if (SkPaint::kLow_FilterLevel == fFilterLevel) {
// Only try bilerp if the matrix is "interesting" and
// the image has a suitable size.
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index a7861ef7b3..36e1ae02ae 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -23,10 +23,6 @@ typedef SkFixed3232 SkFractionalInt;
class SkPaint;
struct SkBitmapProcState {
-
- SkBitmapProcState() : fBitmapFilter(NULL) {}
- ~SkBitmapProcState();
-
typedef void (*ShaderProc32)(const SkBitmapProcState&, int x, int y,
SkPMColor[], int count);
@@ -107,8 +103,6 @@ struct SkBitmapProcState {
ShaderProc32 getShaderProc32() const { return fShaderProc32; }
ShaderProc16 getShaderProc16() const { return fShaderProc16; }
- SkBitmapFilter* getBitmapFilter() const { return fBitmapFilter; }
-
#ifdef SK_DEBUG
MatrixProc getMatrixProc() const;
#else
@@ -131,7 +125,6 @@ private:
SkBitmap fScaledBitmap; // chooseProcs
SkAutoTUnref<const SkMipMap> fCurrMip;
- bool fAdjustedMatrix; // set by possiblyScaleImage
void processHQRequest();
void processMediumRequest();
@@ -141,20 +134,10 @@ private:
bool chooseScanlineProcs(bool trivialMatrix, bool clampClamp, const SkPaint& paint);
ShaderProc32 chooseShaderProc32();
- // returns false if we did not try to scale the image. In that case, we
- // will need to "lock" its pixels some other way.
- bool possiblyScaleImage();
-
// returns false if we failed to "lock" the pixels at all. Typically this
// means we have to abort the shader.
bool lockBaseBitmap();
- SkBitmapFilter* fBitmapFilter;
-
- // If supported, sets fShaderProc32 and fShaderProc16 and returns true,
- // otherwise returns false.
- bool setBitmapFilterProcs();
-
// Return false if we failed to setup for fast translate (e.g. overflow)
bool setupForTranslate();
@@ -211,10 +194,4 @@ void S32_D16_filter_DX(const SkBitmapProcState& s,
void S32_D16_filter_DXDY(const SkBitmapProcState& s,
const uint32_t* xy, int count, uint16_t* colors);
-void highQualityFilter32(const SkBitmapProcState &s, int x, int y,
- SkPMColor *SK_RESTRICT colors, int count);
-void highQualityFilter16(const SkBitmapProcState &s, int x, int y,
- uint16_t *SK_RESTRICT colors, int count);
-
-
#endif