aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapController.cpp37
-rw-r--r--src/core/SkBitmapController.h4
-rw-r--r--src/core/SkBitmapProcShader.cpp22
-rw-r--r--src/core/SkBitmapProcState.cpp63
-rw-r--r--src/core/SkBitmapProcState.h2
-rw-r--r--src/core/SkBitmapProcState_matrix.h12
-rw-r--r--src/core/SkBitmapProcState_matrixProcs.cpp21
-rw-r--r--src/core/SkBitmapProcState_matrix_template.h12
-rw-r--r--src/core/SkBitmapProcState_procs.h44
-rw-r--r--src/core/SkBitmapProcState_sample.h34
-rw-r--r--src/core/SkBitmapProcState_shaderproc.h8
-rw-r--r--src/opts/SkBitmapProcState_matrix_neon.h31
-rw-r--r--src/opts/SkBitmapProcState_opts_SSE2.cpp36
-rw-r--r--src/opts/SkBitmapProcState_opts_SSSE3.cpp12
-rw-r--r--src/opts/SkBitmapProcState_opts_arm.cpp23
-rw-r--r--src/opts/SkBitmapProcState_opts_mips_dsp.cpp20
16 files changed, 199 insertions, 182 deletions
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp
index 484db8eba4..dd7eb6f36f 100644
--- a/src/core/SkBitmapController.cpp
+++ b/src/core/SkBitmapController.cpp
@@ -42,12 +42,9 @@ SkBitmapController::State* SkBitmapController::requestBitmap(const SkBitmap& bm,
State* state = this->onRequestBitmap(bm, inv, quality, storage, storageSize);
if (state) {
- if (!state->fLockedBitmap.getPixels()) {
- state->fLockedBitmap.lockPixels();
- if (!state->fLockedBitmap.getPixels()) {
- SkInPlaceDeleteCheck(state, storage);
- state = NULL;
- }
+ if (NULL == state->fPixmap.addr()) {
+ SkInPlaceDeleteCheck(state, storage);
+ state = NULL;
}
}
return state;
@@ -65,6 +62,7 @@ public:
SkDefaultBitmapControllerState(const SkBitmap& src, const SkMatrix& inv, SkFilterQuality qual);
private:
+ SkBitmap fResultBitmap;
SkAutoTUnref<const SkMipMap> fCurrMip;
bool processHQRequest(const SkBitmap& orig);
@@ -123,8 +121,8 @@ bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmap& origBitmap
SkScalar roundedDestWidth = SkScalarRoundToScalar(trueDestWidth);
SkScalar roundedDestHeight = SkScalarRoundToScalar(trueDestHeight);
- if (!SkBitmapCache::Find(origBitmap, roundedDestWidth, roundedDestHeight, &fLockedBitmap)) {
- if (!SkBitmapScaler::Resize(&fLockedBitmap,
+ if (!SkBitmapCache::Find(origBitmap, roundedDestWidth, roundedDestHeight, &fResultBitmap)) {
+ if (!SkBitmapScaler::Resize(&fResultBitmap,
origBitmap,
SkBitmapScaler::RESIZE_BEST,
roundedDestWidth,
@@ -133,12 +131,12 @@ bool SkDefaultBitmapControllerState::processHQRequest(const SkBitmap& origBitmap
return false; // we failed to create fScaledBitmap
}
- SkASSERT(fLockedBitmap.getPixels());
- fLockedBitmap.setImmutable();
- SkBitmapCache::Add(origBitmap, roundedDestWidth, roundedDestHeight, fLockedBitmap);
+ SkASSERT(fResultBitmap.getPixels());
+ fResultBitmap.setImmutable();
+ SkBitmapCache::Add(origBitmap, roundedDestWidth, roundedDestHeight, fResultBitmap);
}
- SkASSERT(fLockedBitmap.getPixels());
+ SkASSERT(fResultBitmap.getPixels());
fInvMatrix.postScale(roundedDestWidth / origBitmap.width(),
roundedDestHeight / origBitmap.height());
@@ -188,7 +186,7 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmap& origBi
const SkImageInfo info = origBitmap.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.
- return fLockedBitmap.installPixels(info, level.fPixels, level.fRowBytes);
+ return fResultBitmap.installPixels(info, level.fPixels, level.fRowBytes);
} else {
// failed to extract, so release the mipmap
fCurrMip.reset(NULL);
@@ -203,10 +201,19 @@ SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(const SkBitmap& s
fInvMatrix = inv;
fQuality = qual;
- if (!this->processHQRequest(src) && !this->processMediumRequest(src)) {
- fLockedBitmap = src;
+ if (this->processHQRequest(src) || this->processMediumRequest(src)) {
+ SkASSERT(fResultBitmap.getPixels());
+ } else {
+ fResultBitmap = src;
+ fResultBitmap.lockPixels();
+ // lock may fail to give us pixels
}
SkASSERT(fQuality <= kLow_SkFilterQuality);
+
+ // fResultBitmap.getPixels() may be null, but our caller knows to check fPixmap.addr()
+ // and will destroy us if it is NULL.
+ fPixmap.reset(fResultBitmap.info(), fResultBitmap.getPixels(), fResultBitmap.rowBytes(),
+ fResultBitmap.getColorTable());
}
SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBitmap& bm,
diff --git a/src/core/SkBitmapController.h b/src/core/SkBitmapController.h
index bc3c69691c..ead4b783bd 100644
--- a/src/core/SkBitmapController.h
+++ b/src/core/SkBitmapController.h
@@ -21,12 +21,12 @@ public:
public:
virtual ~State() {}
- const SkBitmap& lockedBitmap() const { return fLockedBitmap; }
+ const SkPixmap& pixmap() const { return fPixmap; }
const SkMatrix& invMatrix() const { return fInvMatrix; }
SkFilterQuality quality() const { return fQuality; }
protected:
- SkBitmap fLockedBitmap;
+ SkPixmap fPixmap;
SkMatrix fInvMatrix;
SkFilterQuality fQuality;
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index c1a03fecaf..e17e60b00e 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -117,22 +117,22 @@ SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(
: INHERITED(shader, rec)
, fState(state)
{
- const SkBitmap& bitmap = *fState->fBitmap;
- bool bitmapIsOpaque = bitmap.isOpaque();
+ const SkPixmap& pixmap = fState->fPixmap;
+ bool isOpaque = pixmap.isOpaque();
// update fFlags
uint32_t flags = 0;
- if (bitmapIsOpaque && (255 == this->getPaintAlpha())) {
+ if (isOpaque && (255 == this->getPaintAlpha())) {
flags |= kOpaqueAlpha_Flag;
}
- switch (bitmap.colorType()) {
+ switch (pixmap.colorType()) {
case kRGB_565_SkColorType:
flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag);
break;
case kIndex_8_SkColorType:
case kN32_SkColorType:
- if (bitmapIsOpaque) {
+ if (isOpaque) {
flags |= kHasSpan16_Flag;
}
break;
@@ -142,14 +142,14 @@ SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(
break;
}
- if (rec.fPaint->isDither() && bitmap.colorType() != kRGB_565_SkColorType) {
+ if (rec.fPaint->isDither() && pixmap.colorType() != kRGB_565_SkColorType) {
// gradients can auto-dither in their 16bit sampler, but we don't so
// we clear the flag here.
flags &= ~kHasSpan16_Flag;
}
// if we're only 1-pixel high, and we don't rotate, then we can claim this
- if (1 == bitmap.height() &&
+ if (1 == pixmap.height() &&
only_scale_and_translate(this->getTotalInverse())) {
flags |= kConstInY32_Flag;
if (flags & kHasSpan16_Flag) {
@@ -190,9 +190,7 @@ void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo
SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32();
int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX);
- SkASSERT(state.fBitmap->getPixels());
- SkASSERT(state.fBitmap->pixelRef() == NULL ||
- state.fBitmap->pixelRef()->isLocked());
+ SkASSERT(state.fPixmap.addr());
for (;;) {
int n = count;
@@ -243,9 +241,7 @@ void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint
SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16();
int max = state.maxCountForBufferSize(sizeof(buffer));
- SkASSERT(state.fBitmap->getPixels());
- SkASSERT(state.fBitmap->pixelRef() == NULL ||
- state.fBitmap->pixelRef()->isLocked());
+ SkASSERT(state.fPixmap.addr());
for (;;) {
int n = count;
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 314fdd74c6..2227010da3 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -54,12 +54,12 @@ static bool matrix_only_scale_translate(const SkMatrix& m) {
* For the purposes of drawing bitmaps, if a matrix is "almost" translate
* go ahead and treat it as if it were, so that subsequent code can go fast.
*/
-static bool just_trans_clamp(const SkMatrix& matrix, const SkBitmap& bitmap) {
+static bool just_trans_clamp(const SkMatrix& matrix, const SkPixmap& pixmap) {
SkASSERT(matrix_only_scale_translate(matrix));
if (matrix.getType() & SkMatrix::kScale_Mask) {
- SkRect src, dst;
- bitmap.getBounds(&src);
+ SkRect dst;
+ SkRect src = SkRect::Make(pixmap.bounds());
// Can't call mapRect(), since that will fix up inverted rectangles,
// e.g. when scale is negative, and we don't want to return true for
@@ -74,7 +74,7 @@ static bool just_trans_clamp(const SkMatrix& matrix, const SkBitmap& bitmap) {
// phase (in pixel space) that any translate in the matrix might impart.
SkIRect idst;
dst.round(&idst);
- return idst.width() == bitmap.width() && idst.height() == bitmap.height();
+ return idst.width() == pixmap.width() && idst.height() == pixmap.height();
}
// if we got here, we're either kTranslate_Mask or identity
return true;
@@ -114,20 +114,21 @@ static bool valid_for_filtering(unsigned dimension) {
* and may be removed.
*/
bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
- fBitmap = NULL;
+ fPixmap.reset();
fInvMatrix = inv;
fFilterLevel = paint.getFilterQuality();
SkDefaultBitmapController controller;
fBMState = controller.requestBitmap(fOrigBitmap, inv, paint.getFilterQuality(),
fBMStateStorage.get(), fBMStateStorage.size());
- if (NULL == fBMState) {
+ // Note : we allow the controller to return an empty (zero-dimension) result. Should we?
+ if (NULL == fBMState || fBMState->pixmap().info().isEmpty()) {
return false;
}
- fBitmap = &fBMState->lockedBitmap();
+ fPixmap = fBMState->pixmap();
fInvMatrix = fBMState->invMatrix();
fFilterLevel = fBMState->quality();
- SkASSERT(fBitmap->getPixels());
+ SkASSERT(fPixmap.addr());
bool trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0;
bool clampClamp = SkShader::kClamp_TileMode == fTileModeX &&
@@ -141,7 +142,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
// in both X and Y since clamping to width,height is just as easy as to 0xFFFF.
if (!(clampClamp || trivialMatrix)) {
- fInvMatrix.postIDiv(fBitmap->width(), fBitmap->height());
+ fInvMatrix.postIDiv(fPixmap.width(), fPixmap.height());
}
// Now that all possible changes to the matrix have taken place, check
@@ -155,7 +156,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
if (matrix_only_scale_translate(fInvMatrix)) {
SkMatrix forward;
if (fInvMatrix.invert(&forward)) {
- if (clampClamp ? just_trans_clamp(forward, *fBitmap)
+ if (clampClamp ? just_trans_clamp(forward, fPixmap)
: just_trans_general(forward)) {
SkScalar tx = -SkScalarRoundToScalar(forward.getTranslateX());
SkScalar ty = -SkScalarRoundToScalar(forward.getTranslateY());
@@ -188,7 +189,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
// the image has a suitable size.
if (fInvType <= SkMatrix::kTranslate_Mask ||
- !valid_for_filtering(fBitmap->width() | fBitmap->height()))
+ !valid_for_filtering(fPixmap.width() | fPixmap.height()))
{
fFilterLevel = kNone_SkFilterQuality;
}
@@ -207,7 +208,7 @@ bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp,
///////////////////////////////////////////////////////////////////////
- const SkAlphaType at = fBitmap->alphaType();
+ const SkAlphaType at = fPixmap.alphaType();
// No need to do this if we're doing HQ sampling; if filter quality is
// still set to HQ by the time we get here, then we must have installed
@@ -226,7 +227,7 @@ bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp,
index |= 4;
}
// bits 3,4,5 encoding the source bitmap format
- switch (fBitmap->colorType()) {
+ switch (fPixmap.colorType()) {
case kN32_SkColorType:
if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) {
return false;
@@ -383,8 +384,8 @@ static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
SkASSERT(count > 0 && colors != NULL);
SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
- const int maxX = s.fBitmap->width() - 1;
- const int maxY = s.fBitmap->height() - 1;
+ const int maxX = s.fPixmap.width() - 1;
+ const int maxY = s.fPixmap.height() - 1;
int ix = s.fFilterOneX + x;
int iy = SkClampMax(s.fFilterOneY + y, maxY);
#ifdef SK_DEBUG
@@ -399,7 +400,7 @@ static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
SkASSERT(ix == ix2);
}
#endif
- const SkPMColor* row = s.fBitmap->getAddr32(0, iy);
+ const SkPMColor* row = s.fPixmap.addr32(0, iy);
// clamp to the left
if (ix < 0) {
@@ -457,8 +458,8 @@ static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
SkASSERT(count > 0 && colors != NULL);
SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
- const int stopX = s.fBitmap->width();
- const int stopY = s.fBitmap->height();
+ const int stopX = s.fPixmap.width();
+ const int stopY = s.fPixmap.height();
int ix = s.fFilterOneX + x;
int iy = sk_int_mod(s.fFilterOneY + y, stopY);
#ifdef SK_DEBUG
@@ -473,7 +474,7 @@ static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s,
SkASSERT(ix == ix2);
}
#endif
- const SkPMColor* row = s.fBitmap->getAddr32(0, iy);
+ const SkPMColor* row = s.fPixmap.addr32(0, iy);
ix = sk_int_mod(ix, stopX);
for (;;) {
@@ -495,7 +496,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0);
SkASSERT(s.fInvKy == 0);
SkASSERT(count > 0 && colors != NULL);
- SkASSERT(1 == s.fBitmap->width());
+ SkASSERT(1 == s.fPixmap.width());
int iY0;
int iY1 SK_INIT_TO_AVOID_WARNING;
@@ -525,7 +526,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
// its own tiling and sampling we need to undo that here.
if (SkShader::kClamp_TileMode != s.fTileModeX ||
SkShader::kClamp_TileMode != s.fTileModeY) {
- yTemp = SkScalarFloorToInt(pt.fY * s.fBitmap->height());
+ yTemp = SkScalarFloorToInt(pt.fY * s.fPixmap.height());
} else {
yTemp = SkScalarFloorToInt(pt.fY);
}
@@ -533,7 +534,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
yTemp = s.fFilterOneY + y;
}
- const int stopY = s.fBitmap->height();
+ const int stopY = s.fPixmap.height();
switch (s.fTileModeY) {
case SkShader::kClamp_TileMode:
iY0 = SkClampMax(yTemp, stopY-1);
@@ -557,7 +558,7 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
if (s.fInvType > SkMatrix::kTranslate_Mask &&
(SkShader::kClamp_TileMode != s.fTileModeX ||
SkShader::kClamp_TileMode != s.fTileModeY)) {
- pt.fY *= s.fBitmap->height();
+ pt.fY *= s.fPixmap.height();
}
int iY2;
@@ -579,11 +580,11 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
#endif
}
- const SkPMColor* row0 = s.fBitmap->getAddr32(0, iY0);
+ const SkPMColor* row0 = s.fPixmap.addr32(0, iY0);
SkPMColor color;
if (kNone_SkFilterQuality != s.fFilterLevel) {
- const SkPMColor* row1 = s.fBitmap->getAddr32(0, iY1);
+ const SkPMColor* row1 = s.fPixmap.addr32(0, iY1);
if (s.fAlphaScale < 256) {
Filter_32_alpha(iSubY, *row0, *row1, &color, s.fAlphaScale);
@@ -631,13 +632,13 @@ bool SkBitmapProcState::setupForTranslate() {
SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() {
- if (kN32_SkColorType != fBitmap->colorType()) {
+ if (kN32_SkColorType != fPixmap.colorType()) {
return NULL;
}
static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask;
- if (1 == fBitmap->width() && 0 == (fInvType & ~kMask)) {
+ if (1 == fPixmap.width() && 0 == (fInvType & ~kMask)) {
if (kNone_SkFilterQuality == fFilterLevel &&
fInvType <= SkMatrix::kTranslate_Mask &&
!this->setupForTranslate()) {
@@ -752,7 +753,7 @@ void SkBitmapProcState::DebugMatrixProc(const SkBitmapProcState& state,
} else {
proc = state.fFilterLevel != kNone_SkFilterQuality ? check_affine_filter : check_affine_nofilter;
}
- proc(bitmapXY, count, state.fBitmap->width(), state.fBitmap->height());
+ proc(bitmapXY, count, state.fPixmap.width(), state.fPixmap.height());
}
SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const {
@@ -799,7 +800,7 @@ void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const SkBitmapProcState& s, in
SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask |
SkMatrix::kScale_Mask)) == 0);
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
SkFractionalInt fx;
int dstY;
{
@@ -807,12 +808,12 @@ void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const SkBitmapProcState& s, in
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf,
&pt);
fx = SkScalarToFractionalInt(pt.fY);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
dstY = SkClampMax(SkFractionalIntToInt(fx), maxY);
fx = SkScalarToFractionalInt(pt.fX);
}
- const SkPMColor* SK_RESTRICT src = s.fBitmap->getAddr32(0, dstY);
+ const SkPMColor* SK_RESTRICT src = s.fPixmap.addr32(0, dstY);
const SkFractionalInt dx = s.fInvSxFractionalInt;
// Check if we're safely inside [0...maxX] so no need to clamp each computed index.
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 0afc7737de..31d114291c 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -52,7 +52,7 @@ struct SkBitmapProcState {
typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF
typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1
- const SkBitmap* fBitmap; // chooseProcs - orig or scaled
+ SkPixmap fPixmap;
SkMatrix fInvMatrix; // copy of what is in fBMState, can we remove the dup?
SkMatrix::MapXYProc fInvProc; // chooseProcs
diff --git a/src/core/SkBitmapProcState_matrix.h b/src/core/SkBitmapProcState_matrix.h
index b71c3c3b75..bdab846496 100644
--- a/src/core/SkBitmapProcState_matrix.h
+++ b/src/core/SkBitmapProcState_matrix.h
@@ -55,7 +55,7 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s,
PREAMBLE(s);
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
const SkFixed one = s.fFilterOneX;
const SkFractionalInt dx = s.fInvSxFractionalInt;
SkFractionalInt fx;
@@ -65,7 +65,7 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s,
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
// compute our two Y values up front
*xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y);
// now initialize fx
@@ -106,8 +106,8 @@ void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1);
SkFixed dx = s.fInvSx;
SkFixed dy = s.fInvKy;
- unsigned maxX = s.fBitmap->width() - 1;
- unsigned maxY = s.fBitmap->height() - 1;
+ unsigned maxX = s.fPixmap.width() - 1;
+ unsigned maxY = s.fPixmap.height() - 1;
do {
*xy++ = PACK_FILTER_Y_NAME(fy, maxY, oneY PREAMBLE_ARG_Y);
@@ -123,8 +123,8 @@ void PERSP_FILTER_NAME(const SkBitmapProcState& s,
SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
PREAMBLE(s);
- unsigned maxX = s.fBitmap->width() - 1;
- unsigned maxY = s.fBitmap->height() - 1;
+ unsigned maxX = s.fPixmap.width() - 1;
+ unsigned maxY = s.fPixmap.height() - 1;
SkFixed oneX = s.fFilterOneX;
SkFixed oneY = s.fFilterOneY;
diff --git a/src/core/SkBitmapProcState_matrixProcs.cpp b/src/core/SkBitmapProcState_matrixProcs.cpp
index b7a2ccbdd0..1870a0e50e 100644
--- a/src/core/SkBitmapProcState_matrixProcs.cpp
+++ b/src/core/SkBitmapProcState_matrixProcs.cpp
@@ -1,3 +1,12 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+// The copyright below was added in 2009, but I see no record of moto contributions...?
+
/* NEON optimized code (C) COPYRIGHT 2009 Motorola
*
* Use of this source code is governed by a BSD-style license that can be
@@ -321,7 +330,7 @@ static int nofilter_trans_preamble(const SkBitmapProcState& s, uint32_t** xy,
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
**xy = s.fIntTileProcY(SkScalarToFixed(pt.fY) >> 16,
- s.fBitmap->height());
+ s.fPixmap.height());
*xy += 1; // bump the ptr
// return our starting X position
return SkScalarToFixed(pt.fX) >> 16;
@@ -332,7 +341,7 @@ static void clampx_nofilter_trans(const SkBitmapProcState& s,
SkASSERT((s.fInvType & ~SkMatrix::kTranslate_Mask) == 0);
int xpos = nofilter_trans_preamble(s, &xy, x, y);
- const int width = s.fBitmap->width();
+ const int width = s.fPixmap.width();
if (1 == width) {
// all of the following X values must be 0
memset(xy, 0, count * sizeof(uint16_t));
@@ -380,7 +389,7 @@ static void repeatx_nofilter_trans(const SkBitmapProcState& s,
SkASSERT((s.fInvType & ~SkMatrix::kTranslate_Mask) == 0);
int xpos = nofilter_trans_preamble(s, &xy, x, y);
- const int width = s.fBitmap->width();
+ const int width = s.fPixmap.width();
if (1 == width) {
// all of the following X values must be 0
memset(xy, 0, count * sizeof(uint16_t));
@@ -420,7 +429,7 @@ static void mirrorx_nofilter_trans(const SkBitmapProcState& s,
SkASSERT((s.fInvType & ~SkMatrix::kTranslate_Mask) == 0);
int xpos = nofilter_trans_preamble(s, &xy, x, y);
- const int width = s.fBitmap->width();
+ const int width = s.fPixmap.width();
if (1 == width) {
// all of the following X values must be 0
memset(xy, 0, count * sizeof(uint16_t));
@@ -507,8 +516,8 @@ SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc(bool trivial_m
}
// all remaining procs use this form for filterOne
- fFilterOneX = SK_Fixed1 / fBitmap->width();
- fFilterOneY = SK_Fixed1 / fBitmap->height();
+ fFilterOneX = SK_Fixed1 / fPixmap.width();
+ fFilterOneY = SK_Fixed1 / fPixmap.height();
if (SkShader::kRepeat_TileMode == fTileModeX && SkShader::kRepeat_TileMode == fTileModeY) {
return SK_ARM_NEON_WRAP(RepeatX_RepeatY_Procs)[index];
diff --git a/src/core/SkBitmapProcState_matrix_template.h b/src/core/SkBitmapProcState_matrix_template.h
index 4b0044b46a..468013c30d 100644
--- a/src/core/SkBitmapProcState_matrix_template.h
+++ b/src/core/SkBitmapProcState_matrix_template.h
@@ -19,14 +19,14 @@ void NoFilterProc_Scale(const SkBitmapProcState& s, uint32_t xy[],
// we store y, x, x, x, x, x
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
SkFractionalInt fx;
{
SkPoint pt;
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
fx = SkScalarToFractionalInt(pt.fY);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
*xy++ = TileProc::Y(s, SkFractionalIntToFixed(fx), maxY);
fx = SkScalarToFractionalInt(pt.fX);
}
@@ -89,8 +89,8 @@ void NoFilterProc_Affine(const SkBitmapProcState& s, uint32_t xy[],
SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY);
SkFractionalInt dx = s.fInvSxFractionalInt;
SkFractionalInt dy = s.fInvKyFractionalInt;
- int maxX = s.fBitmap->width() - 1;
- int maxY = s.fBitmap->height() - 1;
+ int maxX = s.fPixmap.width() - 1;
+ int maxY = s.fPixmap.height() - 1;
for (int i = count; i > 0; --i) {
*xy++ = (TileProc::Y(s, SkFractionalIntToFixed(fy), maxY) << 16) |
@@ -104,8 +104,8 @@ void NoFilterProc_Persp(const SkBitmapProcState& s, uint32_t* SK_RESTRICT xy,
int count, int x, int y) {
SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
- int maxX = s.fBitmap->width() - 1;
- int maxY = s.fBitmap->height() - 1;
+ int maxX = s.fPixmap.width() - 1;
+ int maxY = s.fPixmap.height() - 1;
SkPerspIter iter(s.fInvMatrix,
SkIntToScalar(x) + SK_ScalarHalf,
diff --git a/src/core/SkBitmapProcState_procs.h b/src/core/SkBitmapProcState_procs.h
index a9b87501b4..03e192719c 100644
--- a/src/core/SkBitmapProcState_procs.h
+++ b/src/core/SkBitmapProcState_procs.h
@@ -90,7 +90,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S32_opaque_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE SkPMColor
-#define CHECKSTATE(state) SkASSERT(4 == state.fBitmap->bytesPerPixel()); \
+#define CHECKSTATE(state) SkASSERT(4 == state.fPixmap.info().bytesPerPixel()); \
SkASSERT(state.fAlphaScale == 256)
#define RETURNDST(src) src
#define SRC_TO_FILTER(src) src
@@ -102,7 +102,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S32_alpha_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE SkPMColor
-#define CHECKSTATE(state) SkASSERT(4 == state.fBitmap->bytesPerPixel()); \
+#define CHECKSTATE(state) SkASSERT(4 == state.fPixmap.info().bytesPerPixel()); \
SkASSERT(state.fAlphaScale < 256)
#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale
#define RETURNDST(src) SkAlphaMulQ(src, alphaScale)
@@ -121,7 +121,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S16_opaque_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE uint16_t
-#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fBitmap->colorType()); \
+#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType()); \
SkASSERT(state.fAlphaScale == 256)
#define RETURNDST(src) SkPixel16ToPixel32(src)
#define SRC_TO_FILTER(src) src
@@ -137,7 +137,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S16_alpha_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE uint16_t
-#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fBitmap->colorType()); \
+#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType()); \
SkASSERT(state.fAlphaScale < 256)
#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale
#define RETURNDST(src) SkAlphaMulQ(SkPixel16ToPixel32(src), alphaScale)
@@ -152,9 +152,9 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(SI8_opaque_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE uint8_t
-#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fBitmap->colorType()); \
+#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType()); \
SkASSERT(state.fAlphaScale == 256)
-#define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->readColors()
+#define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fPixmap.ctable()->readColors()
#define RETURNDST(src) table[src]
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state)
@@ -166,10 +166,10 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(SI8_alpha_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE uint8_t
-#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fBitmap->colorType()); \
+#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType()); \
SkASSERT(state.fAlphaScale < 256)
#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale; \
- const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->readColors()
+ const SkPMColor* SK_RESTRICT table = state.fPixmap.ctable()->readColors()
#define RETURNDST(src) SkAlphaMulQ(table[src], alphaScale)
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state)
@@ -183,7 +183,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S4444_opaque_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE SkPMColor16
-#define CHECKSTATE(state) SkASSERT(kARGB_4444_SkColorType == state.fBitmap->colorType()); \
+#define CHECKSTATE(state) SkASSERT(kARGB_4444_SkColorType == state.fPixmap.colorType()); \
SkASSERT(state.fAlphaScale == 256)
#define RETURNDST(src) SkPixel4444ToPixel32(src)
#define SRC_TO_FILTER(src) src
@@ -199,7 +199,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S4444_alpha_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE SkPMColor16
-#define CHECKSTATE(state) SkASSERT(kARGB_4444_SkColorType == state.fBitmap->colorType()); \
+#define CHECKSTATE(state) SkASSERT(kARGB_4444_SkColorType == state.fPixmap.colorType()); \
SkASSERT(state.fAlphaScale < 256)
#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale
#define RETURNDST(src) SkAlphaMulQ(SkPixel4444ToPixel32(src), alphaScale)
@@ -218,7 +218,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(SA8_alpha_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE uint8_t
-#define CHECKSTATE(state) SkASSERT(kAlpha_8_SkColorType == state.fBitmap->colorType());
+#define CHECKSTATE(state) SkASSERT(kAlpha_8_SkColorType == state.fPixmap.colorType());
#define PREAMBLE(state) const SkPMColor pmColor = state.fPaintPMColor;
#define RETURNDST(src) SkAlphaMulQ(pmColor, SkAlpha255To256(src))
#define SRC_TO_FILTER(src) src
@@ -237,7 +237,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(SG8_alpha_D32 ## suffix)
#define DSTSIZE 32
#define SRCTYPE uint8_t
-#define CHECKSTATE(state) SkASSERT(kGray_8_SkColorType == state.fBitmap->colorType());
+#define CHECKSTATE(state) SkASSERT(kGray_8_SkColorType == state.fPixmap.colorType());
#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale
#define RETURNDST(src) SkAlphaMulQ(SkPackARGB32(0xFF, src, src, src), alphaScale)
#define SRC_TO_FILTER(src) src
@@ -262,8 +262,8 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S32_D16 ## suffix)
#define DSTSIZE 16
#define SRCTYPE SkPMColor
-#define CHECKSTATE(state) SkASSERT(4 == state.fBitmap->bytesPerPixel()); \
- SkASSERT(state.fBitmap->isOpaque())
+#define CHECKSTATE(state) SkASSERT(4 == state.fPixmap.info().bytesPerPixel()); \
+ SkASSERT(state.fPixmap.isOpaque())
#define RETURNDST(src) SkPixel32ToPixel16(src)
#define SRC_TO_FILTER(src) src
#include "SkBitmapProcState_sample.h"
@@ -280,7 +280,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(S16_D16 ## suffix)
#define DSTSIZE 16
#define SRCTYPE uint16_t
-#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fBitmap->colorType())
+#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType())
#define RETURNDST(src) src
#define SRC_TO_FILTER(src) src
#include "SkBitmapProcState_sample.h"
@@ -297,9 +297,9 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(SI8_D16 ## suffix)
#define DSTSIZE 16
#define SRCTYPE uint8_t
-#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fBitmap->colorType()); \
- SkASSERT(state.fBitmap->isOpaque())
-#define PREAMBLE(state) const uint16_t* SK_RESTRICT table = state.fBitmap->getColorTable()->read16BitCache()
+#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType()); \
+ SkASSERT(state.fPixmap.isOpaque())
+#define PREAMBLE(state) const uint16_t* SK_RESTRICT table = state.fPixmap.ctable()->read16BitCache()
#define RETURNDST(src) table[src]
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state)
@@ -325,7 +325,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(Clamp_S16_D16 ## suffix)
#define SRCTYPE uint16_t
#define DSTTYPE uint16_t
-#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fBitmap->colorType())
+#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType())
#define SRC_TO_FILTER(src) src
#include "SkBitmapProcState_shaderproc.h"
@@ -338,7 +338,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(Repeat_S16_D16 ## suffix)
#define SRCTYPE uint16_t
#define DSTTYPE uint16_t
-#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fBitmap->colorType())
+#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType())
#define SRC_TO_FILTER(src) src
#include "SkBitmapProcState_shaderproc.h"
@@ -353,8 +353,8 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define MAKENAME(suffix) NAME_WRAP(Clamp_SI8_opaque_D32 ## suffix)
#define SRCTYPE uint8_t
#define DSTTYPE uint32_t
-#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fBitmap->colorType())
-#define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->readColors()
+#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType())
+#define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fPixmap.ctable()->readColors()
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state)
#include "SkBitmapProcState_shaderproc.h"
diff --git a/src/core/SkBitmapProcState_sample.h b/src/core/SkBitmapProcState_sample.h
index 70305163cb..5322a3605c 100644
--- a/src/core/SkBitmapProcState_sample.h
+++ b/src/core/SkBitmapProcState_sample.h
@@ -48,29 +48,29 @@ void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s,
#ifdef PREAMBLE
PREAMBLE(s);
#endif
- const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
- size_t rb = s.fBitmap->rowBytes();
+ const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
+ size_t rb = s.fPixmap.rowBytes();
uint32_t XY;
SRCTYPE src;
for (int i = (count >> 1); i > 0; --i) {
XY = *xy++;
- SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() &&
- (XY & 0xFFFF) < (unsigned)s.fBitmap->width());
+ SkASSERT((XY >> 16) < (unsigned)s.fPixmap.height() &&
+ (XY & 0xFFFF) < (unsigned)s.fPixmap.width());
src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
*colors++ = RETURNDST(src);
XY = *xy++;
- SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() &&
- (XY & 0xFFFF) < (unsigned)s.fBitmap->width());
+ SkASSERT((XY >> 16) < (unsigned)s.fPixmap.height() &&
+ (XY & 0xFFFF) < (unsigned)s.fPixmap.width());
src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
*colors++ = RETURNDST(src);
}
if (count & 1) {
XY = *xy++;
- SkASSERT((XY >> 16) < (unsigned)s.fBitmap->height() &&
- (XY & 0xFFFF) < (unsigned)s.fBitmap->width());
+ SkASSERT((XY >> 16) < (unsigned)s.fPixmap.height() &&
+ (XY & 0xFFFF) < (unsigned)s.fPixmap.width());
src = ((const SRCTYPE*)(srcAddr + (XY >> 16) * rb))[XY & 0xFFFF];
*colors++ = RETURNDST(src);
}
@@ -91,18 +91,18 @@ void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s,
#ifdef PREAMBLE
PREAMBLE(s);
#endif
- const SRCTYPE* SK_RESTRICT srcAddr = (const SRCTYPE*)s.fBitmap->getPixels();
+ const SRCTYPE* SK_RESTRICT srcAddr = (const SRCTYPE*)s.fPixmap.addr();
// buffer is y32, x16, x16, x16, x16, x16
// bump srcAddr to the proper row, since we're told Y never changes
- SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height());
+ SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height());
srcAddr = (const SRCTYPE*)((const char*)srcAddr +
- xy[0] * s.fBitmap->rowBytes());
+ xy[0] * s.fPixmap.rowBytes());
xy += 1;
SRCTYPE src;
- if (1 == s.fBitmap->width()) {
+ if (1 == s.fPixmap.width()) {
src = srcAddr[0];
DSTTYPE dstValue = RETURNDST(src);
BITMAPPROC_MEMSET(colors, dstValue, count);
@@ -123,7 +123,7 @@ void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s,
}
const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy);
for (i = (count & 3); i > 0; --i) {
- SkASSERT(*xx < (unsigned)s.fBitmap->width());
+ SkASSERT(*xx < (unsigned)s.fPixmap.width());
src = srcAddr[*xx++]; *colors++ = RETURNDST(src);
}
}
@@ -145,8 +145,8 @@ void MAKENAME(_filter_DX)(const SkBitmapProcState& s,
#ifdef PREAMBLE
PREAMBLE(s);
#endif
- const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
- size_t rb = s.fBitmap->rowBytes();
+ const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
+ size_t rb = s.fPixmap.rowBytes();
unsigned subY;
const SRCTYPE* SK_RESTRICT row0;
const SRCTYPE* SK_RESTRICT row1;
@@ -191,8 +191,8 @@ void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s,
#ifdef PREAMBLE
PREAMBLE(s);
#endif
- const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
- size_t rb = s.fBitmap->rowBytes();
+ const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
+ size_t rb = s.fPixmap.rowBytes();
do {
uint32_t data = *xy++;
diff --git a/src/core/SkBitmapProcState_shaderproc.h b/src/core/SkBitmapProcState_shaderproc.h
index 7a7d45ef35..2708b012b5 100644
--- a/src/core/SkBitmapProcState_shaderproc.h
+++ b/src/core/SkBitmapProcState_shaderproc.h
@@ -24,7 +24,7 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s, int x, int y,
SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
SkDEBUGCODE(CHECKSTATE(s);)
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
const SkFixed oneX = s.fFilterOneX;
const SkFixed dx = s.fInvSx;
SkFixed fx;
@@ -37,14 +37,14 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s, int x, int y,
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
// compute our two Y values up front
subY = TILEY_LOW_BITS(fy, maxY);
int y0 = TILEY_PROCF(fy, maxY);
int y1 = TILEY_PROCF((fy + s.fFilterOneY), maxY);
- const char* SK_RESTRICT srcAddr = (const char*)s.fBitmap->getPixels();
- size_t rb = s.fBitmap->rowBytes();
+ const char* SK_RESTRICT srcAddr = (const char*)s.fPixmap.addr();
+ size_t rb = s.fPixmap.rowBytes();
row0 = (const SRCTYPE*)(srcAddr + y0 * rb);
row1 = (const SRCTYPE*)(srcAddr + y1 * rb);
// now initialize fx
diff --git a/src/opts/SkBitmapProcState_matrix_neon.h b/src/opts/SkBitmapProcState_matrix_neon.h
index 72bf1bce33..fbb2a1e00b 100644
--- a/src/opts/SkBitmapProcState_matrix_neon.h
+++ b/src/opts/SkBitmapProcState_matrix_neon.h
@@ -1,7 +1,12 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#include <arm_neon.h>
-
#define SCALE_NOFILTER_NAME MAKENAME(_nofilter_scale)
#define SCALE_FILTER_NAME MAKENAME(_filter_scale)
#define AFFINE_NOFILTER_NAME MAKENAME(_nofilter_affine)
@@ -30,14 +35,14 @@ static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
PREAMBLE(s);
// we store y, x, x, x, x, x
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
SkFractionalInt fx;
{
SkPoint pt;
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
fx = SkScalarToFractionalInt(pt.fY);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
*xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY);
fx = SkScalarToFractionalInt(pt.fX);
}
@@ -122,8 +127,8 @@ static void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY);
SkFractionalInt dx = s.fInvSxFractionalInt;
SkFractionalInt dy = s.fInvKyFractionalInt;
- int maxX = s.fBitmap->width() - 1;
- int maxY = s.fBitmap->height() - 1;
+ int maxX = s.fPixmap.width() - 1;
+ int maxY = s.fPixmap.height() - 1;
if (count >= 8) {
SkFractionalInt dx4 = dx * 4;
@@ -187,8 +192,8 @@ static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
PREAMBLE(s);
// max{X,Y} are int here, but later shown/assumed to fit in 16 bits
- int maxX = s.fBitmap->width() - 1;
- int maxY = s.fBitmap->height() - 1;
+ int maxX = s.fPixmap.width() - 1;
+ int maxY = s.fPixmap.height() - 1;
SkPerspIter iter(s.fInvMatrix,
SkIntToScalar(x) + SK_ScalarHalf,
@@ -293,7 +298,7 @@ static void SCALE_FILTER_NAME(const SkBitmapProcState& s,
PREAMBLE(s);
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
const SkFixed one = s.fFilterOneX;
const SkFractionalInt dx = s.fInvSxFractionalInt;
SkFractionalInt fx;
@@ -303,7 +308,7 @@ static void SCALE_FILTER_NAME(const SkBitmapProcState& s,
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
// compute our two Y values up front
*xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y);
// now initialize fx
@@ -369,8 +374,8 @@ static void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1);
SkFixed dx = s.fInvSx;
SkFixed dy = s.fInvKy;
- unsigned maxX = s.fBitmap->width() - 1;
- unsigned maxY = s.fBitmap->height() - 1;
+ unsigned maxX = s.fPixmap.width() - 1;
+ unsigned maxY = s.fPixmap.height() - 1;
if (count >= 4) {
int32x4_t wide_fy, wide_fx;
@@ -420,8 +425,8 @@ static void PERSP_FILTER_NAME(const SkBitmapProcState& s,
SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
PREAMBLE(s);
- unsigned maxX = s.fBitmap->width() - 1;
- unsigned maxY = s.fBitmap->height() - 1;
+ unsigned maxX = s.fPixmap.width() - 1;
+ unsigned maxY = s.fPixmap.height() - 1;
SkFixed oneX = s.fFilterOneX;
SkFixed oneY = s.fFilterOneY;
diff --git a/src/opts/SkBitmapProcState_opts_SSE2.cpp b/src/opts/SkBitmapProcState_opts_SSE2.cpp
index 659caf25b8..f55a09938c 100644
--- a/src/opts/SkBitmapProcState_opts_SSE2.cpp
+++ b/src/opts/SkBitmapProcState_opts_SSE2.cpp
@@ -16,11 +16,11 @@ void S32_opaque_D32_filter_DX_SSE2(const SkBitmapProcState& s,
int count, uint32_t* colors) {
SkASSERT(count > 0 && colors != NULL);
SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
- SkASSERT(kN32_SkColorType == s.fBitmap->colorType());
+ SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
SkASSERT(s.fAlphaScale == 256);
- const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels());
- size_t rb = s.fBitmap->rowBytes();
+ const char* srcAddr = static_cast<const char*>(s.fPixmap.addr());
+ size_t rb = s.fPixmap.rowBytes();
uint32_t XY = *xy++;
unsigned y0 = XY >> 14;
const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb);
@@ -122,11 +122,11 @@ void S32_alpha_D32_filter_DX_SSE2(const SkBitmapProcState& s,
int count, uint32_t* colors) {
SkASSERT(count > 0 && colors != NULL);
SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
- SkASSERT(kN32_SkColorType == s.fBitmap->colorType());
+ SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
SkASSERT(s.fAlphaScale < 256);
- const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels());
- size_t rb = s.fBitmap->rowBytes();
+ const char* srcAddr = static_cast<const char*>(s.fPixmap.addr());
+ size_t rb = s.fPixmap.rowBytes();
uint32_t XY = *xy++;
unsigned y0 = XY >> 14;
const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb);
@@ -249,7 +249,7 @@ void ClampX_ClampY_filter_scale_SSE2(const SkBitmapProcState& s, uint32_t xy[],
SkMatrix::kScale_Mask)) == 0);
SkASSERT(s.fInvKy == 0);
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
const SkFixed one = s.fFilterOneX;
const SkFixed dx = s.fInvSx;
SkFixed fx;
@@ -258,7 +258,7 @@ void ClampX_ClampY_filter_scale_SSE2(const SkBitmapProcState& s, uint32_t xy[],
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
// compute our two Y values up front
*xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY);
// now initialize fx
@@ -373,13 +373,13 @@ void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s,
SkMatrix::kScale_Mask)) == 0);
// we store y, x, x, x, x, x
- const unsigned maxX = s.fBitmap->width() - 1;
+ const unsigned maxX = s.fPixmap.width() - 1;
SkFixed fx;
SkPoint pt;
s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf, &pt);
fx = SkScalarToFixed(pt.fY);
- const unsigned maxY = s.fBitmap->height() - 1;
+ const unsigned maxY = s.fPixmap.height() - 1;
*xy++ = SkClampMax(fx >> 16, maxY);
fx = SkScalarToFixed(pt.fX);
@@ -500,8 +500,8 @@ void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s,
SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1);
SkFixed dx = s.fInvSx;
SkFixed dy = s.fInvKy;
- unsigned maxX = s.fBitmap->width() - 1;
- unsigned maxY = s.fBitmap->height() - 1;
+ unsigned maxX = s.fPixmap.width() - 1;
+ unsigned maxY = s.fPixmap.height() - 1;
if (count >= 2 && (maxX <= 0xFFFF)) {
SkFixed dx2 = dx + dx;
@@ -574,8 +574,8 @@ void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s,
SkFixed fy = SkScalarToFixed(srcPt.fY);
SkFixed dx = s.fInvSx;
SkFixed dy = s.fInvKy;
- int maxX = s.fBitmap->width() - 1;
- int maxY = s.fBitmap->height() - 1;
+ int maxX = s.fPixmap.width() - 1;
+ int maxY = s.fPixmap.height() - 1;
if (count >= 4 && (maxX <= 0xFFFF)) {
while (((size_t)xy & 0x0F) != 0) {
@@ -642,12 +642,12 @@ void S32_D16_filter_DX_SSE2(const SkBitmapProcState& s,
int count, uint16_t* colors) {
SkASSERT(count > 0 && colors != NULL);
SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
- SkASSERT(kN32_SkColorType == s.fBitmap->colorType());
- SkASSERT(s.fBitmap->isOpaque());
+ SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
+ SkASSERT(s.fPixmap.isOpaque());
SkPMColor dstColor;
- const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels());
- size_t rb = s.fBitmap->rowBytes();
+ const char* srcAddr = static_cast<const char*>(s.fPixmap.addr());
+ size_t rb = s.fPixmap.rowBytes();
uint32_t XY = *xy++;
unsigned y0 = XY >> 14;
const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4) * rb);
diff --git a/src/opts/SkBitmapProcState_opts_SSSE3.cpp b/src/opts/SkBitmapProcState_opts_SSSE3.cpp
index bfcd7caa72..15a9664c08 100644
--- a/src/opts/SkBitmapProcState_opts_SSSE3.cpp
+++ b/src/opts/SkBitmapProcState_opts_SSSE3.cpp
@@ -395,7 +395,7 @@ void S32_generic_D32_filter_DX_SSSE3(const SkBitmapProcState& s,
int count, uint32_t* colors) {
SkASSERT(count > 0 && colors != NULL);
SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
- SkASSERT(kN32_SkColorType == s.fBitmap->colorType());
+ SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
if (has_alpha) {
SkASSERT(s.fAlphaScale < 256);
} else {
@@ -403,8 +403,8 @@ void S32_generic_D32_filter_DX_SSSE3(const SkBitmapProcState& s,
}
const uint8_t* src_addr =
- static_cast<const uint8_t*>(s.fBitmap->getPixels());
- const size_t rb = s.fBitmap->rowBytes();
+ static_cast<const uint8_t*>(s.fPixmap.addr());
+ const size_t rb = s.fPixmap.rowBytes();
const uint32_t XY = *xy++;
const unsigned y0 = XY >> 14;
const uint32_t* row0 =
@@ -587,7 +587,7 @@ void S32_generic_D32_filter_DXDY_SSSE3(const SkBitmapProcState& s,
int count, uint32_t* colors) {
SkASSERT(count > 0 && colors != NULL);
SkASSERT(s.fFilterLevel != kNone_SkFilterQuality);
- SkASSERT(kN32_SkColorType == s.fBitmap->colorType());
+ SkASSERT(kN32_SkColorType == s.fPixmap.colorType());
if (has_alpha) {
SkASSERT(s.fAlphaScale < 256);
} else {
@@ -595,8 +595,8 @@ void S32_generic_D32_filter_DXDY_SSSE3(const SkBitmapProcState& s,
}
const uint8_t* src_addr =
- static_cast<const uint8_t*>(s.fBitmap->getPixels());
- const size_t rb = s.fBitmap->rowBytes();
+ static_cast<const uint8_t*>(s.fPixmap.addr());
+ const size_t rb = s.fPixmap.rowBytes();
// vector constants
const __m128i mask_dist_select = _mm_set_epi8(12, 12, 12, 12,
diff --git a/src/opts/SkBitmapProcState_opts_arm.cpp b/src/opts/SkBitmapProcState_opts_arm.cpp
index e6799dea19..bd67ba4fd7 100644
--- a/src/opts/SkBitmapProcState_opts_arm.cpp
+++ b/src/opts/SkBitmapProcState_opts_arm.cpp
@@ -30,18 +30,17 @@ void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s,
SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
- const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->read16BitCache();
- const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
+ const uint16_t* SK_RESTRICT table = s.fPixmap.ctable()->read16BitCache();
+ const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr();
// buffer is y32, x16, x16, x16, x16, x16
// bump srcAddr to the proper row, since we're told Y never changes
- SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height());
- srcAddr = (const uint8_t*)((const char*)srcAddr +
- xy[0] * s.fBitmap->rowBytes());
+ SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height());
+ srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes());
uint8_t src;
- if (1 == s.fBitmap->width()) {
+ if (1 == s.fPixmap.width()) {
src = srcAddr[0];
uint16_t dstValue = table[src];
sk_memset16(colors, dstValue, count);
@@ -119,15 +118,15 @@ void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s,
SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
- const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->readColors();
- const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
+ const SkPMColor* SK_RESTRICT table = s.fPixmap.ctable()->readColors();
+ const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr();
// buffer is y32, x16, x16, x16, x16, x16
// bump srcAddr to the proper row, since we're told Y never changes
- SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height());
- srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes());
+ SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height());
+ srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes());
- if (1 == s.fBitmap->width()) {
+ if (1 == s.fPixmap.width()) {
uint8_t src = srcAddr[0];
SkPMColor dstValue = table[src];
sk_memset32(colors, dstValue, count);
@@ -199,7 +198,7 @@ void SkBitmapProcState::platformProcs() {
justDx = true;
}
- switch (fBitmap->colorType()) {
+ switch (fPixmap.colorType()) {
case kIndex_8_SkColorType:
if (justDx && kNone_SkFilterQuality == fFilterLevel) {
#if 0 /* crashing on android device */
diff --git a/src/opts/SkBitmapProcState_opts_mips_dsp.cpp b/src/opts/SkBitmapProcState_opts_mips_dsp.cpp
index 049519a613..6b8195c660 100644
--- a/src/opts/SkBitmapProcState_opts_mips_dsp.cpp
+++ b/src/opts/SkBitmapProcState_opts_mips_dsp.cpp
@@ -18,13 +18,13 @@ static void SI8_D16_nofilter_DX_mips_dsp(const SkBitmapProcState& s,
SkASSERT(count > 0 && colors != NULL);
SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
- const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->read16BitCache();
- const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
- SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height());
- srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes());
+ const uint16_t* SK_RESTRICT table = s.fPixmap.ctable()->read16BitCache();
+ const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr();
+ SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height());
+ srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes());
uint8_t src;
- if (1 == s.fBitmap->width()) {
+ if (1 == s.fPixmap.width()) {
src = srcAddr[0];
uint16_t dstValue = table[src];
sk_memset16(colors, dstValue, count);
@@ -150,11 +150,11 @@ static void SI8_opaque_D32_nofilter_DX_mips_dsp(const SkBitmapProcState& s,
SkASSERT(count > 0 && colors != NULL);
SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
- const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->readColors();
- const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
- srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes());
+ const SkPMColor* SK_RESTRICT table = s.fPixmap.ctable()->readColors();
+ const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr();
+ srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes());
- if (1 == s.fBitmap->width()) {
+ if (1 == s.fPixmap.width()) {
uint8_t src = srcAddr[0];
SkPMColor dstValue = table[src];
sk_memset32(colors, dstValue, count);
@@ -376,7 +376,7 @@ void SkBitmapProcState::platformProcs() {
justDx = true;
}
- switch (fBitmap->colorType()) {
+ switch (fPixmap.colorType()) {
case kIndex_8_SkColorType:
if (justDx && kNone_SkFilterQuality == fFilterLevel) {
fSampleProc16 = SI8_D16_nofilter_DX_mips_dsp;