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; }
#include "SkBlurDrawLooper.h"
#include "SkBlurImageFilter.h"
#include "SkBlurMaskFilter.h"
-#include "SkBounder.h"
#include "SkCanvas.h"
#include "SkChecksum.h"
#include "SkChunkAlloc.h"
'<(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',
'core/SkTime.h',
'core/SkPathMeasure.h',
'core/SkMaskFilter.h',
- 'core/SkBounder.h',
'core/SkFlate.h',
'core/SkTDArray.h',
'core/SkAnnotation.h',
+++ /dev/null
-
-/*
- * 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
#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;
//////////////////////////////////////////////////////////////////////////
- /** 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).
// 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
#include "SkPaint.h"
class SkBitmap;
-class SkBounder;
class SkClipStack;
class SkBaseDevice;
class SkMatrix;
const SkClipStack* fClipStack; // optional
SkBaseDevice* fDevice; // optional
- SkBounder* fBounder; // optional
SkDrawProcs* fProcs; // optional
#ifdef SK_DEBUG
class GrPaint;
class SkBitmap;
class SkBlitter;
-class SkBounder;
class SkMatrix;
class SkPath;
class SkRasterClip;
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;
};
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:
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;
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:
* 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"
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);
}
}
}
-#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) {
: fPipeState(SkOSMenu::kOffState)
, fBGColor(SK_ColorWHITE)
, fRepeatCount(1)
- , fDebugHitTest(false) {
- }
+ {}
void setBGColor(SkColor color) { fBGColor = color; }
private:
int fRepeatCount;
- bool fDebugHitTest;
- SkIPoint fDebugHitTestLoc;
-
typedef SkView INHERITED;
};
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();
}
}
SkBoundableAuto::~SkBoundableAuto() {
if (fBoundable->hasBounds() == false)
return;
- fMaker.fCanvas->setBounder(NULL);
+// fMaker.fCanvas->setBounder(NULL);
fBoundable->setBounds(fMaker.fDisplayList.fBounds);
}
-
/*
* Copyright 2006 The Android Open Source Project
*
* 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;
class SkDrawable;
class SkGroup;
-class SkDisplayList : public SkBounder {
+class SkDisplayList : public SkRefCnt {
public:
SkDisplayList();
virtual ~SkDisplayList();
-
/*
* Copyright 2008 The Android Open Source Project
*
#include "SkCanvas.h"
#include "SkBitmapDevice.h"
-#include "SkBounder.h"
#include "SkDeviceImageFilterProxy.h"
#include "SkDraw.h"
#include "SkDrawFilter.h"
canvas->updateDeviceCMCache();
fClipStack = &canvas->fClipStack;
- fBounder = canvas->getBounder();
fCurrLayer = canvas->fMCRec->fTopLayer;
fSkipEmptyClips = skipEmptyClips;
}
SkDEBUGCODE(this->validate();)
fCurrLayer = rec->fNext;
- if (fBounder) {
- fBounder->setClip(fClip);
- }
// fCurrLayer may be NULL now
return true;
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 //////////////////
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 }
////////////////////////////////////////////////////////////////////////////
SkBaseDevice* SkCanvas::init(SkBaseDevice* device) {
- fBounder = NULL;
fCachedLocalClipBounds.setEmpty();
fCachedLocalClipBoundsDirty = true;
fAllowSoftClip = true;
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;
}
#include "SkDraw.h"
#include "SkBlitter.h"
-#include "SkBounder.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkDevice.h"
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
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
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);
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);
}
SkAutoMaskFreeImage ami(dstM.fImage);
- if (fBounder && !fBounder->doIRect(mask->fBounds)) {
- return;
- }
-
SkAutoBlitterChoose blitterChooser(*fBitmap, *fMatrix, paint);
SkBlitter* blitter = blitterChooser.get();
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
}
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()) {
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.
x, y, &allocator);
if (blitter) {
- if (fBounder && !fBounder->doIRect(bounds)) {
- return;
- }
-
SkScan::FillIRect(bounds, *fRC, blitter);
return;
}
//////////////////////////////////////////////////////////////////////////////
-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()));
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;
}
}
-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;
}
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;
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;
}
}
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:
#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"
draw.fRC = &clip;
draw.fClip = &clip.bwRgn();
draw.fMatrix = &matrix;
- draw.fBounder = NULL;
paint.setAntiAlias(true);
paint.setStyle(style);
draw.drawPath(devPath, paint);
-
/*
* 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
struct SkDraw1Glyph {
const SkDraw* fDraw;
- SkBounder* fBounder;
const SkRegion* fClip;
const SkAAClip* fAAClip;
SkBlitter* fBlitter;
#include "SkMaskFilter.h"
#include "SkBlitter.h"
-#include "SkBounder.h"
#include "SkDraw.h"
#include "SkRasterClip.h"
#include "SkRRect.h"
}
}
-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);
}
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.
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) {
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;
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);
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;
#include "SkGrTexturePixelRef.h"
-#include "SkBounder.h"
#include "SkDeviceImageFilterProxy.h"
#include "SkDrawProcs.h"
#include "SkGlyphCache.h"
// clipped out
return;
}
- if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) {
- // nothing to draw
- return;
- }
if (paint.getMaskFilter()->directFilterRRectMaskGPU(fContext, &grPaint,
stroke, devRRect)) {
return;
}
#include "SkMaskFilter.h"
-#include "SkBounder.h"
///////////////////////////////////////////////////////////////////////////////
}
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;
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
// clipped out
return;
}
- if (NULL != draw.fBounder && !draw.fBounder->doIRect(finalIRect)) {
- // nothing to draw
- return;
- }
if (paint.getMaskFilter()->directFilterMaskGPU(fContext, &grPaint,
stroke, *devPathPtr)) {
// 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;
}
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);
}
}
-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()) {
fProxy->endCommentGroup();
}
-SkBounder* SkProxyCanvas::setBounder(SkBounder* bounder) {
- return fProxy->setBounder(bounder);
-}
-
SkDrawFilter* SkProxyCanvas::setDrawFilter(SkDrawFilter* filter) {
return fProxy->setDrawFilter(filter);
}
#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;
// 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
#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();
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());