Chromium Code Reviews| Index: gm/picture.cpp |
| diff --git a/gm/picture.cpp b/gm/picture.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f16385f3127d149b75f837e7809bae84c248cfed |
| --- /dev/null |
| +++ b/gm/picture.cpp |
| @@ -0,0 +1,72 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "gm.h" |
| +#include "SkPaint.h" |
| +#include "SkPictureRecorder.h" |
| + |
| +static SkPicture* make_picture() { |
| + SkPictureRecorder rec; |
| + SkCanvas* canvas = rec.beginRecording(100, 100); |
| + |
| + SkPaint paint; |
| + paint.setAntiAlias(true); |
| + SkPath path; |
| + |
| + paint.setColor(0x800000FF); |
| + canvas->drawRect(SkRect::MakeWH(100, 100), paint); |
| + |
| + paint.setColor(0x80FF0000); |
| + path.moveTo(0, 0); path.lineTo(100, 0); path.lineTo(100, 100); |
| + canvas->drawPath(path, paint); |
| + |
| + paint.setColor(0x8000FF00); |
| + path.reset(); path.moveTo(0, 0); path.lineTo(100, 0); path.lineTo(0, 100); |
| + canvas->drawPath(path, paint); |
| + |
| + paint.setColor(0x80FFFFFF); |
| + paint.setXfermodeMode(SkXfermode::kPlus_Mode); |
| + canvas->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint); |
| + |
| + return rec.endRecording(); |
| +} |
| + |
|
robertphillips
2014/08/08 18:37:37
// Exercise the SkCanvas::drawPicture interface wi
reed1
2014/08/09 17:42:31
Done.
|
| +class PictureGM : public skiagm::GM { |
| + SkAutoTUnref<SkPicture> fPicture; |
| +public: |
| + PictureGM() : fPicture(make_picture()) {} |
| + |
| +protected: |
| + virtual SkString onShortName() SK_OVERRIDE { |
| + return SkString("pictures"); |
| + } |
| + |
| + virtual SkISize onISize() SK_OVERRIDE { |
|
robertphillips
2014/08/08 18:37:37
Does this need to be this large?
reed1
2014/08/09 17:42:31
Done.
|
| + return SkISize::Make(1024, 768); |
| + } |
| + |
| + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| + canvas->translate(10, 10); |
| + |
| + SkMatrix matrix; |
| + SkPaint paint; |
| + |
| + canvas->drawPicture(fPicture); |
| + |
| + matrix.setTranslate(110, 0); |
| + canvas->drawPicture(fPicture, &matrix, NULL); |
| + |
| + matrix.postTranslate(110, 0); |
| + canvas->drawPicture(fPicture, &matrix, &paint); |
| + |
| + paint.setAlpha(0x80); |
| + matrix.postTranslate(110, 0); |
| + canvas->drawPicture(fPicture, &matrix, &paint); |
| + } |
|
robertphillips
2014/08/08 18:37:37
private:
typedef skiagm::GM INHERITED;
?
reed1
2014/08/09 17:42:31
Done.
|
| +}; |
| + |
| +DEF_GM( return SkNEW(PictureGM); ) |