зеркало из https://github.com/mozilla/moz-skia.git
Fix GrContext::drawPaint with perspective, also never apply AA
Review URL: http://codereview.appspot.com/4969074/ git-svn-id: http://skia.googlecode.com/svn/trunk@2247 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
383963280d
Коммит
4f83be8f86
|
@ -645,6 +645,7 @@ private:
|
|||
*/
|
||||
class GrAutoMatrix : GrNoncopyable {
|
||||
public:
|
||||
GrAutoMatrix() : fContext(NULL) {}
|
||||
GrAutoMatrix(GrContext* ctx) : fContext(ctx) {
|
||||
fMatrix = ctx->getMatrix();
|
||||
}
|
||||
|
@ -652,9 +653,26 @@ public:
|
|||
fMatrix = ctx->getMatrix();
|
||||
ctx->setMatrix(matrix);
|
||||
}
|
||||
~GrAutoMatrix() {
|
||||
void set(GrContext* ctx) {
|
||||
if (NULL != fContext) {
|
||||
fContext->setMatrix(fMatrix);
|
||||
}
|
||||
fMatrix = ctx->getMatrix();
|
||||
fContext = ctx;
|
||||
}
|
||||
void set(GrContext* ctx, const GrMatrix& matrix) {
|
||||
if (NULL != fContext) {
|
||||
fContext->setMatrix(fMatrix);
|
||||
}
|
||||
fMatrix = ctx->getMatrix();
|
||||
ctx->setMatrix(matrix);
|
||||
fContext = ctx;
|
||||
}
|
||||
~GrAutoMatrix() {
|
||||
if (NULL != fContext) {
|
||||
fContext->setMatrix(fMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GrContext* fContext;
|
||||
|
|
|
@ -590,13 +590,26 @@ void GrContext::drawPaint(const GrPaint& paint) {
|
|||
r.setLTRB(0, 0,
|
||||
GrIntToScalar(getRenderTarget()->width()),
|
||||
GrIntToScalar(getRenderTarget()->height()));
|
||||
GrAutoMatrix am;
|
||||
GrMatrix inverse;
|
||||
if (fGpu->getViewInverse(&inverse)) {
|
||||
// We attempt to map r by the inverse matrix and draw that. mapRect will
|
||||
// map the four corners and bound them with a new rect. This will not
|
||||
// produce a correct result for some perspective matrices.
|
||||
if (!this->getMatrix().hasPerspective() &&
|
||||
fGpu->getViewInverse(&inverse)) {
|
||||
inverse.mapRect(&r);
|
||||
} else {
|
||||
GrPrintf("---- fGpu->getViewInverse failed\n");
|
||||
am.set(this, GrMatrix::I());
|
||||
}
|
||||
this->drawRect(paint, r);
|
||||
GrPaint tmpPaint;
|
||||
const GrPaint* p = &paint;
|
||||
// by definition this fills the entire clip, no need for AA
|
||||
if (paint.fAntiAlias) {
|
||||
tmpPaint = paint;
|
||||
tmpPaint.fAntiAlias = false;
|
||||
p = &tmpPaint;
|
||||
}
|
||||
this->drawRect(*p, r);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче