#endif
////////////////////////////////////////////////////////////////////////////////////////////////////
+struct SkDraw1Glyph {
+ const SkDraw* fDraw;
+ const SkRegion* fClip;
+ const SkAAClip* fAAClip;
+ SkBlitter* fBlitter;
+ SkGlyphCache* fCache;
+ const SkPaint* fPaint;
+ SkIRect fClipBounds;
+ /** Half the sampling frequency of the rasterized glyph in x. */
+ SkScalar fHalfSampleX;
+ /** Half the sampling frequency of the rasterized glyph in y. */
+ SkScalar fHalfSampleY;
+
+ /** Draws one glyph.
+ *
+ * The x and y are pre-biased, so implementations may just truncate them.
+ * i.e. half the sampling frequency has been added.
+ * e.g. 1/2 or 1/(2^(SkGlyph::kSubBits+1)) has already been added.
+ * This added bias can be found in fHalfSampleX,Y.
+ */
+ typedef void (*Proc)(const SkDraw1Glyph&, Sk48Dot16 x, Sk48Dot16 y, const SkGlyph&);
+
+ Proc init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache,
+ const SkPaint&);
+
+ // call this instead of fBlitter->blitMask() since this wrapper will handle
+ // the case when the mask is ARGB32_Format
+ //
+ void blitMask(const SkMask& mask, const SkIRect& clip) const {
+ if (SkMask::kARGB32_Format == mask.fFormat) {
+ this->blitMaskAsSprite(mask);
+ } else {
+ fBlitter->blitMask(mask, clip);
+ }
+ }
-static void D1G_RectClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy, const SkGlyph& glyph) {
+ // mask must be kARGB32_Format
+ void blitMaskAsSprite(const SkMask& mask) const;
+};
+
+static void D1G_RectClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy,
+ const SkGlyph& glyph) {
// Prevent glyphs from being drawn outside of or straddling the edge of device space.
if ((fx >> 16) > INT_MAX - (INT16_MAX + UINT16_MAX) ||
(fx >> 16) < INT_MIN - (INT16_MIN + 0 /*UINT16_MIN*/) ||
state.blitMask(mask, *bounds);
}
-static void D1G_RgnClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy, const SkGlyph& glyph) {
+static void D1G_RgnClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy,
+ const SkGlyph& glyph) {
int left = Sk48Dot16FloorToInt(fx);
int top = Sk48Dot16FloorToInt(fy);
SkASSERT(glyph.fWidth > 0 && glyph.fHeight > 0);
}
}
-static bool hasCustomD1GProc(const SkDraw& draw) {
- return draw.fProcs && draw.fProcs->fD1GProc;
-}
-
-static bool needsRasterTextBlit(const SkDraw& draw) {
- return !hasCustomD1GProc(draw);
-}
-
SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache,
const SkPaint& pnt) {
fDraw = draw;
fHalfSampleX = fHalfSampleY = SK_ScalarHalf;
}
- if (hasCustomD1GProc(*draw)) {
- // todo: fix this assumption about clips w/ custom
- fClip = draw->fClip;
- fClipBounds = fClip->getBounds();
- return draw->fProcs->fD1GProc;
- }
-
if (draw->fRC->isBW()) {
fAAClip = nullptr;
fClip = &draw->fRC->bwRgn();
SkAutoGlyphCache autoCache(paint, &fDevice->surfaceProps(), fMatrix);
SkGlyphCache* cache = autoCache.getCache();
- SkAAClipBlitter aaBlitter;
- SkAutoBlitterChoose blitterChooser;
- SkBlitter* blitter = nullptr;
- if (needsRasterTextBlit(*this)) {
- blitterChooser.choose(fDst, *fMatrix, paint);
- blitter = blitterChooser.get();
- if (fRC->isAA()) {
- aaBlitter.init(blitter, &fRC->aaRgn());
- blitter = &aaBlitter;
- }
- }
+
+ // The Blitter Choose needs to be live while using the blitter below.
+ SkAutoBlitterChoose blitterChooser(fDst, *fMatrix, paint);
+ SkAAClipBlitterWrapper wrapper(*fRC, blitterChooser.get());
SkDraw1Glyph d1g;
- SkDraw1Glyph::Proc proc = d1g.init(this, blitter, cache, paint);
+ SkDraw1Glyph::Proc proc = d1g.init(this, wrapper.getBlitter(), cache, paint);
SkFindAndPlaceGlyph::ProcessText(
paint.getTextEncoding(), text, byteLength,
}
// The Blitter Choose needs to be live while using the blitter below.
- SkAutoBlitterChoose blitterChooser;
- SkAAClipBlitterWrapper wrapper;
- SkBlitter* blitter = nullptr;
- if (needsRasterTextBlit(*this)) {
- blitterChooser.choose(fDst, *fMatrix, paint);
- blitter = blitterChooser.get();
- if (fRC->isAA()) {
- wrapper.init(*fRC, blitter);
- blitter = wrapper.getBlitter();
- }
- }
+ SkAutoBlitterChoose blitterChooser(fDst, *fMatrix, paint);
+ SkAAClipBlitterWrapper wrapper(*fRC, blitterChooser.get());
SkAutoGlyphCache autoCache(paint, &fDevice->surfaceProps(), fMatrix);
SkGlyphCache* cache = autoCache.getCache();
SkDraw1Glyph d1g;
- SkDraw1Glyph::Proc proc = d1g.init(this, blitter, cache, paint);
+ SkDraw1Glyph::Proc proc = d1g.init(this, wrapper.getBlitter(), cache, paint);
SkPaint::Align textAlignment = paint.getTextAlign();
SkFindAndPlaceGlyph::ProcessPosText(
#ifndef SkDrawProcs_DEFINED
#define SkDrawProcs_DEFINED
-#include "SkBlitter.h"
#include "SkDraw.h"
#include "SkGlyph.h"
-class SkAAClip;
-class SkBlitter;
-
-struct SkDraw1Glyph {
- const SkDraw* fDraw;
- const SkRegion* fClip;
- const SkAAClip* fAAClip;
- SkBlitter* fBlitter;
- SkGlyphCache* fCache;
- const SkPaint* fPaint;
- SkIRect fClipBounds;
- /** Half the sampling frequency of the rasterized glyph in x. */
- SkScalar fHalfSampleX;
- /** Half the sampling frequency of the rasterized glyph in y. */
- SkScalar fHalfSampleY;
-
- /** Draws one glyph.
- *
- * The x and y are pre-biased, so implementations may just truncate them.
- * i.e. half the sampling frequency has been added.
- * e.g. 1/2 or 1/(2^(SkGlyph::kSubBits+1)) has already been added.
- * This added bias can be found in fHalfSampleX,Y.
- */
- typedef void (*Proc)(const SkDraw1Glyph&, Sk48Dot16 x, Sk48Dot16 y, const SkGlyph&);
-
- Proc init(const SkDraw* draw, SkBlitter* blitter, SkGlyphCache* cache,
- const SkPaint&);
-
- // call this instead of fBlitter->blitMask() since this wrapper will handle
- // the case when the mask is ARGB32_Format
- //
- void blitMask(const SkMask& mask, const SkIRect& clip) const {
- if (SkMask::kARGB32_Format == mask.fFormat) {
- this->blitMaskAsSprite(mask);
- } else {
- fBlitter->blitMask(mask, clip);
- }
- }
-
- // mask must be kARGB32_Format
- void blitMaskAsSprite(const SkMask& mask) const;
-};
-
-struct SkDrawProcs {
- SkDraw1Glyph::Proc fD1GProc;
-};
-
bool SkDrawTreatAAStrokeAsHairline(SkScalar strokeWidth, const SkMatrix&,
SkScalar* coverage);
#include "GrBlurUtils.h"
#include "GrContext.h"
+#include "SkDraw.h"
#include "GrDrawContext.h"
#include "GrFontScaler.h"
#include "GrGpu.h"
#include "GrTextContext.h"
#include "GrTracing.h"
#include "SkCanvasPriv.h"
-#include "SkDrawProcs.h"
#include "SkErrorInternals.h"
#include "SkGlyphCache.h"
#include "SkGrTexturePixelRef.h"
///////////////////////////////////////////////////////////////////////////////
-struct GrSkDrawProcs : public SkDrawProcs {
-public:
- GrContext* fContext;
- GrTextContext* fTextContext;
- GrFontScaler* fFontScaler; // cached in the skia glyphcache
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
/** Checks that the alpha type is legal and gets constructor flags. Returns false if device creation
should fail. */
bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
const SkSurfaceProps* props, unsigned flags)
: INHERITED(SkSurfacePropsCopyOrDefault(props))
{
- fDrawProcs = nullptr;
-
fContext = SkRef(rt->getContext());
fNeedClear = SkToBool(flags & kNeedClear_Flag);
fOpaque = SkToBool(flags & kIsOpaque_Flag);
}
SkGpuDevice::~SkGpuDevice() {
- if (fDrawProcs) {
- delete fDrawProcs;
- }
-
fRenderTarget->unref();
fContext->unref();
}
if (count == 2) {
// We do not antialias as long as the primary axis of the line is integer-aligned, even if
// the other coordinates are not. This does mean the two end pixels of the line will be
- // sharp even when they shouldn't be, but turning antialiasing on (as things stand
+ // sharp even when they shouldn't be, but turning antialiasing on (as things stand
// currently) means that the line will turn into a two-pixel-wide blur. While obviously a
- // more complete fix is possible down the road, for the time being we accept the error on
+ // more complete fix is possible down the road, for the time being we accept the error on
// the two end pixels as being the lesser of two evils.
if (pts[0].fX == pts[1].fX) {
return ((int) pts[0].fX) != pts[0].fX;
// we only handle non-antialiased hairlines and paints without path effects or mask filters,
// else we let the SkDraw call our drawPath()
- if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() ||
+ if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() ||
(paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) {
draw.drawPoints(mode, count, pts, paint, true);
return;
path.addOval(oval);
this->drawPath(draw, path, paint, nullptr, true);
return;
- }
-
+ }
+
if (paint.getMaskFilter()) {
// The RRect path can handle special case blurring
SkRRect rr = SkRRect::MakeOval(oval);
CHECK_SHOULD_DRAW(draw);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
-
+
SkPaint p(paint);
p.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode))->unref();