зеркало из https://github.com/mozilla/moz-skia.git
(re)add SkMask::getAddr() which now checks its pixel-size at runtime.
git-svn-id: http://skia.googlecode.com/svn/trunk@2488 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
7989186dab
Коммит
f52e55543e
|
@ -99,6 +99,20 @@ struct SkMask {
|
|||
return row + (x - fBounds.fLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the specified pixel, computing the pixel-size
|
||||
* at runtime based on the mask format. This will be slightly slower than
|
||||
* using one of the routines where the format is implied by the name
|
||||
* e.g. getAddr8 or getAddrLCD32.
|
||||
*
|
||||
* x,y must be contained by the mask's bounds (this is asserted in the
|
||||
* debug build, but not checked in the release build.)
|
||||
*
|
||||
* This should not be called with kBW_Format, as it will give unspecified
|
||||
* results (and assert in the debug build).
|
||||
*/
|
||||
void* getAddr(int x, int y) const;
|
||||
|
||||
static uint8_t* AllocImage(size_t bytes);
|
||||
static void FreeImage(void* image);
|
||||
|
||||
|
|
|
@ -345,38 +345,13 @@ SkBlitMask::Proc SkBlitMask::Factory(SkBitmap::Config config,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static const int gMaskFormatToShift[] = {
|
||||
~0, // BW
|
||||
0, // A8
|
||||
0, // 3D
|
||||
2, // ARGB32
|
||||
1, // LCD16
|
||||
2 // LCD32
|
||||
};
|
||||
|
||||
static int maskFormatToShift(SkMask::Format format) {
|
||||
SkASSERT((unsigned)format < SK_ARRAY_COUNT(gMaskFormatToShift));
|
||||
SkASSERT(SkMask::kBW_Format != format);
|
||||
return gMaskFormatToShift[format];
|
||||
}
|
||||
|
||||
static const void* getAddr(const SkMask& mask, int x, int y) {
|
||||
SkASSERT(mask.fBounds.contains(x, y));
|
||||
SkASSERT(mask.fImage);
|
||||
|
||||
const char* addr = (const char*)mask.fImage;
|
||||
addr += (y - mask.fBounds.fTop) * mask.fRowBytes;
|
||||
addr += (x - mask.fBounds.fLeft) << maskFormatToShift(mask.fFormat);
|
||||
return addr;
|
||||
}
|
||||
|
||||
bool SkBlitMask::BlitColor(const SkBitmap& device, const SkMask& mask,
|
||||
const SkIRect& clip, SkColor color) {
|
||||
Proc proc = Factory(device.config(), mask.fFormat, color);
|
||||
if (proc) {
|
||||
int x = clip.fLeft;
|
||||
int y = clip.fTop;
|
||||
proc(device.getAddr32(x, y), device.rowBytes(), getAddr(mask, x, y),
|
||||
proc(device.getAddr32(x, y), device.rowBytes(), mask.getAddr(x, y),
|
||||
mask.fRowBytes, color, clip.width(), clip.height());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* Copyright 2007 The Android Open Source Project
|
||||
*
|
||||
|
@ -48,3 +47,31 @@ void SkMask::FreeImage(void* image) {
|
|||
sk_free(image);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const int gMaskFormatToShift[] = {
|
||||
~0, // BW -- not supported
|
||||
0, // A8
|
||||
0, // 3D
|
||||
2, // ARGB32
|
||||
1, // LCD16
|
||||
2 // LCD32
|
||||
};
|
||||
|
||||
static int maskFormatToShift(SkMask::Format format) {
|
||||
SkASSERT((unsigned)format < SK_ARRAY_COUNT(gMaskFormatToShift));
|
||||
SkASSERT(SkMask::kBW_Format != format);
|
||||
return gMaskFormatToShift[format];
|
||||
}
|
||||
|
||||
void* SkMask::getAddr(int x, int y) const {
|
||||
SkASSERT(kBW_Format != fFormat);
|
||||
SkASSERT(fBounds.contains(x, y));
|
||||
SkASSERT(fImage);
|
||||
|
||||
char* addr = (char*)fImage;
|
||||
addr += (y - fBounds.fTop) * fRowBytes;
|
||||
addr += (x - fBounds.fLeft) << maskFormatToShift(fFormat);
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче