Reason for revert:
broke gms

Original issue's description:
> hide get/setLocalMatrix
>
> BUG=skia:
>
> Committed: http://code.google.com/p/skia/source/detail?r=14675

R=fmalita@google.com, dominikg@chromium.org, fmalita@chromium.org
TBR=dominikg@chromium.org, fmalita@chromium.org, fmalita@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Author: reed@google.com

Review URL: https://codereview.chromium.org/278903002

git-svn-id: http://skia.googlecode.com/svn/trunk@14677 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-05-09 15:42:07 +00:00
parent 5d20caea15
commit d12de02542
6 changed files with 31 additions and 25 deletions

View File

@ -37,17 +37,16 @@ public:
SkShader(const SkMatrix* localMatrix = NULL);
virtual ~SkShader();
/**
* Returns the local matrix.
*/
const SkMatrix& getLocalMatrix() const { return fLocalMatrix; }
#ifdef SK_SUPPORT_LEGACY_SHADER_LOCALMATRIX
/**
* Returns true if the local matrix is not an identity matrix.
*/
bool hasLocalMatrix() const { return !fLocalMatrix.isIdentity(); }
/**
* Returns the local matrix.
*/
const SkMatrix& getLocalMatrix() const { return fLocalMatrix; }
/**
* Set the shader's local matrix.
* @param localM The shader's new local matrix.
@ -58,7 +57,6 @@ public:
* Reset the shader's local matrix to identity.
*/
void resetLocalMatrix() { fLocalMatrix.reset(); }
#endif
enum TileMode {
/** replicate the edge color if the shader draws outside of its

View File

@ -35,7 +35,7 @@ static void erase(SkSurface* surface) {
surface->getCanvas()->clear(SK_ColorTRANSPARENT);
}
static SkShader* createChecker(const SkMatrix& localMatrix) {
static SkShader* createChecker() {
// SkColor colors[] = { 0xFFFDFDFD, 0xFFF4F4F4 };
SkColor colors[] = { 0xFFFFFFFF, 0xFFFFFFFF };
SkBitmap bm;
@ -43,13 +43,15 @@ static SkShader* createChecker(const SkMatrix& localMatrix) {
bm.lockPixels();
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = SkPreMultiplyColor(colors[0]);
*bm.getAddr32(0, 1) = *bm.getAddr32(1, 0) = SkPreMultiplyColor(colors[1]);
SkMatrix m;
m.setScale(12, 12);
return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode, &localMatrix);
SkShader::kRepeat_TileMode, &m);
}
class FatBits {
public:
FatBits() {
FatBits() : fShader(createChecker()) {
fAA = false;
fStyle = kHair_Style;
fGrid = true;
@ -98,7 +100,7 @@ public:
fBounds.set(0, 0, SkIntToScalar(width * zoom), SkIntToScalar(height * zoom));
fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
fShader.reset(createChecker(fMatrix));
fShader->setLocalMatrix(fMatrix);
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
fMinSurface.reset(SkSurface::NewRaster(info));

View File

@ -56,7 +56,11 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
SkASSERT(fPicture && fPicture->width() > 0 && fPicture->height() > 0);
SkMatrix m;
m.setConcat(matrix, this->getLocalMatrix());
if (this->hasLocalMatrix()) {
m.setConcat(matrix, this->getLocalMatrix());
} else {
m = matrix;
}
if (localM) {
m.preConcat(*localM);
}

View File

@ -60,7 +60,7 @@ SkShader::~SkShader() {
void SkShader::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
bool hasLocalM = !fLocalMatrix.isIdentity();
bool hasLocalM = this->hasLocalMatrix();
buffer.writeBool(hasLocalM);
if (hasLocalM) {
buffer.writeMatrix(fLocalMatrix);
@ -68,10 +68,13 @@ void SkShader::flatten(SkWriteBuffer& buffer) const {
}
bool SkShader::computeTotalInverse(const ContextRec& rec, SkMatrix* totalInverse) const {
SkMatrix total;
total.setConcat(*rec.fMatrix, fLocalMatrix);
const SkMatrix* m = rec.fMatrix;
SkMatrix total;
const SkMatrix* m = &total;
if (this->hasLocalMatrix()) {
total.setConcat(*m, this->getLocalMatrix());
m = &total;
}
if (rec.fLocalMatrix) {
total.setConcat(*m, *rec.fLocalMatrix);
m = &total;
@ -232,9 +235,9 @@ SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t
#ifndef SK_IGNORE_TO_STRING
void SkShader::toString(SkString* str) const {
if (!fLocalMatrix.isIdentity()) {
if (this->hasLocalMatrix()) {
str->append(" ");
fLocalMatrix.toString(str);
this->getLocalMatrix().toString(str);
}
}
#endif

View File

@ -66,15 +66,13 @@ bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
return false;
}
SkCanvas canvas(device.get());
SkPaint paint;
paint.setShader(fShader);
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref();
fShader->setLocalMatrix(matrix);
SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
canvas.drawRect(rect, paint);
*result = device.get()->accessBitmap(false);
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;

View File

@ -6,6 +6,7 @@
*/
#include "SkPDFDeviceFlattener.h"
#include "SkDraw.h"
static SkISize SkSizeToISize(const SkSize& size) {
@ -24,9 +25,9 @@ SkPDFDeviceFlattener::~SkPDFDeviceFlattener() {
static void flattenPaint(const SkDraw& d, SkPaint* paint) {
if (paint->getShader()) {
SkAutoTUnref<SkShader> lms(SkShader::CreateLocalMatrixShader(paint->getShader(),
*d.fMatrix));
paint->setShader(lms);
SkMatrix local = paint->getShader()->getLocalMatrix();
local.preConcat(*d.fMatrix);
paint->getShader()->setLocalMatrix(local);
}
}