Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: gm/picture.cpp

Issue 448793004: add drawPicture variant that takes a matrix and paint (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more dummies so we can land Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/PdfViewer/SkNulCanvas.h ('k') | gyp/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/picture.cpp
diff --git a/gm/picture.cpp b/gm/picture.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1f7e5c38c9f9ab37b56dc73839707af80bc24b84
--- /dev/null
+++ b/gm/picture.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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();
+}
+
+// Exercise the optional arguments to drawPicture
+//
+class PictureGM : public skiagm::GM {
+public:
+ PictureGM() : fPicture(make_picture()) {}
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("pictures");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(450, 120);
+ }
+
+ 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);
+ }
+
+private:
+ SkAutoTUnref<SkPicture> fPicture;
+
+ typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return SkNEW(PictureGM); )
« no previous file with comments | « experimental/PdfViewer/SkNulCanvas.h ('k') | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698