revert 2783 -- broke debug gm

git-svn-id: http://skia.googlecode.com/svn/trunk@2784 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-12-01 21:47:26 +00:00
parent f974a5d782
commit a89c77b5ca
4 changed files with 57 additions and 72 deletions

View File

@ -24,23 +24,16 @@ class SkBlitter {
public: public:
virtual ~SkBlitter(); virtual ~SkBlitter();
/// Blit a horizontal run of opaque pixels. /// Blit a horizontal run of pixels.
virtual void blitH(int x, int y, int width); virtual void blitH(int x, int y, int width);
/// Blit a horizontal run of antialiased pixels; runs[] is a *sparse* /// Blit a horizontal run of antialiased pixels; runs[] is a *sparse*
/// zero-terminated run-length encoding of spans of constant alpha values. /// zero-terminated run-length encoding of spans of constant alpha values.
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
const int16_t runs[]); const int16_t runs[]);
/** Blit a vertical run of pixels with a constant alpha value. /// Blit a vertical run of pixels with a constant alpha value.
Subclasses may require all blits to be performed in scanline order
and redefine blitV() to cause a runtime error.
*/
virtual void blitV(int x, int y, int height, SkAlpha alpha); virtual void blitV(int x, int y, int height, SkAlpha alpha);
/// Blit an opaque rectangle. /// Blit a solid rectangle.
virtual void blitRect(int x, int y, int width, int height); virtual void blitRect(int x, int y, int width, int height);
/// Blit a rectangle with one antialiased column on the left,
/// width opaque pixels, and one antialiased column on the right.
virtual void blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha);
/// Blit a pattern of pixels defined by a rectangle-clipped mask; /// Blit a pattern of pixels defined by a rectangle-clipped mask;
/// typically used for text. /// typically used for text.
virtual void blitMask(const SkMask&, const SkIRect& clip); virtual void blitMask(const SkMask&, const SkIRect& clip);

View File

@ -930,36 +930,7 @@ public:
SkASSERT(fBounds.contains(x + width - 1, y + height - 1)); SkASSERT(fBounds.contains(x + width - 1, y + height - 1));
this->addRun(x, y, 0xFF, width); this->addRun(x, y, 0xFF, width);
// we assume the rect must be all we'll see for these scanlines // we assum the rect must be all we'll see for these scanlines
// so we ensure our row goes all the way to our right
this->flushRowH(fCurrRow);
y -= fBounds.fTop;
SkASSERT(y == fCurrRow->fY);
fCurrRow->fY = y + height - 1;
}
void addAntiRectRun(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) {
SkASSERT(fBounds.contains(x + width - 1, y + height - 1));
SkASSERT(width >= 0);
// Conceptually we're always adding 3 runs, but we should
// merge or omit them if possible.
if (leftAlpha == 0xFF) {
width++;
} else if (leftAlpha > 0) {
this->addRun(x++, y, leftAlpha, 1);
}
if (rightAlpha == 0xFF) {
width++;
}
this->addRun(x, y, 0xFF, width);
if (rightAlpha > 0 && rightAlpha < 255) {
this->addRun(x + width, y, rightAlpha, 1);
}
// we assume the rect must be all we'll see for these scanlines
// so we ensure our row goes all the way to our right // so we ensure our row goes all the way to our right
this->flushRowH(fCurrRow); this->flushRowH(fCurrRow);
@ -1142,7 +1113,6 @@ public:
} }
} }
// Must evaluate clips in scan-line order, so can't allow blitV()
virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE
{ unexpected(); } { unexpected(); }
@ -1151,12 +1121,6 @@ public:
fBuilder->addRectRun(x, y, width, height); fBuilder->addRectRun(x, y, width, height);
} }
virtual void blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE {
this->recordMinY(y);
fBuilder->addAntiRectRun(x, y, width, height, leftAlpha, rightAlpha);
}
virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE
{ unexpected(); } { unexpected(); }

View File

@ -52,16 +52,6 @@ void SkBlitter::blitRect(int x, int y, int width, int height) {
} }
} }
/// Default implementation doesn't check for any easy optimizations
/// such as alpha == 0 or 255; also uses blitV(), which some subclasses
/// may not support.
void SkBlitter::blitAntiRect(int x, int y, int width, int height,
SkAlpha leftAlpha, SkAlpha rightAlpha) {
this->blitV(x, y, height, leftAlpha);
this->blitRect(x + 1, y, width, height);
this->blitV(x + width - 1, y, height, rightAlpha);
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static inline void bits_to_runs(SkBlitter* blitter, int x, int y, static inline void bits_to_runs(SkBlitter* blitter, int x, int y,
@ -128,8 +118,7 @@ void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
int rite_mask = 0xFF << (8 - (rite_edge & 7)); int rite_mask = 0xFF << (8 - (rite_edge & 7));
int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3); int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3);
// check for empty right mask, so we don't read off the end // check for empty right mask, so we don't read off the end (or go slower than we need to)
// (or go slower than we need to)
if (rite_mask == 0) { if (rite_mask == 0) {
SkASSERT(full_runs >= 0); SkASSERT(full_runs >= 0);
full_runs -= 1; full_runs -= 1;
@ -139,8 +128,8 @@ void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
full_runs -= 1; full_runs -= 1;
} }
// Back up manually so we can keep in sync with our byte-aligned // back up manually so we can keep in sync with our byte-aligned src
// src; have cx reflect our actual starting x-coord. // have cx reflect our actual starting x-coord
cx -= left_edge & 7; cx -= left_edge & 7;
if (full_runs < 0) { if (full_runs < 0) {
@ -152,8 +141,7 @@ void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
} }
} else { } else {
while (--height >= 0) { while (--height >= 0) {
bits_to_runs(this, cx, cy, bits, left_mask, full_runs + 2, bits_to_runs(this, cx, cy, bits, left_mask, full_runs + 2, rite_mask);
rite_mask);
bits += mask_rowBytes; bits += mask_rowBytes;
cy += 1; cy += 1;
} }

View File

@ -219,7 +219,42 @@ void SuperBlitter::blitH(int x, int y, int width) {
#endif #endif
} }
// All parameters are in supersampled space. static void set_left_rite_runs(SkAlphaRuns& runs, int ileft, U8CPU leftA,
int n, U8CPU riteA) {
SkASSERT(leftA <= 0xFF);
SkASSERT(riteA <= 0xFF);
int16_t* run = runs.fRuns;
uint8_t* aa = runs.fAlpha;
if (ileft > 0) {
run[0] = ileft;
aa[0] = 0;
run += ileft;
aa += ileft;
}
SkASSERT(leftA < 0xFF);
if (leftA > 0) {
*run++ = 1;
*aa++ = leftA;
}
if (n > 0) {
run[0] = n;
aa[0] = 0xFF;
run += n;
aa += n;
}
SkASSERT(riteA < 0xFF);
if (riteA > 0) {
*run++ = 1;
*aa++ = riteA;
}
run[0] = 0;
}
void SuperBlitter::blitRect(int x, int y, int width, int height) { void SuperBlitter::blitRect(int x, int y, int width, int height) {
SkASSERT(width > 0); SkASSERT(width > 0);
SkASSERT(height > 0); SkASSERT(height > 0);
@ -240,7 +275,6 @@ void SuperBlitter::blitRect(int x, int y, int width, int height) {
int stop_y = (y + height) >> SHIFT; int stop_y = (y + height) >> SHIFT;
int count = stop_y - start_y; int count = stop_y - start_y;
if (count > 0) { if (count > 0) {
y += count << SHIFT; y += count << SHIFT;
height -= count << SHIFT; height -= count << SHIFT;
@ -284,9 +318,19 @@ void SuperBlitter::blitRect(int x, int y, int width, int height) {
const int coverageR = coverage_to_alpha(xrite) << SHIFT; const int coverageR = coverage_to_alpha(xrite) << SHIFT;
SkASSERT(n + (coverageR != 0) <= fWidth); SkASSERT(n + (coverageR != 0) <= fWidth);
fRealBlitter->blitAntiRect(ileft + fLeft, start_y, n, count, for (int i = start_y; i < stop_y; ++i) {
coverageL > 0 ? coverageL : 255, // note: we should only need to call set_left_rite once, but
coverageR > 0 ? coverageR : 255); // our clipping blitters sometimes modify runs/alpha in-place,
// so for now we reset fRuns each time :(
//
// TODO:
// - don't modify in-place, or at least tell us when you're going to
// - pass height down to blitAntiH (blitAntiHV) so that aaclip and
// other can take advantage of the vertical-repeat explicitly
//
set_left_rite_runs(fRuns, ileft, coverageL, n, coverageR);
fRealBlitter->blitAntiH(fLeft, i, fRuns.fAlpha, fRuns.fRuns);
}
// preamble for our next call to blitH() // preamble for our next call to blitH()
fCurrIY = stop_y - 1; fCurrIY = stop_y - 1;
@ -316,10 +360,6 @@ public:
virtual void blitH(int x, int y, int width) SK_OVERRIDE; virtual void blitH(int x, int y, int width) SK_OVERRIDE;
// TODO: blitAntiRect() if we ever have performance problems -
// but the gains aren't expected to be nearly as large as for
// SuperBlitter.
static bool CanHandleRect(const SkIRect& bounds) { static bool CanHandleRect(const SkIRect& bounds) {
#ifdef FORCE_RLE #ifdef FORCE_RLE
return false; return false;