Remove translate param from GrContext::drawPath (and subsequent calls).
Review URL: https://codereview.appspot.com/6615062 git-svn-id: http://skia.googlecode.com/svn/trunk@5852 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
a5b7cc00b9
commit
0f11e1ab5b
@ -328,6 +328,11 @@ public:
|
||||
*/
|
||||
void setMatrix(const GrMatrix& m);
|
||||
|
||||
/**
|
||||
* Sets the current transformation matrix to identity.
|
||||
*/
|
||||
void setIdentityMatrix();
|
||||
|
||||
/**
|
||||
* Concats the current matrix. The passed matrix is applied before the
|
||||
* current matrix.
|
||||
@ -414,8 +419,7 @@ public:
|
||||
* @param translate optional additional translation applied to the
|
||||
* path.
|
||||
*/
|
||||
void drawPath(const GrPaint& paint, const SkPath& path, GrPathFill fill,
|
||||
const GrPoint* translate = NULL);
|
||||
void drawPath(const GrPaint& paint, const SkPath& path, GrPathFill fill);
|
||||
|
||||
/**
|
||||
* Draws vertices with a paint.
|
||||
@ -845,8 +849,7 @@ private:
|
||||
/// draw state is left unmodified.
|
||||
GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw);
|
||||
|
||||
void internalDrawPath(const GrPaint& paint, const SkPath& path,
|
||||
GrPathFill fill, const GrPoint* translate);
|
||||
void internalDrawPath(const GrPaint& paint, const SkPath& path, GrPathFill fill);
|
||||
|
||||
GrTexture* createResizedTexture(const GrTextureDesc& desc,
|
||||
const GrCacheData& cacheData,
|
||||
|
@ -445,7 +445,6 @@ bool GrAAConvexPathRenderer::canDrawPath(const SkPath& path,
|
||||
|
||||
bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) {
|
||||
|
||||
@ -458,9 +457,6 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
|
||||
GrDrawState* drawState = target->drawState();
|
||||
|
||||
GrMatrix vm = drawState->getViewMatrix();
|
||||
if (NULL != translate) {
|
||||
vm.postTranslate(translate->fX, translate->fY);
|
||||
}
|
||||
if (!drawState->preConcatSamplerMatricesWithInverse(vm)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ public:
|
||||
protected:
|
||||
virtual bool onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) SK_OVERRIDE;
|
||||
};
|
||||
|
@ -197,7 +197,6 @@ int num_quad_subdivs(const SkPoint p[3]) {
|
||||
*/
|
||||
int generate_lines_and_quads(const SkPath& path,
|
||||
const SkMatrix& m,
|
||||
const SkVector& translate,
|
||||
const GrIRect& devClipBounds,
|
||||
PtArray* lines,
|
||||
PtArray* quads,
|
||||
@ -218,7 +217,6 @@ int generate_lines_and_quads(const SkPath& path,
|
||||
case kMove_PathCmd:
|
||||
break;
|
||||
case kLine_PathCmd:
|
||||
SkPoint::Offset(pts, 2, translate);
|
||||
m.mapPoints(devPts, pts, 2);
|
||||
bounds.setBounds(devPts, 2);
|
||||
bounds.outset(SK_Scalar1, SK_Scalar1);
|
||||
@ -230,7 +228,6 @@ int generate_lines_and_quads(const SkPath& path,
|
||||
}
|
||||
break;
|
||||
case kQuadratic_PathCmd:
|
||||
SkPoint::Offset(pts, 3, translate);
|
||||
m.mapPoints(devPts, pts, 3);
|
||||
bounds.setBounds(devPts, 3);
|
||||
bounds.outset(SK_Scalar1, SK_Scalar1);
|
||||
@ -257,7 +254,6 @@ int generate_lines_and_quads(const SkPath& path,
|
||||
}
|
||||
break;
|
||||
case kCubic_PathCmd:
|
||||
SkPoint::Offset(pts, 4, translate);
|
||||
m.mapPoints(devPts, pts, 4);
|
||||
bounds.setBounds(devPts, 4);
|
||||
bounds.outset(SK_Scalar1, SK_Scalar1);
|
||||
@ -503,7 +499,6 @@ void add_line(const SkPoint p[2],
|
||||
|
||||
bool GrAAHairLinePathRenderer::createGeom(
|
||||
const SkPath& path,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
int* lineCnt,
|
||||
int* quadCnt,
|
||||
@ -521,11 +516,7 @@ bool GrAAHairLinePathRenderer::createGeom(
|
||||
PREALLOC_PTARRAY(128) lines;
|
||||
PREALLOC_PTARRAY(128) quads;
|
||||
IntArray qSubdivs;
|
||||
static const GrVec gZeroVec = {0, 0};
|
||||
if (NULL == translate) {
|
||||
translate = &gZeroVec;
|
||||
}
|
||||
*quadCnt = generate_lines_and_quads(path, viewM, *translate, devClipBounds,
|
||||
*quadCnt = generate_lines_and_quads(path, viewM, devClipBounds,
|
||||
&lines, &quads, &qSubdivs);
|
||||
|
||||
*lineCnt = lines.count() / 2;
|
||||
@ -582,7 +573,6 @@ bool GrAAHairLinePathRenderer::canDrawPath(const SkPath& path,
|
||||
|
||||
bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) {
|
||||
|
||||
@ -590,7 +580,6 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
|
||||
int quadCnt;
|
||||
GrDrawTarget::AutoReleaseGeometry arg;
|
||||
if (!this->createGeom(path,
|
||||
translate,
|
||||
target,
|
||||
&lineCnt,
|
||||
&quadCnt,
|
||||
|
@ -25,7 +25,6 @@ public:
|
||||
protected:
|
||||
virtual bool onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) SK_OVERRIDE;
|
||||
|
||||
@ -36,7 +35,6 @@ private:
|
||||
const GrIndexBuffer* fQuadsIndexBuffer);
|
||||
|
||||
bool createGeom(const SkPath& path,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
int* lineCnt,
|
||||
int* quadCnt,
|
||||
|
@ -441,7 +441,7 @@ bool draw_path(GrContext* context,
|
||||
return draw_path_in_software(context, gpu, path, fill, doAA, resultBounds);
|
||||
}
|
||||
|
||||
pr->drawPath(path, fill, NULL, gpu, doAA);
|
||||
pr->drawPath(path, fill, gpu, doAA);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -857,7 +857,7 @@ bool GrClipMaskManager::createStencilClipMask(const GrClipData& clipDataIn,
|
||||
} else {
|
||||
if (canRenderDirectToStencil) {
|
||||
*drawState->stencil() = gDrawToStencil;
|
||||
pr->drawPath(*clipPath, fill, NULL, fGpu, false);
|
||||
pr->drawPath(*clipPath, fill, fGpu, false);
|
||||
} else {
|
||||
pr->drawPathToStencil(*clipPath, fill, fGpu);
|
||||
}
|
||||
@ -875,7 +875,7 @@ bool GrClipMaskManager::createStencilClipMask(const GrClipData& clipDataIn,
|
||||
fGpu->drawSimpleRect(*clip->fRect, NULL);
|
||||
} else {
|
||||
SET_RANDOM_COLOR
|
||||
pr->drawPath(*clipPath, fill, NULL, fGpu, false);
|
||||
pr->drawPath(*clipPath, fill, fGpu, false);
|
||||
}
|
||||
} else {
|
||||
SET_RANDOM_COLOR
|
||||
|
@ -1019,7 +1019,7 @@ void GrContext::drawOval(const GrPaint& paint,
|
||||
path.addOval(rect);
|
||||
GrPathFill fill = (strokeWidth == 0) ?
|
||||
kHairLine_GrPathFill : kWinding_GrPathFill;
|
||||
this->internalDrawPath(paint, path, fill, NULL);
|
||||
this->internalDrawPath(paint, path, fill);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1091,8 +1091,7 @@ void GrContext::drawOval(const GrPaint& paint,
|
||||
target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4);
|
||||
}
|
||||
|
||||
void GrContext::drawPath(const GrPaint& paint, const SkPath& path,
|
||||
GrPathFill fill, const GrPoint* translate) {
|
||||
void GrContext::drawPath(const GrPaint& paint, const SkPath& path, GrPathFill fill) {
|
||||
|
||||
if (path.isEmpty()) {
|
||||
if (GrIsFillInverted(fill)) {
|
||||
@ -1103,19 +1102,15 @@ void GrContext::drawPath(const GrPaint& paint, const SkPath& path,
|
||||
|
||||
SkRect ovalRect;
|
||||
if (!GrIsFillInverted(fill) && path.isOval(&ovalRect)) {
|
||||
if (translate) {
|
||||
ovalRect.offset(*translate);
|
||||
}
|
||||
SkScalar width = (fill == kHairLine_GrPathFill) ? 0 : -SK_Scalar1;
|
||||
this->drawOval(paint, ovalRect, width);
|
||||
return;
|
||||
}
|
||||
|
||||
internalDrawPath(paint, path, fill, translate);
|
||||
this->internalDrawPath(paint, path, fill);
|
||||
}
|
||||
|
||||
void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path,
|
||||
GrPathFill fill, const GrPoint* translate) {
|
||||
void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path, GrPathFill fill) {
|
||||
|
||||
// Note that below we may sw-rasterize the path into a scratch texture.
|
||||
// Scratch textures can be recycled after they are returned to the texture
|
||||
@ -1146,7 +1141,7 @@ void GrContext::internalDrawPath(const GrPaint& paint, const SkPath& path,
|
||||
return;
|
||||
}
|
||||
|
||||
pr->drawPath(path, fill, translate, target, prAA);
|
||||
pr->drawPath(path, fill, target, prAA);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1672,6 +1667,10 @@ void GrContext::setMatrix(const GrMatrix& m) {
|
||||
fDrawState->setViewMatrix(m);
|
||||
}
|
||||
|
||||
void GrContext::setIdentityMatrix() {
|
||||
fDrawState->viewMatrix()->reset();
|
||||
}
|
||||
|
||||
void GrContext::concatMatrix(const GrMatrix& m) const {
|
||||
fDrawState->preConcatViewMatrix(m);
|
||||
}
|
||||
|
@ -183,7 +183,6 @@ static inline void append_countour_edge_indices(GrPathFill fillType,
|
||||
|
||||
bool GrDefaultPathRenderer::createGeom(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrScalar srcSpaceTol,
|
||||
GrDrawTarget* target,
|
||||
GrPrimitiveType* primType,
|
||||
@ -312,20 +311,12 @@ FINISHED:
|
||||
*vertexCnt = vert - base;
|
||||
*indexCnt = idx - idxBase;
|
||||
|
||||
if (NULL != translate &&
|
||||
(translate->fX || translate->fY)) {
|
||||
int count = vert - base;
|
||||
for (int i = 0; i < count; i++) {
|
||||
base[i].offset(translate->fX, translate->fY);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GrDefaultPathRenderer::internalDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool stencilOnly) {
|
||||
|
||||
@ -339,7 +330,6 @@ bool GrDefaultPathRenderer::internalDrawPath(const SkPath& path,
|
||||
GrDrawTarget::AutoReleaseGeometry arg;
|
||||
if (!this->createGeom(path,
|
||||
fill,
|
||||
translate,
|
||||
tol,
|
||||
target,
|
||||
&primType,
|
||||
@ -481,9 +471,6 @@ bool GrDefaultPathRenderer::internalDrawPath(const SkPath& path,
|
||||
}
|
||||
} else {
|
||||
bounds = path.getBounds();
|
||||
if (NULL != translate) {
|
||||
bounds.offset(*translate);
|
||||
}
|
||||
}
|
||||
GrDrawTarget::AutoGeometryPush agp(target);
|
||||
target->drawSimpleRect(bounds, NULL);
|
||||
@ -514,12 +501,10 @@ bool GrDefaultPathRenderer::canDrawPath(const SkPath& path,
|
||||
|
||||
bool GrDefaultPathRenderer::onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) {
|
||||
return this->internalDrawPath(path,
|
||||
fill,
|
||||
translate,
|
||||
target,
|
||||
false);
|
||||
}
|
||||
@ -529,5 +514,5 @@ void GrDefaultPathRenderer::drawPathToStencil(const SkPath& path,
|
||||
GrDrawTarget* target) {
|
||||
GrAssert(kInverseEvenOdd_GrPathFill != fill);
|
||||
GrAssert(kInverseWinding_GrPathFill != fill);
|
||||
this->internalDrawPath(path, fill, NULL, target, true);
|
||||
this->internalDrawPath(path, fill, target, true);
|
||||
}
|
||||
|
@ -38,19 +38,16 @@ private:
|
||||
|
||||
virtual bool onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) SK_OVERRIDE;
|
||||
|
||||
bool internalDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool stencilOnly);
|
||||
|
||||
bool createGeom(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrScalar srcSpaceTol,
|
||||
GrDrawTarget* target,
|
||||
GrPrimitiveType* primType,
|
||||
|
@ -97,18 +97,15 @@ public:
|
||||
*
|
||||
* @param path the path to draw.
|
||||
* @param fill the path filling rule to use.
|
||||
* @param translate optional additional translation applied to
|
||||
* the path (can be NULL)
|
||||
* @param target target that the path will be rendered to
|
||||
* @param antiAlias true if anti-aliasing is required.
|
||||
*/
|
||||
virtual bool drawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) {
|
||||
GrAssert(this->canDrawPath(path, fill, target, antiAlias));
|
||||
return this->onDrawPath(path, fill, translate, target, antiAlias);
|
||||
return this->onDrawPath(path, fill, target, antiAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,14 +132,11 @@ protected:
|
||||
*
|
||||
* @param path the path to draw.
|
||||
* @param fill the path filling rule to use.
|
||||
* @param translate optional additional translation applied to
|
||||
* the path
|
||||
* @param target target that the path will be rendered to
|
||||
* @param antiAlias whether antialiasing is enabled or not.
|
||||
*/
|
||||
virtual bool onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) = 0;
|
||||
|
||||
|
@ -108,7 +108,6 @@ void draw_around_inv_path(GrDrawTarget* target,
|
||||
// return true on success; false on failure
|
||||
bool GrSoftwarePathRenderer::onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) {
|
||||
|
||||
@ -119,9 +118,6 @@ bool GrSoftwarePathRenderer::onDrawPath(const SkPath& path,
|
||||
GrDrawState* drawState = target->drawState();
|
||||
|
||||
GrMatrix vm = drawState->getViewMatrix();
|
||||
if (NULL != translate) {
|
||||
vm.postTranslate(translate->fX, translate->fY);
|
||||
}
|
||||
|
||||
GrIRect devPathBounds, devClipBounds;
|
||||
if (!get_path_and_clip_bounds(target, path, vm,
|
||||
|
@ -31,7 +31,6 @@ public:
|
||||
protected:
|
||||
virtual bool onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) SK_OVERRIDE;
|
||||
|
||||
|
@ -57,9 +57,8 @@ void GrStencilAndCoverPathRenderer::drawPathToStencil(const SkPath& path,
|
||||
|
||||
bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias){
|
||||
bool antiAlias) {
|
||||
GrAssert(!antiAlias);
|
||||
GrAssert(kHairLine_GrPathFill != fill);
|
||||
|
||||
@ -68,10 +67,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
|
||||
|
||||
SkAutoTUnref<GrPath> p(fGpu->createPath(path));
|
||||
GrDrawState::AutoViewMatrixRestore avmr;
|
||||
if (translate) {
|
||||
avmr.set(drawState);
|
||||
drawState->viewMatrix()->postTranslate(translate->fX, translate->fY);
|
||||
}
|
||||
|
||||
GrPathFill nonInvertedFill = GrNonInvertedFill(fill);
|
||||
target->stencilPath(p, nonInvertedFill);
|
||||
|
||||
@ -111,13 +107,11 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
|
||||
// theoretically could set bloat = 0, instead leave it because of matrix inversion
|
||||
// precision.
|
||||
} else {
|
||||
avmr.set(drawState);
|
||||
if (!drawState->preConcatSamplerMatricesWithInverse(drawState->getViewMatrix())) {
|
||||
GrPrintf("Could not invert matrix.\n");
|
||||
return false;
|
||||
}
|
||||
if (avmr.isSet()) {
|
||||
avmr.set(drawState);
|
||||
}
|
||||
drawState->viewMatrix()->reset();
|
||||
bloat = 0;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ public:
|
||||
protected:
|
||||
virtual bool onDrawPath(const SkPath& path,
|
||||
GrPathFill fill,
|
||||
const GrVec* translate,
|
||||
GrDrawTarget* target,
|
||||
bool antiAlias) SK_OVERRIDE;
|
||||
|
||||
|
@ -221,11 +221,12 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed,
|
||||
glyph->fPath = path;
|
||||
}
|
||||
|
||||
GrPoint translate;
|
||||
translate.set(GrFixedToScalar(vx - GrIntToFixed(glyph->fBounds.fLeft)),
|
||||
GrFixedToScalar(vy - GrIntToFixed(glyph->fBounds.fTop)));
|
||||
fContext->drawPath(fPaint, *glyph->fPath, kWinding_GrPathFill,
|
||||
&translate);
|
||||
GrContext::AutoMatrix am(fContext, GrContext::AutoMatrix::kPreserve_InitialMatrix);
|
||||
GrMatrix translate;
|
||||
translate.setTranslate(GrFixedToScalar(vx - GrIntToFixed(glyph->fBounds.fLeft)),
|
||||
GrFixedToScalar(vy - GrIntToFixed(glyph->fBounds.fTop)));
|
||||
fContext->concatMatrix(translate);
|
||||
fContext->drawPath(fPaint, *glyph->fPath, kWinding_GrPathFill);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -878,7 +878,8 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
|
||||
|
||||
SkAutoTUnref<GrTexture> blurTexture;
|
||||
|
||||
GrContext::AutoMatrix avm(context, GrMatrix::I());
|
||||
// We pass kPreserve here. We will replace the current matrix below.
|
||||
GrContext::AutoMatrix avm(context, GrContext::AutoMatrix::kPreserve_InitialMatrix);
|
||||
|
||||
{
|
||||
GrContext::AutoRenderTarget art(context, pathTexture->asRenderTarget());
|
||||
@ -897,8 +898,14 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
|
||||
// use a zero dst coeff when dual source blending isn't available.
|
||||
tempPaint.setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff);
|
||||
}
|
||||
// Draw hard shadow to pathTexture with path topleft at origin 0,0.
|
||||
context->drawPath(tempPaint, path, pathFillType, &offset);
|
||||
// Draw hard shadow to pathTexture with path top-left at origin 0,0.
|
||||
GrMatrix translate;
|
||||
translate.setTranslate(offset.fX, offset.fY);
|
||||
context->setMatrix(translate);
|
||||
context->drawPath(tempPaint, path, pathFillType);
|
||||
|
||||
// switch to device coord drawing when going back to the main RT.
|
||||
context->setIdentityMatrix();
|
||||
|
||||
// If we're doing a normal blur, we can clobber the pathTexture in the
|
||||
// gaussianBlur. Otherwise, we need to save it for later compositing.
|
||||
@ -910,7 +917,7 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
|
||||
GrPaint paint;
|
||||
paint.reset();
|
||||
paint.colorSampler(0)->matrix()->setIDiv(pathTexture->width(),
|
||||
pathTexture->height());
|
||||
pathTexture->height());
|
||||
// Blend pathTexture over blurTexture.
|
||||
context->setRenderTarget(blurTexture->asRenderTarget());
|
||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS
|
||||
|
Loading…
Reference in New Issue
Block a user