SkColorTable locking serves no purpose anymore.

The only thing the unlock methods were doing was assert their balance.
This removes the unlock methods and renames the lock methods "read".

BUG=skia:

Review URL: https://codereview.chromium.org/719213008
This commit is contained in:
mtklein 2014-12-02 09:11:25 -08:00 committed by Commit bot
parent ba1bf8af8d
commit 775b8199a2
16 changed files with 63 additions and 176 deletions

View File

@ -271,13 +271,13 @@ public:
isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
return this->tryAllocPixels(info);
}
SK_ALLOCPIXELS_RETURN_TYPE allocN32Pixels(int width, int height, bool isOpaque = false) {
SkImageInfo info = SkImageInfo::MakeN32(width, height,
isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
return this->allocPixels(info);
}
/**
* Install a pixelref that wraps the specified pixels and rowBytes, and
* optional ReleaseProc and context. When the pixels are no longer
@ -798,60 +798,6 @@ private:
//TODO(mtklein): uncomment when 71713004 lands and Chromium's fixed.
//#define SkAutoLockPixels(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockPixels)
/** Helper class that performs the lock/unlockColors calls on a colortable.
The destructor will call unlockColors(false) if it has a bitmap's colortable
*/
class SkAutoLockColors : SkNoncopyable {
public:
/** Initialize with no bitmap. Call lockColors(bitmap) to lock bitmap's
colortable
*/
SkAutoLockColors() : fCTable(NULL), fColors(NULL) {}
/** Initialize with bitmap, locking its colortable if present
*/
explicit SkAutoLockColors(const SkBitmap& bm) {
fCTable = bm.getColorTable();
fColors = fCTable ? fCTable->lockColors() : NULL;
}
/** Initialize with a colortable (may be null)
*/
explicit SkAutoLockColors(SkColorTable* ctable) {
fCTable = ctable;
fColors = ctable ? ctable->lockColors() : NULL;
}
~SkAutoLockColors() {
if (fCTable) {
fCTable->unlockColors();
}
}
/** Return the currently locked colors, or NULL if no bitmap's colortable
is currently locked.
*/
const SkPMColor* colors() const { return fColors; }
/** Locks the table and returns is colors (assuming ctable is not null) and
unlocks the previous table if one was present
*/
const SkPMColor* lockColors(SkColorTable* ctable) {
if (fCTable) {
fCTable->unlockColors();
}
fCTable = ctable;
fColors = ctable ? ctable->lockColors() : NULL;
return fColors;
}
const SkPMColor* lockColors(const SkBitmap& bm) {
return this->lockColors(bm.getColorTable());
}
private:
SkColorTable* fCTable;
const SkPMColor* fColors;
};
#define SkAutoLockColors(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockColors)
///////////////////////////////////////////////////////////////////////////////
inline uint32_t* SkBitmap::getAddr32(int x, int y) const {

View File

@ -30,43 +30,26 @@ public:
virtual ~SkColorTable();
/** Returns the number of colors in the table.
*/
*/
int count() const { return fCount; }
/** Returns the specified color from the table. In the debug build, this asserts that
the index is in range (0 <= index < count).
*/
* the index is in range (0 <= index < count).
*/
SkPMColor operator[](int index) const {
SkASSERT(fColors != NULL && (unsigned)index < (unsigned)fCount);
return fColors[index];
}
/**
* Return the array of colors for reading. This must be balanced by a call
* to unlockColors().
*/
const SkPMColor* lockColors() {
SkDEBUGCODE(sk_atomic_inc(&fColorLockCount);)
return fColors;
}
// TODO: Would making the read() methods const allow us to avoid copies?
/**
* Balancing call to lockColors().
/** Return the array of colors for reading.
*/
void unlockColors();
const SkPMColor* readColors() { return fColors; }
/** Similar to lockColors(), lock16BitCache() returns the array of
RGB16 colors that mirror the 32bit colors. However, this function
will return null if kColorsAreOpaque_Flag is not set.
Also, unlike lockColors(), the returned array here cannot be modified.
*/
const uint16_t* lock16BitCache();
/** Balancing call to lock16BitCache().
*/
void unlock16BitCache() {
SkASSERT(f16BitCacheLockCount > 0);
SkDEBUGCODE(sk_atomic_dec(&f16BitCacheLockCount);)
}
/** read16BitCache() returns the array of RGB16 colors that mirror the 32bit colors.
*/
const uint16_t* read16BitCache();
explicit SkColorTable(SkReadBuffer&);
void writeToBuffer(SkWriteBuffer&) const;
@ -75,13 +58,9 @@ private:
SkPMColor* fColors;
uint16_t* f16BitCache;
int fCount;
SkDEBUGCODE(int fColorLockCount;)
SkDEBUGCODE(int f16BitCacheLockCount;)
void init(const SkPMColor* colors, int count);
void inval16BitCache();
typedef SkRefCnt INHERITED;
};

View File

@ -284,20 +284,20 @@ bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, size_t rowBytes)
if (!this->setInfo(requestedInfo, rowBytes)) {
return reset_return_false(this);
}
// setInfo may have corrected info (e.g. 565 is always opaque).
const SkImageInfo& correctedInfo = this->info();
// setInfo may have computed a valid rowbytes if 0 were passed in
rowBytes = this->rowBytes();
SkMallocPixelRef::PRFactory defaultFactory;
SkPixelRef* pr = defaultFactory.create(correctedInfo, rowBytes, NULL);
if (NULL == pr) {
return reset_return_false(this);
}
this->setPixelRef(pr)->unref();
// TODO: lockPixels could/should return bool or void*/NULL
this->lockPixels();
if (NULL == this->getPixels()) {
@ -586,11 +586,10 @@ bool SkBitmap::ComputeIsOpaque(const SkBitmap& bm) {
return true;
} break;
case kIndex_8_SkColorType: {
SkAutoLockColors alc(bm);
const SkPMColor* table = alc.colors();
if (!table) {
if (!bm.getColorTable()) {
return false;
}
const SkPMColor* table = bm.getColorTable()->readColors();
SkPMColor c = (SkPMColor)~0;
for (int i = bm.getColorTable()->count() - 1; i >= 0; --i) {
c &= table[i];
@ -848,15 +847,15 @@ bool SkBitmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels,
if (0 == requestedDstInfo.width() || 0 == requestedDstInfo.height()) {
return false;
}
SkIRect srcR = SkIRect::MakeXYWH(x, y, requestedDstInfo.width(), requestedDstInfo.height());
if (!srcR.intersect(0, 0, this->width(), this->height())) {
return false;
}
// the intersect may have shrunk info's logical size
const SkImageInfo dstInfo = requestedDstInfo.makeWH(srcR.width(), srcR.height());
// if x or y are negative, then we have to adjust pixels
if (x > 0) {
x = 0;
@ -868,16 +867,16 @@ bool SkBitmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels,
dstPixels = ((char*)dstPixels - y * dstRB - x * dstInfo.bytesPerPixel());
//////////////
SkAutoLockPixels alp(*this);
// since we don't stop creating un-pixeled devices yet, check for no pixels here
if (NULL == this->getPixels()) {
return false;
}
const SkImageInfo srcInfo = this->info().makeWH(dstInfo.width(), dstInfo.height());
const void* srcPixels = this->getAddr(srcR.x(), srcR.y());
return SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, this->rowBytes(),
this->getColorTable());
@ -1067,7 +1066,7 @@ static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha,
} else if (kIndex_8_SkColorType == colorType && !src.isOpaque()) {
SkColorTable* ct = src.getColorTable();
if (ct) {
const SkPMColor* SK_RESTRICT table = ct->lockColors();
const SkPMColor* SK_RESTRICT table = ct->readColors();
const uint8_t* SK_RESTRICT s = src.getAddr8(0, 0);
while (--h >= 0) {
for (int x = 0; x < w; x++) {
@ -1076,7 +1075,6 @@ static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha,
s += rb;
alpha += alphaRowBytes;
}
ct->unlockColors();
}
} else { // src is opaque, so just fill alpha[] with 0xFF
memset(alpha, 0xFF, h * alphaRowBytes);

View File

@ -154,10 +154,10 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define SRCTYPE uint8_t
#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fBitmap->colorType()); \
SkASSERT(state.fAlphaScale == 256)
#define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->lockColors()
#define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->readColors()
#define RETURNDST(src) table[src]
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state) state.fBitmap->getColorTable()->unlockColors()
#define POSTAMBLE(state)
#include "SkBitmapProcState_sample.h"
#undef FILTER_PROC
@ -169,10 +169,10 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fBitmap->colorType()); \
SkASSERT(state.fAlphaScale < 256)
#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale; \
const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->lockColors()
const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->readColors()
#define RETURNDST(src) SkAlphaMulQ(table[src], alphaScale)
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state) state.fBitmap->getColorTable()->unlockColors()
#define POSTAMBLE(state)
#include "SkBitmapProcState_sample.h"
// SRC == 4444
@ -280,10 +280,10 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#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()->lock16BitCache()
#define PREAMBLE(state) const uint16_t* SK_RESTRICT table = state.fBitmap->getColorTable()->read16BitCache()
#define RETURNDST(src) table[src]
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state) state.fBitmap->getColorTable()->unlock16BitCache()
#define POSTAMBLE(state)
#include "SkBitmapProcState_sample.h"
///////////////////////////////////////////////////////////////////////////////
@ -335,9 +335,9 @@ static inline U8CPU Filter_8(unsigned x, unsigned y,
#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()->lockColors()
#define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->readColors()
#define SRC_TO_FILTER(src) table[src]
#define POSTAMBLE(state) state.fBitmap->getColorTable()->unlockColors()
#define POSTAMBLE(state)
#include "SkBitmapProcState_shaderproc.h"
#undef NAME_WRAP

View File

@ -19,11 +19,8 @@ void SkColorTable::init(const SkPMColor colors[], int count) {
f16BitCache = NULL;
fCount = count;
fColors = reinterpret_cast<SkPMColor*>(sk_malloc_throw(count * sizeof(SkPMColor)));
memcpy(fColors, colors, count * sizeof(SkPMColor));
SkDEBUGCODE(fColorLockCount = 0;)
SkDEBUGCODE(f16BitCacheLockCount = 0;)
}
// As copy constructor is hidden in the class hierarchy, we need to call
@ -43,18 +40,10 @@ SkColorTable::SkColorTable(const SkPMColor colors[], int count) {
}
SkColorTable::~SkColorTable() {
SkASSERT(fColorLockCount == 0);
SkASSERT(f16BitCacheLockCount == 0);
sk_free(fColors);
sk_free(f16BitCache);
}
void SkColorTable::unlockColors() {
SkASSERT(fColorLockCount != 0);
SkDEBUGCODE(sk_atomic_dec(&fColorLockCount);)
}
#include "SkColorPriv.h"
static inline void build_16bitcache(uint16_t dst[], const SkPMColor src[],
@ -64,13 +53,11 @@ static inline void build_16bitcache(uint16_t dst[], const SkPMColor src[],
}
}
const uint16_t* SkColorTable::lock16BitCache() {
const uint16_t* SkColorTable::read16BitCache() {
if (NULL == f16BitCache) {
f16BitCache = (uint16_t*)sk_malloc_throw(fCount * sizeof(uint16_t));
build_16bitcache(f16BitCache, fColors, fCount);
}
SkDEBUGCODE(sk_atomic_inc(&f16BitCacheLockCount));
return f16BitCache;
}
@ -78,9 +65,6 @@ const uint16_t* SkColorTable::lock16BitCache() {
SkColorTable::SkColorTable(SkReadBuffer& buffer) {
f16BitCache = NULL;
SkDEBUGCODE(fColorLockCount = 0;)
SkDEBUGCODE(f16BitCacheLockCount = 0;)
if (buffer.isVersionLT(SkReadBuffer::kRemoveColorTableAlpha_Version)) {
/*fAlphaType = */buffer.readUInt();
}

View File

@ -154,13 +154,13 @@ bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
dstPI.fAlphaType = dstInfo.alphaType();
dstPI.fPixels = dstPixels;
dstPI.fRowBytes = dstRB;
SkSrcPixelInfo srcPI;
srcPI.fColorType = srcInfo.colorType();
srcPI.fAlphaType = srcInfo.alphaType();
srcPI.fPixels = srcPixels;
srcPI.fRowBytes = srcRB;
return srcPI.convertPixelsTo(&dstPI, width, height);
}
@ -196,13 +196,13 @@ bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
// Our method for converting to 4444 assumes premultiplied.
return false;
}
const SkPMColor* table = NULL;
if (kIndex_8_SkColorType == srcInfo.colorType()) {
if (NULL == ctable) {
return false;
}
table = ctable->lockColors();
table = ctable->readColors();
}
for (int y = 0; y < height; ++y) {
@ -222,10 +222,6 @@ bool SkPixelInfo::CopyPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t
dstPixels = (char*)dstPixels + dstRB;
srcPixels = (const char*)srcPixels + srcRB;
}
if (table) {
ctable->unlockColors();
}
return true;
}

View File

@ -26,7 +26,7 @@ public:
const SkPMColor* ctable = NULL;
if fSource.getColorTable())
ctable = fSource.getColorTable()->lockColors();
ctable = fSource.getColorTable()->readColors();
while (--height >= 0)
{
@ -34,9 +34,6 @@ public:
dst += dstRB;
src += srcRB;
}
if fSource.getColorTable())
fSource.getColorTable()->unlockColors();
}
private:

View File

@ -142,10 +142,10 @@ public:
#define SkSPRITE_SRC_TYPE uint8_t
#define SkSPRITE_DST_GETADDR getAddr16
#define SkSPRITE_SRC_GETADDR getAddr8
#define SkSPRITE_PREAMBLE(srcBM, x, y) const SkPMColor* ctable = srcBM.getColorTable()->lockColors()
#define SkSPRITE_PREAMBLE(srcBM, x, y) const SkPMColor* ctable = srcBM.getColorTable()->readColors()
#define SkSPRITE_BLIT_PIXEL(dst, src) D16_S32A_Opaque_Pixel(dst, ctable[src])
#define SkSPRITE_NEXT_ROW
#define SkSPRITE_POSTAMBLE(srcBM) srcBM.getColorTable()->unlockColors()
#define SkSPRITE_POSTAMBLE(srcBM)
#include "SkSpriteBlitterTemplate.h"
#define SkSPRITE_CLASSNAME Sprite_D16_SIndex8A_Blend
@ -156,10 +156,10 @@ public:
#define SkSPRITE_SRC_TYPE uint8_t
#define SkSPRITE_DST_GETADDR getAddr16
#define SkSPRITE_SRC_GETADDR getAddr8
#define SkSPRITE_PREAMBLE(srcBM, x, y) const SkPMColor* ctable = srcBM.getColorTable()->lockColors(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
#define SkSPRITE_PREAMBLE(srcBM, x, y) const SkPMColor* ctable = srcBM.getColorTable()->readColors(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
#define SkSPRITE_BLIT_PIXEL(dst, src) D16_S32A_Blend_Pixel(dst, ctable[src], src_scale)
#define SkSPRITE_NEXT_ROW
#define SkSPRITE_POSTAMBLE(srcBM) srcBM.getColorTable()->unlockColors();
#define SkSPRITE_POSTAMBLE(srcBM)
#include "SkSpriteBlitterTemplate.h"
///////////////////////////////////////////////////////////////////////////////
@ -234,10 +234,10 @@ static void blitrow_d16_si8(uint16_t* SK_RESTRICT dst,
#define SkSPRITE_SRC_TYPE uint8_t
#define SkSPRITE_DST_GETADDR getAddr16
#define SkSPRITE_SRC_GETADDR getAddr8
#define SkSPRITE_PREAMBLE(srcBM, x, y) const uint16_t* ctable = srcBM.getColorTable()->lock16BitCache()
#define SkSPRITE_PREAMBLE(srcBM, x, y) const uint16_t* ctable = srcBM.getColorTable()->read16BitCache()
#define SkSPRITE_BLIT_PIXEL(dst, src) *dst = ctable[src]
#define SkSPRITE_NEXT_ROW
#define SkSPRITE_POSTAMBLE(srcBM) srcBM.getColorTable()->unlock16BitCache()
#define SkSPRITE_POSTAMBLE(srcBM)
#include "SkSpriteBlitterTemplate.h"
#define SkSPRITE_CLASSNAME Sprite_D16_SIndex8_Blend
@ -248,10 +248,10 @@ static void blitrow_d16_si8(uint16_t* SK_RESTRICT dst,
#define SkSPRITE_SRC_TYPE uint8_t
#define SkSPRITE_DST_GETADDR getAddr16
#define SkSPRITE_SRC_GETADDR getAddr8
#define SkSPRITE_PREAMBLE(srcBM, x, y) const uint16_t* ctable = srcBM.getColorTable()->lock16BitCache(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
#define SkSPRITE_PREAMBLE(srcBM, x, y) const uint16_t* ctable = srcBM.getColorTable()->read16BitCache(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
#define SkSPRITE_BLIT_PIXEL(dst, src) D16_S16_Blend_Pixel(dst, ctable[src], src_scale)
#define SkSPRITE_NEXT_ROW
#define SkSPRITE_POSTAMBLE(srcBM) srcBM.getColorTable()->unlock16BitCache();
#define SkSPRITE_POSTAMBLE(srcBM)
#include "SkSpriteBlitterTemplate.h"
///////////////////////////////////////////////////////////////////////////////

View File

@ -56,13 +56,11 @@ static void build_index8_data(void* buffer, const SkBitmap& bitmap) {
SkSrcPixelInfo srcPI;
srcPI.fColorType = kN32_SkColorType;
srcPI.fAlphaType = kPremul_SkAlphaType;
srcPI.fPixels = ctable->lockColors();
srcPI.fPixels = ctable->readColors();
srcPI.fRowBytes = count * sizeof(SkPMColor);
srcPI.convertPixelsTo(&dstPI, count, 1);
ctable->unlockColors();
// always skip a full 256 number of entries, even if we memcpy'd fewer
dst += 256 * sizeof(GrColor);
@ -205,7 +203,7 @@ static GrTexture *load_etc1_texture(GrContext* ctx, bool cache,
// then we don't know how to scale the image to match it...
if (ktx.width() != bm.width() || ktx.height() != bm.height()) {
return NULL;
}
}
bytes = ktx.pixelData();
desc.fConfig = kETC1_GrPixelConfig;
@ -481,7 +479,7 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
dm = SkXfermode::kISA_Coeff;
}
grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm));
//set the color of the paint to the one of the parameter
grPaint->setColor(paintColor);

View File

@ -199,8 +199,7 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
return false;
}
const int count = ctable->count();
memcpy(ctableEntries, ctable->lockColors(), count * sizeof(SkPMColor));
ctable->unlockColors();
memcpy(ctableEntries, ctable->readColors(), count * sizeof(SkPMColor));
*ctableCount = count;
}
return true;

View File

@ -1355,7 +1355,6 @@ protected:
// allocate these before set call setjmp
SkAutoMalloc oneRow;
SkAutoLockColors ctLocker;
cinfo.err = jpeg_std_error(&sk_err);
sk_err.error_exit = skjpeg_error_exit;
@ -1392,7 +1391,7 @@ protected:
const int width = bm.width();
uint8_t* oneRowP = (uint8_t*)oneRow.reset(width * 3);
const SkPMColor* colors = ctLocker.lockColors(bm);
const SkPMColor* colors = bm.getColorTable() ? bm.getColorTable()->readColors() : NULL;
const void* srcRow = bm.getPixels();
while (cinfo.next_scanline < cinfo.image_height) {

View File

@ -413,8 +413,8 @@ SkImageDecoder::Result SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap
even if our decodedBitmap doesn't, due to the request that we
upscale png's palette to a direct model
*/
SkAutoLockColors ctLock(colorTable);
if (!sampler.begin(decodedBitmap, sc, *this, ctLock.colors())) {
const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL;
if (!sampler.begin(decodedBitmap, sc, *this, colors)) {
return kFailure;
}
const int height = decodedBitmap->height();
@ -894,8 +894,8 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
even if our decodedBitmap doesn't, due to the request that we
upscale png's palette to a direct model
*/
SkAutoLockColors ctLock(colorTable);
if (!sampler.begin(&decodedBitmap, sc, *this, ctLock.colors())) {
const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL;
if (!sampler.begin(&decodedBitmap, sc, *this, colors)) {
return false;
}
const int height = decodedBitmap.height();
@ -1047,8 +1047,7 @@ static int computeBitDepth(int colorCount) {
static inline int pack_palette(SkColorTable* ctable,
png_color* SK_RESTRICT palette,
png_byte* SK_RESTRICT trans, bool hasAlpha) {
SkAutoLockColors alc(ctable);
const SkPMColor* SK_RESTRICT colors = alc.colors();
const SkPMColor* SK_RESTRICT colors = ctable ? ctable->readColors() : NULL;
const int ctCount = ctable->count();
int i, num_trans = 0;

View File

@ -621,7 +621,6 @@ bool SkWEBPImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bm,
}
SkAutoLockPixels alp(bm);
SkAutoLockColors ctLocker;
if (NULL == bm.getPixels()) {
return false;
}
@ -638,7 +637,7 @@ bool SkWEBPImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bm,
pic.writer = stream_writer;
pic.custom_ptr = (void*)stream;
const SkPMColor* colors = ctLocker.lockColors(bm);
const SkPMColor* colors = bm.getColorTable() ? bm.getColorTable()->readColors() : NULL;
const uint8_t* src = (uint8_t*)bm.getPixels();
const int rgbStride = pic.width * bpp;

View File

@ -98,8 +98,7 @@ bool SkARGBImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int
return false;
}
SkAutoLockColors ctLocker;
const SkPMColor* colors = ctLocker.lockColors(bitmap);
const SkPMColor* colors = bitmap.getColorTable() ? bitmap.getColorTable()->readColors() : NULL;
const int argbStride = bitmap.width() * 4;
SkAutoTDeleteArray<uint8_t> ada(new uint8_t[argbStride]);

View File

@ -30,7 +30,7 @@ void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s,
SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel);
const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->lock16BitCache();
const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->read16BitCache();
const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
// buffer is y32, x16, x16, x16, x16, x16
@ -104,8 +104,6 @@ void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s,
src = srcAddr[*xx++]; *colors++ = table[src];
}
}
s.fBitmap->getColorTable()->unlock16BitCache();
}
void SI8_opaque_D32_nofilter_DX_arm(
@ -121,7 +119,7 @@ void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s,
SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel);
const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->lockColors();
const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->readColors();
const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
// buffer is y32, x16, x16, x16, x16, x16
@ -184,8 +182,6 @@ void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s,
: "memory", "cc", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11"
);
}
s.fBitmap->getColorTable()->unlockColors();
}
#endif // !defined(SK_CPU_ARM64) && SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)

View File

@ -18,7 +18,7 @@ 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(SkPaint::kNone_FilterLevel == s.fFilterLevel);
const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->lock16BitCache();
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());
@ -142,7 +142,6 @@ static void SI8_D16_nofilter_DX_mips_dsp(const SkBitmapProcState& s,
src = srcAddr[*xx++]; *colors++ = table[src];
}
}
s.fBitmap->getColorTable()->unlock16BitCache();
}
static void SI8_opaque_D32_nofilter_DX_mips_dsp(const SkBitmapProcState& s,
@ -151,7 +150,7 @@ 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(SkPaint::kNone_FilterLevel == s.fFilterLevel);
const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->lockColors();
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());
@ -363,7 +362,6 @@ static void SI8_opaque_D32_nofilter_DX_mips_dsp(const SkBitmapProcState& s,
"t4", "t5", "t6", "t7", "t8"
);
}
s.fBitmap->getColorTable()->unlockColors();
}
/* If we replace a sampleproc, then we null-out the associated shaderproc,