Reason for revert:
changed GM unexpectedly. will sort out and try again
Original issue's description:
> Remove setLocalMatrix calls from picture shader GM.
>
> This makes all --skr tests pass for me. Enabling it by default in DM.
>
> BUG=skia:2378
>
> Committed: http://code.google.com/p/skia/source/detail?r=14549
R=reed@google.com, fmalita@google.com, mtklein@chromium.org
TBR=fmalita@google.com, mtklein@chromium.org, reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2378
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/
265013003
git-svn-id: http://skia.googlecode.com/svn/trunk@14550
2bbb7eff-a529-9590-31e7-
b0007b416f81
#include "SkCommandLineFlags.h"
#include "SkRecording.h"
-DEFINE_bool(skr, true, "If true, run SKR tests.");
+DEFINE_bool(skr, false, "If true, run SKR tests.");
namespace DM {
#include "SkPictureRecorder.h"
#include "SkShader.h"
+namespace skiagm {
+
static struct {
SkShader::TileMode tmx;
SkShader::TileMode tmy;
{ SkShader::kMirror_TileMode, SkShader::kRepeat_TileMode },
};
-class PictureShaderGM : public skiagm::GM {
+class PictureShaderGM : public GM {
public:
+
PictureShaderGM(SkScalar tileSize, SkScalar sceneSize)
: fTileSize(tileSize)
, fSceneSize(sceneSize) {
SkScalarRoundToInt(tileSize),
NULL, 0);
this->drawTile(pictureCanvas);
- fPicture.reset(recorder.endRecording());
+ SkAutoTUnref<SkPicture> p(recorder.endRecording());
// Build a reference bitmap.
- fBitmap.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
- fBitmap.eraseColor(SK_ColorTRANSPARENT);
- SkCanvas bitmapCanvas(fBitmap);
+ SkBitmap bm;
+ bm.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileSize));
+ bm.eraseColor(SK_ColorTRANSPARENT);
+ SkCanvas bitmapCanvas(bm);
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:
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->drawRect(SkRect::MakeXYWH(fSceneSize * 1.1f, 0, fSceneSize, fSceneSize), paint);
- SkAutoTUnref<SkShader> pictureShader(SkShader::CreatePictureShader(
- fPicture,
- kTileConfigs[tileMode].tmx,
- kTileConfigs[tileMode].tmy,
- &localMatrix));
- paint.setShader(pictureShader.get());
+ fPictureShaders[tileMode]->setLocalMatrix(localMatrix);
+ paint.setShader(fPictureShaders[tileMode].get());
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->translate(fSceneSize * 1.1f, 0);
- SkAutoTUnref<SkShader> bitmapShader(SkShader::CreateBitmapShader(
- fBitmap,
- kTileConfigs[tileMode].tmx,
- kTileConfigs[tileMode].tmy,
- &localMatrix));
- paint.setShader(bitmapShader.get());
+ fBitmapShaders[tileMode]->setLocalMatrix(localMatrix);
+ paint.setShader(fBitmapShaders[tileMode].get());
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->restore();
SkScalar fTileSize;
SkScalar fSceneSize;
- SkAutoTUnref<SkPicture> fPicture;
- SkBitmap fBitmap;
+ SkAutoTUnref<SkShader> fPictureShaders[SK_ARRAY_COUNT(kTileConfigs)];
+ SkAutoTUnref<SkShader> fBitmapShaders[SK_ARRAY_COUNT(kTileConfigs)];
typedef GM INHERITED;
};
DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); )
+}
* @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,
- const SkMatrix* localMatrix = NULL);
+ static SkShader* CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy);
SK_TO_STRING_VIRT()
SK_DEFINE_FLATTENABLE_TYPE(SkShader)
#include "GrContext.h"
#endif
-SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix)
- : INHERITED(localMatrix)
- , fPicture(SkRef(picture))
+SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy)
+ : fPicture(SkRef(picture))
, fTmx(tmx)
, fTmy(tmy) { }
fPicture->unref();
}
-SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix) {
+SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileMode tmy) {
if (!picture || 0 == picture->width() || 0 == picture->height()) {
return NULL;
}
SkAutoMutexAcquire ama(fCachedBitmapShaderMutex);
- // TODO(fmalita): remove fCachedLocalMatrix from this key after getLocalMatrix is removed.
if (!fCachedBitmapShader || tileScale != fCachedTileScale ||
this->getLocalMatrix() != fCachedLocalMatrix) {
SkBitmap bm;
*/
class SkPictureShader : public SkShader {
public:
- static SkPictureShader* Create(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
+ static SkPictureShader* Create(SkPicture*, TileMode, TileMode);
virtual ~SkPictureShader();
virtual bool validContext(const ContextRec&, SkMatrix* totalInverse) const SK_OVERRIDE;
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
private:
- SkPictureShader(SkPicture*, TileMode, TileMode, const SkMatrix* = NULL);
+ SkPictureShader(SkPicture*, TileMode, TileMode);
SkShader* validInternal(const ContextRec&, SkMatrix* totalInverse) const;
SkShader* refBitmapShader(const SkMatrix&) const;
return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL);
}
-SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix) {
- return SkPictureShader::Create(src, tmx, tmy, localMatrix);
+SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode tmy) {
+ return SkPictureShader::Create(src, tmx, tmy);
}
#ifndef SK_IGNORE_TO_STRING