remove SkBounder -- unused and unloved

BUG=skia:
R=scroggo@google.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/312553006
This commit is contained in:
reed 2014-06-03 10:53:59 -07:00 коммит произвёл Commit bot
Родитель 55ada0630e
Коммит 868074b50b
26 изменённых файлов: 37 добавлений и 557 удалений

Просмотреть файл

@ -57,7 +57,6 @@ public:
virtual void beginCommentGroup(const char* description) SK_OVERRIDE {}
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {}
virtual void endCommentGroup() SK_OVERRIDE {}
virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE {return NULL;}
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE {return NULL;}
virtual bool isClipEmpty() const SK_OVERRIDE { return false; }

Просмотреть файл

@ -18,7 +18,6 @@
#include "SkBlurDrawLooper.h"
#include "SkBlurImageFilter.h"
#include "SkBlurMaskFilter.h"
#include "SkBounder.h"
#include "SkCanvas.h"
#include "SkChecksum.h"
#include "SkChunkAlloc.h"

Просмотреть файл

@ -223,7 +223,6 @@
'<(skia_include_path)/core/SkBitmap.h',
'<(skia_include_path)/core/SkBitmapDevice.h',
'<(skia_include_path)/core/SkBlitRow.h',
'<(skia_include_path)/core/SkBounder.h',
'<(skia_include_path)/core/SkCanvas.h',
'<(skia_include_path)/core/SkChecksum.h',
'<(skia_include_path)/core/SkChunkAlloc.h',

Просмотреть файл

@ -217,7 +217,6 @@
'core/SkTime.h',
'core/SkPathMeasure.h',
'core/SkMaskFilter.h',
'core/SkBounder.h',
'core/SkFlate.h',
'core/SkTDArray.h',
'core/SkAnnotation.h',

Просмотреть файл

@ -1,93 +0,0 @@
/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBounder_DEFINED
#define SkBounder_DEFINED
#include "SkTypes.h"
#include "SkRefCnt.h"
#include "SkPoint.h"
struct SkGlyph;
struct SkIRect;
struct SkPoint;
struct SkRect;
class SkPaint;
class SkPath;
class SkRegion;
/** \class SkBounder
Base class for intercepting the device bounds of shapes before they are drawn.
Install a subclass of this in your canvas.
*/
class SkBounder : public SkRefCnt {
public:
SK_DECLARE_INST_COUNT(SkBounder)
SkBounder();
/* Call to perform a clip test before calling onIRect.
Returns the result from onIRect.
*/
bool doIRect(const SkIRect&);
bool doIRectGlyph(const SkIRect& , int x, int y, const SkGlyph&);
protected:
/** Override in your subclass. This is called with the device bounds of an
object (text, geometry, image) just before it is drawn. If your method
returns false, the drawing for that shape is aborted. If your method
returns true, drawing continues. The bounds your method receives have already
been transformed in to device coordinates, and clipped to the current clip.
*/
virtual bool onIRect(const SkIRect&) {
return false;
}
/** Passed to onIRectGlyph with the information about the current glyph.
LSB and RSB are fixed-point (16.16) coordinates of the start and end
of the glyph's advance
*/
struct GlyphRec {
SkIPoint fLSB; //!< fixed-point left-side-bearing of the glyph
SkIPoint fRSB; //!< fixed-point right-side-bearing of the glyph
uint16_t fGlyphID;
uint16_t fFlags; //!< currently set to 0
};
/** Optionally, override in your subclass to receive the glyph ID when
text drawing supplies the device bounds of the object.
*/
virtual bool onIRectGlyph(const SkIRect& r, const GlyphRec&) {
return onIRect(r);
}
/** Called after each shape has been drawn. The default implementation does
nothing, but your override could use this notification to signal itself
that the offscreen being rendered into needs to be updated to the screen.
*/
virtual void commit();
private:
bool doHairline(const SkPoint&, const SkPoint&, const SkPaint&);
bool doRect(const SkRect&, const SkPaint&);
bool doPath(const SkPath&, const SkPaint&, bool doFill);
void setClip(const SkRegion* clip) { fClip = clip; }
const SkRegion* fClip;
friend class SkAutoBounderCommit;
friend class SkDraw;
friend class SkDrawIter;
friend struct Draw1Glyph;
friend class SkMaskFilter;
typedef SkRefCnt INHERITED;
};
#endif

Просмотреть файл

@ -18,22 +18,12 @@
#include "SkRegion.h"
#include "SkXfermode.h"
// if not defined, we always assume ClipToLayer for saveLayer()
//#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
//#define SK_SUPPORT_LEGACY_GETCLIPTYPE
//#define SK_SUPPORT_LEGACY_GETTOTALCLIP
//#define SK_SUPPORT_LEGACY_GETTOPDEVICE
//#define SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL
#ifdef SK_SUPPORT_LEGACY_DRAWTEXT_VIRTUAL
#define SK_LEGACY_DRAWTEXT_VIRTUAL virtual
#else
#define SK_LEGACY_DRAWTEXT_VIRTUAL
#endif
class SkBounder;
class SkBaseDevice;
class SkDraw;
class SkDrawFilter;
@ -1069,22 +1059,6 @@ public:
//////////////////////////////////////////////////////////////////////////
/** Get the current bounder object.
The bounder's reference count is unchaged.
@return the canva's bounder (or NULL).
*/
SkBounder* getBounder() const { return fBounder; }
/** Set a new bounder (or NULL).
Pass NULL to clear any previous bounder.
As a convenience, the parameter passed is also returned.
If a previous bounder exists, its reference count is decremented.
If bounder is not NULL, its reference count is incremented.
@param bounder the new bounder (or NULL) to be installed in the canvas
@return the set bounder object
*/
virtual SkBounder* setBounder(SkBounder* bounder);
/** Get the current filter object. The filter's reference count is not
affected. The filter is saved/restored, just like the matrix and clip.
@return the canvas' filter (or NULL).
@ -1304,7 +1278,6 @@ private:
// the first N recs that can fit here mean we won't call malloc
uint32_t fMCRecStorage[32];
SkBounder* fBounder;
int fSaveLayerCount; // number of successful saveLayer calls
int fCullCount; // number of active culls

Просмотреть файл

@ -15,7 +15,6 @@
#include "SkPaint.h"
class SkBitmap;
class SkBounder;
class SkClipStack;
class SkBaseDevice;
class SkMatrix;
@ -140,7 +139,6 @@ public:
const SkClipStack* fClipStack; // optional
SkBaseDevice* fDevice; // optional
SkBounder* fBounder; // optional
SkDrawProcs* fProcs; // optional
#ifdef SK_DEBUG

Просмотреть файл

@ -19,7 +19,6 @@ class GrContext;
class GrPaint;
class SkBitmap;
class SkBlitter;
class SkBounder;
class SkMatrix;
class SkPath;
class SkRasterClip;
@ -205,17 +204,15 @@ private:
to render that mask. Returns false if filterMask() returned false.
This method is not exported to java.
*/
bool filterPath(const SkPath& devPath, const SkMatrix& devMatrix,
const SkRasterClip&, SkBounder*, SkBlitter* blitter,
SkPaint::Style style) const;
bool filterPath(const SkPath& devPath, const SkMatrix& ctm, const SkRasterClip&, SkBlitter*,
SkPaint::Style) const;
/** Helper method that, given a roundRect in device space, will rasterize it into a kA8_Format
mask and then call filterMask(). If this returns true, the specified blitter will be called
to render that mask. Returns false if filterMask() returned false.
*/
bool filterRRect(const SkRRect& devRRect, const SkMatrix& devMatrix,
const SkRasterClip&, SkBounder*, SkBlitter* blitter,
SkPaint::Style style) const;
bool filterRRect(const SkRRect& devRRect, const SkMatrix& ctm, const SkRasterClip&,
SkBlitter*, SkPaint::Style style) const;
typedef SkFlattenable INHERITED;
};

Просмотреть файл

@ -168,7 +168,6 @@ public:
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) SK_OVERRIDE;
virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE;
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
protected:

Просмотреть файл

@ -51,7 +51,6 @@ public:
const SkPaint&) SK_OVERRIDE;
virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
virtual SkBounder* setBounder(SkBounder*) SK_OVERRIDE;
virtual SkDrawFilter* setDrawFilter(SkDrawFilter*) SK_OVERRIDE;
virtual void beginCommentGroup(const char* description) SK_OVERRIDE;

Просмотреть файл

@ -54,7 +54,6 @@ public:
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
virtual void endCommentGroup() SK_OVERRIDE;
virtual SkBounder* setBounder(SkBounder* bounder) SK_OVERRIDE;
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
protected:

Просмотреть файл

@ -4,6 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SampleApp.h"
#include "SkData.h"
@ -2270,14 +2271,6 @@ bool SampleView::onEvent(const SkEvent& evt) {
return true;
}
if (evt.isType("debug-hit-test")) {
fDebugHitTest = true;
evt.findS32("debug-hit-test-x", &fDebugHitTestLoc.fX);
evt.findS32("debug-hit-test-y", &fDebugHitTestLoc.fY);
this->inval(NULL);
return true;
}
return this->INHERITED::onEvent(evt);
}
@ -2385,45 +2378,13 @@ void SampleView::draw(SkCanvas* canvas) {
}
}
#include "SkBounder.h"
class DebugHitTestBounder : public SkBounder {
public:
DebugHitTestBounder(int x, int y) {
fLoc.set(x, y);
}
virtual bool onIRect(const SkIRect& bounds) SK_OVERRIDE {
if (bounds.contains(fLoc.x(), fLoc.y())) {
//
// Set a break-point here to see what was being drawn under
// the click point (just needed a line of code to stop the debugger)
//
bounds.centerX();
}
return true;
}
private:
SkIPoint fLoc;
typedef SkBounder INHERITED;
};
void SampleView::onDraw(SkCanvas* canvas) {
this->onDrawBackground(canvas);
DebugHitTestBounder bounder(fDebugHitTestLoc.x(), fDebugHitTestLoc.y());
if (fDebugHitTest) {
canvas->setBounder(&bounder);
}
for (int i = 0; i < fRepeatCount; i++) {
SkAutoCanvasRestore acr(canvas, true);
this->onDrawContent(canvas);
}
fDebugHitTest = false;
canvas->setBounder(NULL);
}
void SampleView::onDrawBackground(SkCanvas* canvas) {

Просмотреть файл

@ -109,8 +109,7 @@ public:
: fPipeState(SkOSMenu::kOffState)
, fBGColor(SK_ColorWHITE)
, fRepeatCount(1)
, fDebugHitTest(false) {
}
{}
void setBGColor(SkColor color) { fBGColor = color; }
@ -145,9 +144,6 @@ protected:
private:
int fRepeatCount;
bool fDebugHitTest;
SkIPoint fDebugHitTestLoc;
typedef SkView INHERITED;
};

Просмотреть файл

@ -42,7 +42,7 @@ void SkBoundable::enableBounder() {
SkBoundableAuto::SkBoundableAuto(SkBoundable* boundable,
SkAnimateMaker& maker) : fBoundable(boundable), fMaker(maker) {
if (fBoundable->hasBounds()) {
fMaker.fCanvas->setBounder(&maker.fDisplayList);
// fMaker.fCanvas->setBounder(&maker.fDisplayList);
fMaker.fDisplayList.fBounds.setEmpty();
}
}
@ -50,6 +50,6 @@ SkBoundableAuto::SkBoundableAuto(SkBoundable* boundable,
SkBoundableAuto::~SkBoundableAuto() {
if (fBoundable->hasBounds() == false)
return;
fMaker.fCanvas->setBounder(NULL);
// fMaker.fCanvas->setBounder(NULL);
fBoundable->setBounds(fMaker.fDisplayList.fBounds);
}

Просмотреть файл

@ -1,4 +1,3 @@
/*
* Copyright 2006 The Android Open Source Project
*
@ -6,14 +5,13 @@
* found in the LICENSE file.
*/
#ifndef SkDisplayList_DEFINED
#define SkDisplayList_DEFINED
#include "SkOperand.h"
#include "SkIntArray.h"
#include "SkBounder.h"
#include "SkRect.h"
#include "SkRefCnt.h"
class SkAnimateMaker;
class SkActive;
@ -21,7 +19,7 @@ class SkApply;
class SkDrawable;
class SkGroup;
class SkDisplayList : public SkBounder {
class SkDisplayList : public SkRefCnt {
public:
SkDisplayList();
virtual ~SkDisplayList();

Просмотреть файл

@ -1,4 +1,3 @@
/*
* Copyright 2008 The Android Open Source Project
*
@ -9,7 +8,6 @@
#include "SkCanvas.h"
#include "SkBitmapDevice.h"
#include "SkBounder.h"
#include "SkDeviceImageFilterProxy.h"
#include "SkDraw.h"
#include "SkDrawFilter.h"
@ -257,7 +255,6 @@ public:
canvas->updateDeviceCMCache();
fClipStack = &canvas->fClipStack;
fBounder = canvas->getBounder();
fCurrLayer = canvas->fMCRec->fTopLayer;
fSkipEmptyClips = skipEmptyClips;
}
@ -282,9 +279,6 @@ public:
SkDEBUGCODE(this->validate();)
fCurrLayer = rec->fNext;
if (fBounder) {
fBounder->setClip(fClip);
}
// fCurrLayer may be NULL now
return true;
@ -424,23 +418,6 @@ bool AutoDrawLooper::doNext(SkDrawFilter::Type drawType) {
return true;
}
/* Stack helper for managing a SkBounder. In the destructor, if we were
given a bounder, we call its commit() method, signifying that we are
done accumulating bounds for that draw.
*/
class SkAutoBounderCommit {
public:
SkAutoBounderCommit(SkBounder* bounder) : fBounder(bounder) {}
~SkAutoBounderCommit() {
if (NULL != fBounder) {
fBounder->commit();
}
}
private:
SkBounder* fBounder;
};
#define SkAutoBounderCommit(...) SK_REQUIRE_LOCAL_VAR(SkAutoBounderCommit)
#include "SkColorPriv.h"
////////// macros to place around the internal draw calls //////////////////
@ -449,14 +426,12 @@ private:
this->predrawNotify(); \
AutoDrawLooper looper(this, paint, true); \
while (looper.next(type)) { \
SkAutoBounderCommit ac(fBounder); \
SkDrawIter iter(this);
#define LOOPER_BEGIN(paint, type, bounds) \
this->predrawNotify(); \
AutoDrawLooper looper(this, paint, false, bounds); \
while (looper.next(type)) { \
SkAutoBounderCommit ac(fBounder); \
SkDrawIter iter(this);
#define LOOPER_END }
@ -464,7 +439,6 @@ private:
////////////////////////////////////////////////////////////////////////////
SkBaseDevice* SkCanvas::init(SkBaseDevice* device) {
fBounder = NULL;
fCachedLocalClipBounds.setEmpty();
fCachedLocalClipBoundsDirty = true;
fAllowSoftClip = true;
@ -526,17 +500,11 @@ SkCanvas::~SkCanvas() {
this->internalRestore(); // restore the last, since we're going away
SkSafeUnref(fBounder);
SkDELETE(fMetaData);
dec_canvas();
}
SkBounder* SkCanvas::setBounder(SkBounder* bounder) {
SkRefCnt_SafeAssign(fBounder, bounder);
return bounder;
}
SkDrawFilter* SkCanvas::getDrawFilter() const {
return fMCRec->fFilter;
}

Просмотреть файл

@ -7,7 +7,6 @@
#include "SkDraw.h"
#include "SkBlitter.h"
#include "SkBounder.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkDevice.h"
@ -259,9 +258,6 @@ void SkDraw::drawPaint(const SkPaint& paint) const {
SkIRect devRect;
devRect.set(0, 0, fBitmap->width(), fBitmap->height());
if (fBounder && !fBounder->doIRect(devRect)) {
return;
}
if (fRC->isBW()) {
/* If we don't have a shader (i.e. we're just a solid color) we may
@ -535,21 +531,6 @@ PtProcRec::Proc PtProcRec::chooseProc(SkBlitter** blitterPtr) {
return proc;
}
static bool bounder_points(SkBounder* bounder, SkCanvas::PointMode mode,
size_t count, const SkPoint pts[],
const SkPaint& paint, const SkMatrix& matrix) {
SkIRect ibounds;
SkRect bounds;
SkScalar inset = paint.getStrokeWidth();
bounds.set(pts, SkToInt(count));
bounds.inset(-inset, -inset);
matrix.mapRect(&bounds);
bounds.roundOut(&ibounds);
return bounder->doIRect(ibounds);
}
// each of these costs 8-bytes of stack space, so don't make it too large
// must be even for lines/polygon to work
#define MAX_DEV_PTS 32
@ -574,19 +555,6 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count,
return;
}
if (fBounder) {
if (!bounder_points(fBounder, mode, count, pts, paint, *fMatrix)) {
return;
}
// clear the bounder and call this again, so we don't invoke the bounder
// later if we happen to call ourselves for drawRect, drawPath, etc.
SkDraw noBounder(*this);
noBounder.fBounder = NULL;
noBounder.drawPoints(mode, count, pts, paint, forceUseDevice);
return;
}
PtProcRec rec;
if (!forceUseDevice && rec.init(mode, paint, fMatrix, fRC)) {
SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint);
@ -842,10 +810,6 @@ void SkDraw::drawRect(const SkRect& rect, const SkPaint& paint) const {
matrix.mapPoints(rect_points(devRect), rect_points(rect), 2);
devRect.sort();
if (fBounder && !fBounder->doRect(devRect, paint)) {
return;
}
// look for the quick exit, before we build a blitter
SkIRect ir;
devRect.roundOut(&ir);
@ -916,10 +880,6 @@ void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint) const {
}
SkAutoMaskFreeImage ami(dstM.fImage);
if (fBounder && !fBounder->doIRect(mask->fBounds)) {
return;
}
SkAutoBlitterChoose blitterChooser(*fBitmap, *fMatrix, paint);
SkBlitter* blitter = blitterChooser.get();
@ -1015,8 +975,7 @@ void SkDraw::drawRRect(const SkRRect& rrect, const SkPaint& paint) const {
SkRRect devRRect;
if (rrect.transform(*fMatrix, &devRRect)) {
SkAutoBlitterChoose blitter(*fBitmap, *fMatrix, paint);
if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC,
fBounder, blitter.get(),
if (paint.getMaskFilter()->filterRRect(devRRect, *fMatrix, *fRC, blitter.get(),
SkPaint::kFill_Style)) {
return; // filterRRect() called the blitter, so we're done
}
@ -1123,17 +1082,11 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
if (paint->getMaskFilter()) {
SkPaint::Style style = doFill ? SkPaint::kFill_Style :
SkPaint::kStroke_Style;
if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC,
fBounder, blitter.get(),
style)) {
if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, blitter.get(), style)) {
return; // filterPath() called the blitter, so we're done
}
}
if (fBounder && !fBounder->doPath(*devPathPtr, *paint, doFill)) {
return;
}
void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*);
if (doFill) {
if (paint->isAntiAlias()) {
@ -1283,18 +1236,7 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix,
return;
}
if (fBounder && just_translate(matrix, bitmap)) {
SkIRect ir;
int32_t ix = SkScalarRoundToInt(matrix.getTranslateX());
int32_t iy = SkScalarRoundToInt(matrix.getTranslateY());
ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height());
if (!fBounder->doIRect(ir)) {
return;
}
}
if (bitmap.colorType() != kAlpha_8_SkColorType &&
just_translate(matrix, bitmap)) {
if (bitmap.colorType() != kAlpha_8_SkColorType && just_translate(matrix, bitmap)) {
//
// It is safe to call lock pixels now, since we know the matrix is
// (more or less) identity.
@ -1366,10 +1308,6 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y,
x, y, &allocator);
if (blitter) {
if (fBounder && !fBounder->doIRect(bounds)) {
return;
}
SkScan::FillIRect(bounds, *fRC, blitter);
return;
}
@ -1472,13 +1410,10 @@ void SkDraw::drawText_asPaths(const char text[], size_t byteLength,
//////////////////////////////////////////////////////////////////////////////
static void D1G_NoBounder_RectClip(const SkDraw1Glyph& state,
SkFixed fx, SkFixed fy,
const SkGlyph& glyph) {
static void D1G_RectClip(const SkDraw1Glyph& state, SkFixed fx, SkFixed fy, const SkGlyph& glyph) {
int left = SkFixedFloorToInt(fx);
int top = SkFixedFloorToInt(fy);
SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
SkASSERT(NULL == state.fBounder);
SkASSERT((NULL == state.fClip && state.fAAClip) ||
(state.fClip && NULL == state.fAAClip && state.fClip->isRect()));
@ -1516,14 +1451,11 @@ static void D1G_NoBounder_RectClip(const SkDraw1Glyph& state,
state.blitMask(mask, *bounds);
}
static void D1G_NoBounder_RgnClip(const SkDraw1Glyph& state,
SkFixed fx, SkFixed fy,
const SkGlyph& glyph) {
static void D1G_RgnClip(const SkDraw1Glyph& state, SkFixed fx, SkFixed fy, const SkGlyph& glyph) {
int left = SkFixedFloorToInt(fx);
int top = SkFixedFloorToInt(fy);
SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
SkASSERT(!state.fClip->isRect());
SkASSERT(NULL == state.fBounder);
SkMask mask;
@ -1553,60 +1485,6 @@ static void D1G_NoBounder_RgnClip(const SkDraw1Glyph& state,
}
}
static void D1G_Bounder(const SkDraw1Glyph& state,
SkFixed fx, SkFixed fy,
const SkGlyph& glyph) {
int left = SkFixedFloorToInt(fx);
int top = SkFixedFloorToInt(fy);
SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
SkMask mask;
left += glyph.fLeft;
top += glyph.fTop;
mask.fBounds.set(left, top, left + glyph.fWidth, top + glyph.fHeight);
SkRegion::Cliperator clipper(*state.fClip, mask.fBounds);
if (!clipper.done()) {
const SkIRect& cr = clipper.rect();
const uint8_t* aa = (const uint8_t*)glyph.fImage;
if (NULL == aa) {
aa = (uint8_t*)state.fCache->findImage(glyph);
if (NULL == aa) {
return;
}
}
// we need to pass the origin, which we approximate with our
// (unadjusted) left,top coordinates (the caller called fixedfloor)
if (state.fBounder->doIRectGlyph(cr,
left - glyph.fLeft,
top - glyph.fTop, glyph)) {
mask.fRowBytes = glyph.rowBytes();
mask.fFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
mask.fImage = (uint8_t*)aa;
do {
state.blitMask(mask, cr);
clipper.next();
} while (!clipper.done());
}
}
}
static void D1G_Bounder_AAClip(const SkDraw1Glyph& state,
SkFixed fx, SkFixed fy,
const SkGlyph& glyph) {
int left = SkFixedFloorToInt(fx);
int top = SkFixedFloorToInt(fy);
SkIRect bounds;
bounds.set(left, top, left + glyph.fWidth, top + glyph.fHeight);
if (state.fBounder->doIRectGlyph(bounds, left, top, glyph)) {
D1G_NoBounder_RectClip(state, fx, fy, glyph);
}
}
static bool hasCustomD1GProc(const SkDraw& draw) {
return draw.fProcs && draw.fProcs->fD1GProc;
}
@ -1615,10 +1493,9 @@ static bool needsRasterTextBlit(const SkDraw& draw) {
return !hasCustomD1GProc(draw);
}
SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter,
SkGlyphCache* cache, const SkPaint& pnt) {
SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache,
const SkPaint& pnt) {
fDraw = draw;
fBounder = draw->fBounder;
fBlitter = blitter;
fCache = cache;
fPaint = &pnt;
@ -1640,24 +1517,16 @@ SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter,
fAAClip = NULL;
fClip = &draw->fRC->bwRgn();
fClipBounds = fClip->getBounds();
if (NULL == fBounder) {
if (fClip->isRect()) {
return D1G_NoBounder_RectClip;
} else {
return D1G_NoBounder_RgnClip;
}
if (fClip->isRect()) {
return D1G_RectClip;
} else {
return D1G_Bounder;
return D1G_RgnClip;
}
} else { // aaclip
fAAClip = &draw->fRC->aaRgn();
fClip = NULL;
fClipBounds = fAAClip->getBounds();
if (NULL == fBounder) {
return D1G_NoBounder_RectClip;
} else {
return D1G_Bounder_AAClip;
}
return D1G_RectClip;
}
}
@ -2377,14 +2246,6 @@ void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
SkPoint* devVerts = storage.get();
fMatrix->mapPoints(devVerts, vertices, count);
if (fBounder) {
SkRect bounds;
bounds.set(devVerts, count);
if (!fBounder->doRect(bounds, paint)) {
return;
}
}
/*
We can draw the vertices in 1 of 4 ways:
@ -2516,97 +2377,6 @@ void SkDraw::validate() const {
#endif
///////////////////////////////////////////////////////////////////////////////
SkBounder::SkBounder() {
// initialize up front. This gets reset by SkCanvas before each draw call.
fClip = &SkRegion::GetEmptyRegion();
}
bool SkBounder::doIRect(const SkIRect& r) {
SkIRect rr;
return rr.intersect(fClip->getBounds(), r) && this->onIRect(rr);
}
// TODO: change the prototype to take fixed, and update the callers
bool SkBounder::doIRectGlyph(const SkIRect& r, int x, int y,
const SkGlyph& glyph) {
SkIRect rr;
if (!rr.intersect(fClip->getBounds(), r)) {
return false;
}
GlyphRec rec;
rec.fLSB.set(SkIntToFixed(x), SkIntToFixed(y));
rec.fRSB.set(rec.fLSB.fX + glyph.fAdvanceX,
rec.fLSB.fY + glyph.fAdvanceY);
rec.fGlyphID = glyph.getGlyphID();
rec.fFlags = 0;
return this->onIRectGlyph(rr, rec);
}
bool SkBounder::doHairline(const SkPoint& pt0, const SkPoint& pt1,
const SkPaint& paint) {
SkIRect r;
SkScalar v0, v1;
v0 = pt0.fX;
v1 = pt1.fX;
if (v0 > v1) {
SkTSwap<SkScalar>(v0, v1);
}
r.fLeft = SkScalarFloorToInt(v0);
r.fRight = SkScalarCeilToInt(v1);
v0 = pt0.fY;
v1 = pt1.fY;
if (v0 > v1) {
SkTSwap<SkScalar>(v0, v1);
}
r.fTop = SkScalarFloorToInt(v0);
r.fBottom = SkScalarCeilToInt(v1);
if (paint.isAntiAlias()) {
r.inset(-1, -1);
}
return this->doIRect(r);
}
bool SkBounder::doRect(const SkRect& rect, const SkPaint& paint) {
SkIRect r;
if (paint.getStyle() == SkPaint::kFill_Style) {
rect.round(&r);
} else {
int rad = -1;
rect.roundOut(&r);
if (paint.isAntiAlias()) {
rad = -2;
}
r.inset(rad, rad);
}
return this->doIRect(r);
}
bool SkBounder::doPath(const SkPath& path, const SkPaint& paint, bool doFill) {
SkIRect r;
const SkRect& bounds = path.getBounds();
if (doFill) {
bounds.round(&r);
} else { // hairline
bounds.roundOut(&r);
}
if (paint.isAntiAlias()) {
r.inset(-1, -1);
}
return this->doIRect(r);
}
void SkBounder::commit() {
// override in subclass
}
////////////////////////////////////////////////////////////////////////////////////////////////
#include "SkPath.h"
@ -2682,7 +2452,6 @@ static void draw_into_mask(const SkMask& mask, const SkPath& devPath,
draw.fRC = &clip;
draw.fClip = &clip.bwRgn();
draw.fMatrix = &matrix;
draw.fBounder = NULL;
paint.setAntiAlias(true);
paint.setStyle(style);
draw.drawPath(devPath, paint);

Просмотреть файл

@ -1,10 +1,10 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDrawProcs_DEFINED
#define SkDrawProcs_DEFINED
@ -16,7 +16,6 @@ class SkBlitter;
struct SkDraw1Glyph {
const SkDraw* fDraw;
SkBounder* fBounder;
const SkRegion* fClip;
const SkAAClip* fAAClip;
SkBlitter* fBlitter;

Просмотреть файл

@ -9,7 +9,6 @@
#include "SkMaskFilter.h"
#include "SkBlitter.h"
#include "SkBounder.h"
#include "SkDraw.h"
#include "SkRasterClip.h"
#include "SkRRect.h"
@ -181,17 +180,15 @@ static void draw_nine_clipped(const SkMask& mask, const SkIRect& outerR,
}
}
static void draw_nine(const SkMask& mask, const SkIRect& outerR,
const SkIPoint& center, bool fillCenter,
const SkRasterClip& clip, SkBounder* bounder,
SkBlitter* blitter) {
static void draw_nine(const SkMask& mask, const SkIRect& outerR, const SkIPoint& center,
bool fillCenter, const SkRasterClip& clip, SkBlitter* blitter) {
// if we get here, we need to (possibly) resolve the clip and blitter
SkAAClipBlitterWrapper wrapper(clip, blitter);
blitter = wrapper.getBlitter();
SkRegion::Cliperator clipper(wrapper.getRgn(), outerR);
if (!clipper.done() && (!bounder || bounder->doIRect(outerR))) {
if (!clipper.done()) {
const SkIRect& cr = clipper.rect();
do {
draw_nine_clipped(mask, outerR, center, fillCenter, cr, blitter);
@ -208,8 +205,8 @@ static int countNestedRects(const SkPath& path, SkRect rects[2]) {
}
bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix,
const SkRasterClip& clip, SkBounder* bounder,
SkBlitter* blitter, SkPaint::Style style) const {
const SkRasterClip& clip, SkBlitter* blitter,
SkPaint::Style style) const {
// Attempt to speed up drawing by creating a nine patch. If a nine patch
// cannot be used, return false to allow our caller to recover and perform
// the drawing another way.
@ -221,15 +218,14 @@ bool SkMaskFilter::filterRRect(const SkRRect& devRRect, const SkMatrix& matrix,
SkASSERT(NULL == patch.fMask.fImage);
return false;
}
draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, true, clip,
bounder, blitter);
draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, true, clip, blitter);
SkMask::FreeImage(patch.fMask.fImage);
return true;
}
bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
const SkRasterClip& clip, SkBounder* bounder,
SkBlitter* blitter, SkPaint::Style style) const {
const SkRasterClip& clip, SkBlitter* blitter,
SkPaint::Style style) const {
SkRect rects[2];
int rectCount = 0;
if (SkPaint::kFill_Style == style) {
@ -246,8 +242,8 @@ bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
return false;
case kTrue_FilterReturn:
draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter,
1 == rectCount, clip, bounder, blitter);
draw_nine(patch.fMask, patch.fOuterRect, patch.fCenter, 1 == rectCount, clip,
blitter);
SkMask::FreeImage(patch.fMask.fImage);
return true;
@ -278,7 +274,7 @@ bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
SkRegion::Cliperator clipper(wrapper.getRgn(), dstM.fBounds);
if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds))) {
if (!clipper.done()) {
const SkIRect& cr = clipper.rect();
do {
blitter->blitMask(dstM, cr);

Просмотреть файл

@ -146,7 +146,6 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
draw.fRC = &rectClip;
draw.fClip = &rectClip.bwRgn();
// we set the matrixproc in the loop, as the matrix changes each time (potentially)
draw.fBounder = NULL;
SkDeque::F2BIter iter(*fLayers);
SkLayerRasterizer_Rec* rec;

Просмотреть файл

@ -20,7 +20,6 @@
#include "SkGrTexturePixelRef.h"
#include "SkBounder.h"
#include "SkDeviceImageFilterProxy.h"
#include "SkDrawProcs.h"
#include "SkGlyphCache.h"
@ -532,10 +531,6 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
// clipped out
return;
}
if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) {
// nothing to draw
return;
}
if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, &grPaint,
stroke, devRRect)) {
return;
@ -611,7 +606,6 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
}
#include "SkMaskFilter.h"
#include "SkBounder.h"
///////////////////////////////////////////////////////////////////////////////
@ -638,7 +632,7 @@ bool draw_mask(GrContext* context, const SkRect& maskRect,
}
bool draw_with_mask_filter(GrContext* context, const SkPath& devPath,
SkMaskFilter* filter, const SkRegion& clip, SkBounder* bounder,
SkMaskFilter* filter, const SkRegion& clip,
GrPaint* grp, SkPaint::Style style) {
SkMask srcM, dstM;
@ -657,9 +651,6 @@ bool draw_with_mask_filter(GrContext* context, const SkPath& devPath,
if (clip.quickReject(dstM.fBounds)) {
return false;
}
if (bounder && !bounder->doIRect(dstM.fBounds)) {
return false;
}
// we now have a device-aligned 8bit mask in dstM, ready to be drawn using
// the current clip (and identity matrix) and GrPaint settings
@ -819,10 +810,6 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
// clipped out
return;
}
if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) {
// nothing to draw
return;
}
if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint,
stroke, *devPathPtr)) {
@ -862,8 +849,8 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
// GPU path fails
SkPaint::Style style = stroke.isHairlineStyle() ? SkPaint::kStroke_Style :
SkPaint::kFill_Style;
draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(),
*draw.fClip, draw.fBounder, &grPaint, style);
draw_with_mask_filter(fContext, *devPathPtr, paint.getMaskFilter(), *draw.fClip, &grPaint,
style);
return;
}

Просмотреть файл

@ -953,13 +953,6 @@ void SkDeferredCanvas::drawVertices(VertexMode vmode, int vertexCount,
this->recordedDrawCommand();
}
SkBounder* SkDeferredCanvas::setBounder(SkBounder* bounder) {
this->drawingCanvas()->setBounder(bounder);
this->INHERITED::setBounder(bounder);
this->recordedDrawCommand();
return bounder;
}
SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) {
this->drawingCanvas()->setDrawFilter(filter);
this->INHERITED::setDrawFilter(filter);

Просмотреть файл

@ -291,14 +291,6 @@ void SkNWayCanvas::drawData(const void* data, size_t length) {
}
}
SkBounder* SkNWayCanvas::setBounder(SkBounder* bounder) {
Iter iter(fList);
while (iter.next()) {
iter->setBounder(bounder);
}
return this->INHERITED::setBounder(bounder);
}
SkDrawFilter* SkNWayCanvas::setDrawFilter(SkDrawFilter* filter) {
Iter iter(fList);
while (iter.next()) {

Просмотреть файл

@ -165,10 +165,6 @@ void SkProxyCanvas::endCommentGroup() {
fProxy->endCommentGroup();
}
SkBounder* SkProxyCanvas::setBounder(SkBounder* bounder) {
return fProxy->setBounder(bounder);
}
SkDrawFilter* SkProxyCanvas::setDrawFilter(SkDrawFilter* filter) {
return fProxy->setDrawFilter(filter);
}

Просмотреть файл

@ -14,38 +14,6 @@
#define SK_EventDelayInval "\xd" "n" "\xa" "l"
#define TEST_BOUNDERx
#include "SkBounder.h"
class TestSkBounder : public SkBounder {
public:
explicit TestSkBounder(const SkBitmap& bm) : fCanvas(bm) {}
protected:
virtual bool onIRect(const SkIRect& r) SK_OVERRIDE {
SkRect rr;
rr.set(SkIntToScalar(r.fLeft), SkIntToScalar(r.fTop),
SkIntToScalar(r.fRight), SkIntToScalar(r.fBottom));
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
p.setColor(SK_ColorYELLOW);
#if 0
rr.inset(SK_ScalarHalf, SK_ScalarHalf);
#else
rr.inset(-SK_ScalarHalf, -SK_ScalarHalf);
#endif
fCanvas.drawRect(rr, p);
return true;
}
private:
SkCanvas fCanvas;
};
SkWindow::SkWindow() : fFocusView(NULL) {
fClicks.reset();
fWaitingOnInval = false;
@ -171,10 +139,6 @@ bool SkWindow::update(SkIRect* updateArea) {
// might be made during the draw call.
fDirtyRgn.setEmpty();
#ifdef TEST_BOUNDER
TestSkBounder bounder(bm);
canvas->setBounder(&bounder);
#endif
#ifdef SK_SIMULATE_FAILED_MALLOC
gEnableControlledThrow = true;
#endif
@ -190,9 +154,6 @@ bool SkWindow::update(SkIRect* updateArea) {
#ifdef SK_SIMULATE_FAILED_MALLOC
gEnableControlledThrow = false;
#endif
#ifdef TEST_BOUNDER
canvas->setBounder(NULL);
#endif
#if defined(SK_BUILD_FOR_WINCE) && defined(USE_GX_SCREEN)
GXEndDraw();

Просмотреть файл

@ -632,10 +632,7 @@ static void AssertCanvasStatesEqual(skiatest::Reporter* reporter,
canvas1->getClipDeviceBounds(&deviceBounds1) ==
canvas2->getClipDeviceBounds(&deviceBounds2),
testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, deviceBounds1 == deviceBounds2,
testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, canvas1->getBounder() ==
canvas2->getBounder(), testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, deviceBounds1 == deviceBounds2, testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, canvas1->getTotalMatrix() ==
canvas2->getTotalMatrix(), testStep->assertMessage());
REPORTER_ASSERT_MESSAGE(reporter, equal_clips(*canvas1, *canvas2), testStep->assertMessage());