defer allocating blitter until we know we need it (i.e. gpu-devices don't need,
which they signal by setting a custom D1G proc) git-svn-id: http://skia.googlecode.com/svn/trunk@1791 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
b5c97895f3
commit
1d6ee0bd4d
@ -38,6 +38,14 @@
|
|||||||
|
|
||||||
//#define TRACE_BITMAP_DRAWS
|
//#define TRACE_BITMAP_DRAWS
|
||||||
|
|
||||||
|
static bool hasCustomD1GProc(const SkDraw& draw) {
|
||||||
|
return draw.fProcs && draw.fProcs->fD1GProc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool needsRasterTextBlit(const SkDraw& draw) {
|
||||||
|
return !hasCustomD1GProc(draw);
|
||||||
|
}
|
||||||
|
|
||||||
class SkAutoRestoreBounder : SkNoncopyable {
|
class SkAutoRestoreBounder : SkNoncopyable {
|
||||||
public:
|
public:
|
||||||
// note: initializing fBounder is done only to fix a warning
|
// note: initializing fBounder is done only to fix a warning
|
||||||
@ -71,17 +79,27 @@ static SkPoint* rect_points(SkRect& r, int index) {
|
|||||||
|
|
||||||
class SkAutoBlitterChoose {
|
class SkAutoBlitterChoose {
|
||||||
public:
|
public:
|
||||||
|
SkAutoBlitterChoose() {
|
||||||
|
fBlitter = NULL;
|
||||||
|
}
|
||||||
SkAutoBlitterChoose(const SkBitmap& device, const SkMatrix& matrix,
|
SkAutoBlitterChoose(const SkBitmap& device, const SkMatrix& matrix,
|
||||||
const SkPaint& paint) {
|
const SkPaint& paint) {
|
||||||
fBlitter = SkBlitter::Choose(device, matrix, paint,
|
fBlitter = SkBlitter::Choose(device, matrix, paint,
|
||||||
fStorage, sizeof(fStorage));
|
fStorage, sizeof(fStorage));
|
||||||
}
|
}
|
||||||
|
|
||||||
~SkAutoBlitterChoose();
|
~SkAutoBlitterChoose();
|
||||||
|
|
||||||
SkBlitter* operator->() { return fBlitter; }
|
SkBlitter* operator->() { return fBlitter; }
|
||||||
SkBlitter* get() const { return fBlitter; }
|
SkBlitter* get() const { return fBlitter; }
|
||||||
|
|
||||||
|
void choose(const SkBitmap& device, const SkMatrix& matrix,
|
||||||
|
const SkPaint& paint) {
|
||||||
|
SkASSERT(!fBlitter);
|
||||||
|
fBlitter = SkBlitter::Choose(device, matrix, paint,
|
||||||
|
fStorage, sizeof(fStorage));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SkBlitter* fBlitter;
|
SkBlitter* fBlitter;
|
||||||
uint32_t fStorage[kBlitterStorageLongCount];
|
uint32_t fStorage[kBlitterStorageLongCount];
|
||||||
@ -1496,7 +1514,7 @@ SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter,
|
|||||||
fBlitter = blitter;
|
fBlitter = blitter;
|
||||||
fCache = cache;
|
fCache = cache;
|
||||||
|
|
||||||
if (draw->fProcs && draw->fProcs->fD1GProc) {
|
if (hasCustomD1GProc(*draw)) {
|
||||||
return draw->fProcs->fD1GProc;
|
return draw->fProcs->fD1GProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1572,7 +1590,7 @@ void SkDraw::drawText(const char text[], size_t byteLength,
|
|||||||
|
|
||||||
const SkMatrix* matrix = fMatrix;
|
const SkMatrix* matrix = fMatrix;
|
||||||
SkFixed finalFYMask = ~0xFFFF; // trunc fy;
|
SkFixed finalFYMask = ~0xFFFF; // trunc fy;
|
||||||
if (fProcs && fProcs->fD1GProc) {
|
if (hasCustomD1GProc(*this)) {
|
||||||
// only support the fMVMatrix (for now) for the GPU case, which also
|
// only support the fMVMatrix (for now) for the GPU case, which also
|
||||||
// sets the fD1GProc
|
// sets the fD1GProc
|
||||||
if (fMVMatrix) {
|
if (fMVMatrix) {
|
||||||
@ -1583,7 +1601,6 @@ void SkDraw::drawText(const char text[], size_t byteLength,
|
|||||||
|
|
||||||
SkAutoGlyphCache autoCache(paint, matrix);
|
SkAutoGlyphCache autoCache(paint, matrix);
|
||||||
SkGlyphCache* cache = autoCache.getCache();
|
SkGlyphCache* cache = autoCache.getCache();
|
||||||
SkAutoBlitterChoose blitter(*fBitmap, *matrix, paint);
|
|
||||||
|
|
||||||
// transform our starting point
|
// transform our starting point
|
||||||
{
|
{
|
||||||
@ -1630,6 +1647,11 @@ void SkDraw::drawText(const char text[], size_t byteLength,
|
|||||||
fy += SK_FixedHalf;
|
fy += SK_FixedHalf;
|
||||||
fyMask &= finalFYMask;
|
fyMask &= finalFYMask;
|
||||||
|
|
||||||
|
SkAutoBlitterChoose blitter;
|
||||||
|
if (needsRasterTextBlit(*this)) {
|
||||||
|
blitter.choose(*fBitmap, *matrix, paint);
|
||||||
|
}
|
||||||
|
|
||||||
SkAutoKern autokern;
|
SkAutoKern autokern;
|
||||||
SkDraw1Glyph d1g;
|
SkDraw1Glyph d1g;
|
||||||
SkDraw1Glyph::Proc proc = d1g.init(this, blitter.get(), cache);
|
SkDraw1Glyph::Proc proc = d1g.init(this, blitter.get(), cache);
|
||||||
@ -1767,7 +1789,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SkMatrix* matrix = fMatrix;
|
const SkMatrix* matrix = fMatrix;
|
||||||
if (fProcs && fProcs->fD1GProc) {
|
if (hasCustomD1GProc(*this)) {
|
||||||
// only support the fMVMatrix (for now) for the GPU case, which also
|
// only support the fMVMatrix (for now) for the GPU case, which also
|
||||||
// sets the fD1GProc
|
// sets the fD1GProc
|
||||||
if (fMVMatrix) {
|
if (fMVMatrix) {
|
||||||
@ -1778,8 +1800,12 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
|
|||||||
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
|
SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc();
|
||||||
SkAutoGlyphCache autoCache(paint, matrix);
|
SkAutoGlyphCache autoCache(paint, matrix);
|
||||||
SkGlyphCache* cache = autoCache.getCache();
|
SkGlyphCache* cache = autoCache.getCache();
|
||||||
SkAutoBlitterChoose blitter(*fBitmap, *matrix, paint);
|
|
||||||
|
|
||||||
|
SkAutoBlitterChoose blitter;
|
||||||
|
if (needsRasterTextBlit(*this)) {
|
||||||
|
blitter.choose(*fBitmap, *matrix, paint);
|
||||||
|
}
|
||||||
|
|
||||||
const char* stop = text + byteLength;
|
const char* stop = text + byteLength;
|
||||||
AlignProc alignProc = pick_align_proc(paint.getTextAlign());
|
AlignProc alignProc = pick_align_proc(paint.getTextAlign());
|
||||||
SkDraw1Glyph d1g;
|
SkDraw1Glyph d1g;
|
||||||
|
Loading…
Reference in New Issue
Block a user