Reduce internal explicit SaveFlags usage.
Most of these are either redundant/defaults or (hopefully) unnecessarily specific. R=reed@google.com, robertphillips@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/241453003 git-svn-id: http://skia.googlecode.com/svn/trunk@14253 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
60bd7519a9
commit
091a594dbc
@ -83,7 +83,7 @@ protected:
|
||||
rect.setXYWH(0, 0, 10, 10);
|
||||
SkPaint paint;
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
|
||||
canvas->save();
|
||||
canvas->translate(SkIntToScalar(i * 27 % CANVAS_WIDTH), SkIntToScalar(i * 13 % CANVAS_HEIGHT));
|
||||
canvas->drawRect(rect, paint);
|
||||
canvas->restore();
|
||||
|
@ -112,7 +112,7 @@ class XfermodesGM : public GM {
|
||||
break;
|
||||
}
|
||||
case kRectangleWithMask_SrcType: {
|
||||
canvas->save(SkCanvas::kClip_SaveFlag);
|
||||
canvas->save();
|
||||
restoreNeeded = true;
|
||||
SkScalar w = SkIntToScalar(W);
|
||||
SkScalar h = SkIntToScalar(H);
|
||||
@ -247,7 +247,7 @@ protected:
|
||||
p.setShader(s);
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
|
||||
canvas->saveLayer(&r, NULL);
|
||||
draw_mode(canvas, mode, static_cast<SrcType>(sourceType),
|
||||
r.fLeft, r.fTop);
|
||||
canvas->restore();
|
||||
|
@ -54,7 +54,7 @@ protected:
|
||||
SkRect r = SkRect::MakeWH(w, h);
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
|
||||
canvas->saveLayer(&r, NULL);
|
||||
|
||||
p.setShader(fDst);
|
||||
canvas->drawRect(r, p);
|
||||
|
@ -152,7 +152,7 @@ private:
|
||||
|
||||
SkCanvas* modeCanvas;
|
||||
if (NULL == layerCanvas) {
|
||||
canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
|
||||
canvas->saveLayer(&r, NULL);
|
||||
modeCanvas = canvas;
|
||||
} else {
|
||||
modeCanvas = layerCanvas;
|
||||
|
@ -57,7 +57,7 @@ protected:
|
||||
virtual void onDrawContent(SkCanvas* canvas) {
|
||||
SkRect r;
|
||||
r.set(SkIntToScalar(20), SkIntToScalar(20), SkIntToScalar(120), SkIntToScalar(120));
|
||||
canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
|
||||
canvas->saveLayer(&r, NULL);
|
||||
canvas->drawColor(SK_ColorRED);
|
||||
drawMask(canvas, r);
|
||||
canvas->restore();
|
||||
|
@ -69,11 +69,11 @@ static void test_fade(SkCanvas* canvas) {
|
||||
canvas->clipRect(r);
|
||||
|
||||
r.fBottom = SkIntToScalar(20);
|
||||
canvas->saveLayer(&r, NULL, (SkCanvas::SaveFlags)(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag));
|
||||
canvas->saveLayer(&r, NULL);
|
||||
|
||||
r.fTop = SkIntToScalar(80);
|
||||
r.fBottom = SkIntToScalar(100);
|
||||
canvas->saveLayer(&r, NULL, (SkCanvas::SaveFlags)(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag));
|
||||
canvas->saveLayer(&r, NULL);
|
||||
|
||||
// now draw the "content"
|
||||
|
||||
@ -203,7 +203,7 @@ protected:
|
||||
r.set(SkIntToScalar(0), SkIntToScalar(0),
|
||||
SkIntToScalar(220), SkIntToScalar(60));
|
||||
|
||||
canvas->saveLayer(&r, &p, (SkCanvas::SaveFlags)(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag));
|
||||
canvas->saveLayer(&r, &p);
|
||||
|
||||
r.set(SkIntToScalar(0), SkIntToScalar(0),
|
||||
SkIntToScalar(220), SkIntToScalar(120));
|
||||
|
@ -180,7 +180,7 @@ protected:
|
||||
p.setShader(s);
|
||||
canvas->drawRect(r, p);
|
||||
|
||||
canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
|
||||
canvas->saveLayer(&r, NULL);
|
||||
draw_mode(canvas, mode, twice ? 0x88 : 0xFF, r.fLeft, r.fTop);
|
||||
canvas->restore();
|
||||
|
||||
|
@ -41,10 +41,10 @@ bool SkSaveLayer::draw(SkAnimateMaker& maker)
|
||||
{
|
||||
SkPaint realPaint;
|
||||
paint->setupPaint(&realPaint);
|
||||
maker.fCanvas->saveLayer(&bounds->fRect, &realPaint, SkCanvas::kHasAlphaLayer_SaveFlag);
|
||||
maker.fCanvas->saveLayer(&bounds->fRect, &realPaint);
|
||||
}
|
||||
else
|
||||
maker.fCanvas->saveLayer(&bounds->fRect, save, SkCanvas::kHasAlphaLayer_SaveFlag);
|
||||
maker.fCanvas->saveLayer(&bounds->fRect, save);
|
||||
SkPaint local = SkPaint(*maker.fPaint);
|
||||
maker.fPaint = &local;
|
||||
bool result = INHERITED::draw(maker);
|
||||
|
@ -1631,12 +1631,13 @@ void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio
|
||||
SkIRect deviceIBounds;
|
||||
this->getDevice()->getGlobalBounds(&deviceIBounds);
|
||||
deviceBounds = SkRect::Make(deviceIBounds);
|
||||
this->SkCanvas::save(SkCanvas::kMatrix_SaveFlag);
|
||||
|
||||
// set the clip in device space
|
||||
SkMatrix savedMatrix = this->getTotalMatrix();
|
||||
this->SkCanvas::setMatrix(SkMatrix::I());
|
||||
this->SkCanvas::onClipRect(deviceBounds, SkRegion::kReplace_Op,
|
||||
kHard_ClipEdgeStyle);
|
||||
this->SkCanvas::restore(); //pop the matrix, but keep the clip
|
||||
this->setMatrix(savedMatrix);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -770,7 +770,7 @@ void SkPictureRecord::beginRecording() {
|
||||
// we have to call this *after* our constructor, to ensure that it gets
|
||||
// recorded. This is balanced by restoreToCount() call from endRecording,
|
||||
// which in-turn calls our overridden restore(), so those get recorded too.
|
||||
fInitialSaveCount = this->save(kMatrixClip_SaveFlag);
|
||||
fInitialSaveCount = this->save();
|
||||
}
|
||||
|
||||
void SkPictureRecord::endRecording() {
|
||||
|
@ -124,7 +124,7 @@ uint32_t SkPictureStateTree::Iterator::draw() {
|
||||
Node* targetNode = draw->fNode;
|
||||
|
||||
if (fSave) {
|
||||
fCanvas->save(SkCanvas::kClip_SaveFlag);
|
||||
fCanvas->save();
|
||||
fSave = false;
|
||||
}
|
||||
|
||||
@ -162,6 +162,9 @@ uint32_t SkPictureStateTree::Iterator::draw() {
|
||||
fCanvas->restore();
|
||||
}
|
||||
if (targetNode != ancestor) {
|
||||
// FIXME: the save below depends on soon-to-be-deprecated
|
||||
// SaveFlags behavior: it relies on matrix changes persisting
|
||||
// after restore.
|
||||
fCanvas->save(SkCanvas::kClip_SaveFlag);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ SkLayerDrawLooper::~SkLayerDrawLooper() {
|
||||
}
|
||||
|
||||
SkLayerDrawLooper::Context* SkLayerDrawLooper::createContext(SkCanvas* canvas, void* storage) const {
|
||||
canvas->save(SkCanvas::kMatrix_SaveFlag);
|
||||
canvas->save();
|
||||
return SkNEW_PLACEMENT_ARGS(storage, LayerDrawLooperContext, (this));
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ bool SkLayerDrawLooper::LayerDrawLooperContext::next(SkCanvas* canvas,
|
||||
|
||||
ApplyInfo(paint, fCurrRec->fPaint, fCurrRec->fInfo);
|
||||
|
||||
canvas->save(SkCanvas::kMatrix_SaveFlag);
|
||||
canvas->save();
|
||||
if (fCurrRec->fInfo.fPostTranslate) {
|
||||
postTranslate(canvas, fCurrRec->fInfo.fOffset.fX,
|
||||
fCurrRec->fInfo.fOffset.fY);
|
||||
|
@ -290,20 +290,20 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
|
||||
REPORTER_ASSERT(reporter, canvas->isFreshFrame());
|
||||
|
||||
// Verify that clear with saved state triggers a fresh frame
|
||||
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
|
||||
canvas->save();
|
||||
canvas->clear(0x00000000);
|
||||
canvas->restore();
|
||||
REPORTER_ASSERT(reporter, canvas->isFreshFrame());
|
||||
|
||||
// Verify that clear within a layer does NOT trigger a fresh frame
|
||||
canvas->saveLayer(NULL, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
|
||||
canvas->saveLayer(NULL, NULL);
|
||||
canvas->clear(0x00000000);
|
||||
canvas->restore();
|
||||
REPORTER_ASSERT(reporter, !canvas->isFreshFrame());
|
||||
|
||||
// Verify that a clear with clipping triggers a fresh frame
|
||||
// (clear is not affected by clipping)
|
||||
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
|
||||
canvas->save();
|
||||
canvas->clipRect(partialRect, SkRegion::kIntersect_Op, false);
|
||||
canvas->clear(0x00000000);
|
||||
canvas->restore();
|
||||
@ -389,7 +389,7 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
|
||||
// Verify that incomplete coverage due to clipping does not trigger a fresh
|
||||
// frame
|
||||
{
|
||||
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
|
||||
canvas->save();
|
||||
canvas->clipRect(partialRect, SkRegion::kIntersect_Op, false);
|
||||
SkPaint paint;
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
@ -399,7 +399,7 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
|
||||
REPORTER_ASSERT(reporter, !canvas->isFreshFrame());
|
||||
}
|
||||
{
|
||||
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
|
||||
canvas->save();
|
||||
SkPaint paint;
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
paint.setAlpha(255);
|
||||
|
@ -285,9 +285,7 @@ DEF_TEST(ImageFilterMatrixTest, reporter) {
|
||||
SkAutoTUnref<MatrixTestImageFilter> imageFilter(
|
||||
new MatrixTestImageFilter(reporter, expectedMatrix));
|
||||
paint.setImageFilter(imageFilter.get());
|
||||
SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>(
|
||||
SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag);
|
||||
recordingCanvas->saveLayer(NULL, &paint, saveFlags);
|
||||
recordingCanvas->saveLayer(NULL, &paint);
|
||||
SkPaint solidPaint;
|
||||
solidPaint.setColor(0xFFFFFFFF);
|
||||
recordingCanvas->save();
|
||||
|
Loading…
Reference in New Issue
Block a user