Remove SkDrawProcs
TBR=reed@google.com Review URL: https://codereview.chromium.org/1476563002
This commit is contained in:
parent
ff2103200b
commit
11a7f7f599
@ -147,7 +147,6 @@ public:
|
||||
|
||||
const SkClipStack* fClipStack; // optional
|
||||
SkBaseDevice* fDevice; // optional
|
||||
SkDrawProcs* fProcs; // optional
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void validate() const;
|
||||
|
@ -1423,8 +1423,48 @@ void SkDraw::drawText_asPaths(const char text[], size_t byteLength,
|
||||
#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;
|
||||
|
||||
static void D1G_RectClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy, const SkGlyph& glyph) {
|
||||
/** 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;
|
||||
};
|
||||
|
||||
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*/) ||
|
||||
@ -1474,7 +1514,8 @@ static void D1G_RectClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy,
|
||||
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);
|
||||
@ -1505,14 +1546,6 @@ static void D1G_RgnClip(const SkDraw1Glyph& state, Sk48Dot16 fx, Sk48Dot16 fy, c
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -1526,13 +1559,6 @@ SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter, Sk
|
||||
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();
|
||||
@ -1583,20 +1609,13 @@ void SkDraw::drawText(const char text[], size_t byteLength,
|
||||
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,
|
||||
@ -1678,22 +1697,13 @@ void SkDraw::drawPosText(const char text[], size_t 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(
|
||||
|
@ -8,57 +8,9 @@
|
||||
#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);
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "SkConstexprMath.h"
|
||||
#include "SkData.h"
|
||||
#include "SkDraw.h"
|
||||
#include "SkDrawProcs.h"
|
||||
#include "SkEndian.h"
|
||||
#include "SkFindAndPlaceGlyph.h"
|
||||
#include "SkGeometry.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "GrBlurUtils.h"
|
||||
#include "GrContext.h"
|
||||
#include "SkDraw.h"
|
||||
#include "GrDrawContext.h"
|
||||
#include "GrFontScaler.h"
|
||||
#include "GrGpu.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "GrTextContext.h"
|
||||
#include "GrTracing.h"
|
||||
#include "SkCanvasPriv.h"
|
||||
#include "SkDrawProcs.h"
|
||||
#include "SkErrorInternals.h"
|
||||
#include "SkGlyphCache.h"
|
||||
#include "SkGrTexturePixelRef.h"
|
||||
@ -113,15 +113,6 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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(
|
||||
@ -181,8 +172,6 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
|
||||
const SkSurfaceProps* props, unsigned flags)
|
||||
: INHERITED(SkSurfacePropsCopyOrDefault(props))
|
||||
{
|
||||
fDrawProcs = nullptr;
|
||||
|
||||
fContext = SkRef(rt->getContext());
|
||||
fNeedClear = SkToBool(flags & kNeedClear_Flag);
|
||||
fOpaque = SkToBool(flags & kIsOpaque_Flag);
|
||||
@ -238,10 +227,6 @@ GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B
|
||||
}
|
||||
|
||||
SkGpuDevice::~SkGpuDevice() {
|
||||
if (fDrawProcs) {
|
||||
delete fDrawProcs;
|
||||
}
|
||||
|
||||
fRenderTarget->unref();
|
||||
fContext->unref();
|
||||
}
|
||||
@ -404,9 +389,9 @@ static bool needs_antialiasing(SkCanvas::PointMode mode, size_t count, const SkP
|
||||
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;
|
||||
@ -444,7 +429,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
|
||||
|
||||
// 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;
|
||||
@ -625,8 +610,8 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
|
||||
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);
|
||||
@ -1688,7 +1673,7 @@ void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS
|
||||
|
||||
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();
|
||||
|
||||
|
@ -18,9 +18,6 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrSurfacePriv.h"
|
||||
|
||||
struct SkDrawProcs;
|
||||
struct GrSkDrawProcs;
|
||||
|
||||
class GrAccelData;
|
||||
class GrTextureProducer;
|
||||
struct GrCachedLayer;
|
||||
@ -154,7 +151,6 @@ protected:
|
||||
|
||||
private:
|
||||
GrContext* fContext;
|
||||
GrSkDrawProcs* fDrawProcs;
|
||||
SkAutoTUnref<const SkClipStack> fClipStack;
|
||||
SkIPoint fClipOrigin;
|
||||
GrClip fClip;
|
||||
|
Loading…
Reference in New Issue
Block a user