зеркало из https://github.com/mozilla/moz-skia.git
Remove setLocalMatrix calls from picture shader GM.
This makes all --skr tests pass for me. Enabling it by default in DM. BUG=skia:2378 R=reed@google.com, mtklein@google.com, fmalita@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/260863007 git-svn-id: http://skia.googlecode.com/svn/trunk@14549 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
608d63735f
Коммит
74b8cb15e4
|
@ -4,7 +4,7 @@
|
|||
#include "SkCommandLineFlags.h"
|
||||
#include "SkRecording.h"
|
||||
|
||||
DEFINE_bool(skr, false, "If true, run SKR tests.");
|
||||
DEFINE_bool(skr, true, "If true, run SKR tests.");
|
||||
|
||||
namespace DM {
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include "SkPictureRecorder.h"
|
||||
#include "SkShader.h"
|
||||
|
||||
namespace skiagm {
|
||||
|
||||
static struct {
|
||||
SkShader::TileMode tmx;
|
||||
SkShader::TileMode tmy;
|
||||
|
@ -24,9 +22,8 @@ static struct {
|
|||
{ SkShader::kMirror_TileMode, SkShader::kRepeat_TileMode },
|
||||
};
|
||||
|
||||
class PictureShaderGM : public GM {
|
||||
class PictureShaderGM : public skiagm::GM {
|
||||
public:
|
||||
|
||||
PictureShaderGM(SkScalar tileSize, SkScalar sceneSize)
|
||||
: fTileSize(tileSize)
|
||||
, fSceneSize(sceneSize) {
|
||||
|
@ -37,24 +34,13 @@ public:
|
|||
SkScalarRoundToInt(tileSize),
|
||||
NULL, 0);
|
||||
this->drawTile(pictureCanvas);
|
||||
SkAutoTUnref<SkPicture> p(recorder.endRecording());
|
||||
fPicture.reset(recorder.endRecording());
|
||||
|
||||
// Build a reference bitmap.
|
||||
SkBitmap bm;
|
||||
bm.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
|
||||
bm.eraseColor(SK_ColorTRANSPARENT);
|
||||
SkCanvas bitmapCanvas(bm);
|
||||
fBitmap.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
|
||||
fBitmap.eraseColor(SK_ColorTRANSPARENT);
|
||||
SkCanvas bitmapCanvas(fBitmap);
|
||||
this->drawTile(&bitmapCanvas);
|
||||
|
||||
for (unsigned i = 0; i < SK_ARRAY_COUNT(kTileConfigs); ++i) {
|
||||
fPictureShaders[i].reset(SkShader::CreatePictureShader(p,
|
||||
kTileConfigs[i].tmx,
|
||||
kTileConfigs[i].tmy));
|
||||
|
||||
fBitmapShaders[i].reset(SkShader::CreateBitmapShader(bm,
|
||||
kTileConfigs[i].tmx,
|
||||
kTileConfigs[i].tmy));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -145,14 +131,22 @@ private:
|
|||
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
|
||||
canvas->drawRect(SkRect::MakeXYWH(fSceneSize * 1.1f, 0, fSceneSize, fSceneSize), paint);
|
||||
|
||||
fPictureShaders[tileMode]->setLocalMatrix(localMatrix);
|
||||
paint.setShader(fPictureShaders[tileMode].get());
|
||||
SkAutoTUnref<SkShader> pictureShader(SkShader::CreatePictureShader(
|
||||
fPicture,
|
||||
kTileConfigs[tileMode].tmx,
|
||||
kTileConfigs[tileMode].tmy,
|
||||
&localMatrix));
|
||||
paint.setShader(pictureShader.get());
|
||||
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
|
||||
|
||||
canvas->translate(fSceneSize * 1.1f, 0);
|
||||
|
||||
fBitmapShaders[tileMode]->setLocalMatrix(localMatrix);
|
||||
paint.setShader(fBitmapShaders[tileMode].get());
|
||||
SkAutoTUnref<SkShader> bitmapShader(SkShader::CreateBitmapShader(
|
||||
fBitmap,
|
||||
kTileConfigs[tileMode].tmx,
|
||||
kTileConfigs[tileMode].tmy,
|
||||
&localMatrix));
|
||||
paint.setShader(bitmapShader.get());
|
||||
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
|
||||
|
||||
canvas->restore();
|
||||
|
@ -161,11 +155,10 @@ private:
|
|||
SkScalar fTileSize;
|
||||
SkScalar fSceneSize;
|
||||
|
||||
SkAutoTUnref<SkShader> fPictureShaders[SK_ARRAY_COUNT(kTileConfigs)];
|
||||
SkAutoTUnref<SkShader> fBitmapShaders[SK_ARRAY_COUNT(kTileConfigs)];
|
||||
SkAutoTUnref<SkPicture> fPicture;
|
||||
SkBitmap fBitmap;
|
||||
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
||||
DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); )
|
||||
}
|
||||
|
|
|
@ -402,7 +402,8 @@ public:
|
|||
* @param tmy The tiling mode to use when sampling the bitmap in the y-direction.
|
||||
* @return Returns a new shader object. Note: this function never returns null.
|
||||
*/
|
||||
static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy);
|
||||
static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy,
|
||||
const SkMatrix* localMatrix = NULL);
|
||||
|
||||
SK_TO_STRING_VIRT()
|
||||
SK_DEFINE_FLATTENABLE_TYPE(SkShader)
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
#include "GrContext.h"
|
||||
#endif
|
||||
|
||||
SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy)
|
||||
: fPicture(SkRef(picture))
|
||||
SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy,
|
||||
const SkMatrix* localMatrix)
|
||||
: INHERITED(localMatrix)
|
||||
, fPicture(SkRef(picture))
|
||||
, fTmx(tmx)
|
||||
, fTmy(tmy) { }
|
||||
|
||||
|
@ -34,7 +36,8 @@ SkPictureShader::~SkPictureShader() {
|
|||
fPicture->unref();
|
||||
}
|
||||
|
||||
SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy) {
|
||||
SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy,
|
||||
const SkMatrix* localMatrix) {
|
||||
if (!picture || 0 == picture->width() || 0 == picture->height()) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -79,6 +82,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix) const {
|
|||
|
||||
SkAutoMutexAcquire ama(fCachedBitmapShaderMutex);
|
||||
|
||||
// TODO(fmalita): remove fCachedLocalMatrix from this key after getLocalMatrix is removed.
|
||||
if (!fCachedBitmapShader || tileScale != fCachedTileScale ||
|
||||
this->getLocalMatrix() != fCachedLocalMatrix) {
|
||||
SkBitmap bm;
|
||||
|
|
|
@ -21,7 +21,7 @@ class SkPicture;
|
|||
*/
|
||||
class SkPictureShader : public SkShader {
|
||||
public:
|
||||
static SkPictureShader* Create(SkPicture*, TileMode, TileMode);
|
||||
static SkPictureShader* Create(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
|
||||
virtual ~SkPictureShader();
|
||||
|
||||
virtual bool validContext(const ContextRec&, SkMatrix* totalInverse) const SK_OVERRIDE;
|
||||
|
@ -59,7 +59,7 @@ protected:
|
|||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkPictureShader(SkPicture*, TileMode, TileMode);
|
||||
SkPictureShader(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
|
||||
|
||||
SkShader* validInternal(const ContextRec&, SkMatrix* totalInverse) const;
|
||||
SkShader* refBitmapShader(const SkMatrix&) const;
|
||||
|
|
|
@ -193,8 +193,9 @@ SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo
|
|||
return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
|
||||
}
|
||||
|
||||
SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy) {
|
||||
return SkPictureShader::Create(src, tmx, tmy);
|
||||
SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy,
|
||||
const SkMatrix* localMatrix) {
|
||||
return SkPictureShader::Create(src, tmx, tmy, localMatrix);
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
|
|
Загрузка…
Ссылка в новой задаче