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

Unified Diff: gm/dashing.cpp

Issue 274673004: Add Dashing gpu effect for simple dashed lines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add missing files Created 6 years, 7 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 | « no previous file | gyp/gpu.gypi » ('j') | src/gpu/SkGpuDevice.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/dashing.cpp
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index 2f5be081597d55a940405b9c1fc5d323f1e68760..7102b44d44e837f83785c8f6ba8cf6cf31b7eaf1 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -313,10 +313,69 @@ protected:
//////////////////////////////////////////////////////////////////////////////
+class Dashing4GM : public skiagm::GM {
+public:
+ Dashing4GM() {}
+
+protected:
+ virtual uint32_t onGetFlags() const SK_OVERRIDE {
+ return kSkipTiled_Flag;
+ }
+
+ SkString onShortName() {
+ return SkString("dashing4");
+ }
+
+ SkISize onISize() { return skiagm::make_isize(640, 730); }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ static const struct {
+ int fOnInterval;
+ int fOffInterval;
+ } gData[] = {
+ { 1, 1 },
+ { 4, 2 },
+ { 0, 4 }, // test for zero length on interval
+ };
+
+ SkPaint paint;
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
+ canvas->translate(0, SK_ScalarHalf);
+
+ for (int width = 0; width <= 2; ++width) {
+ for (size_t data = 0; data < SK_ARRAY_COUNT(gData); ++data) {
+ for (int aa = 0; aa <= 1; ++aa) {
+ for (int cap = 0; cap <= 1; ++cap) {
+ int w = width * width * width;
+ paint.setAntiAlias(SkToBool(aa));
+ paint.setStrokeWidth(SkIntToScalar(w));
+
+ SkToBool(cap) ? paint.setStrokeCap(SkPaint::kSquare_Cap)
+ : paint.setStrokeCap(SkPaint::kRound_Cap);
+
+ int scale = w ? w : 1;
+
+ drawline(canvas, gData[data].fOnInterval * scale,
+ gData[data].fOffInterval * scale,
+ paint);
+ canvas->translate(0, SkIntToScalar(20));
+ }
+ }
+ }
+ }
+ }
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
static skiagm::GM* F0(void*) { return new DashingGM; }
static skiagm::GM* F1(void*) { return new Dashing2GM; }
static skiagm::GM* F2(void*) { return new Dashing3GM; }
+static skiagm::GM* F3(void*) { return new Dashing4GM; }
static skiagm::GMRegistry gR0(F0);
static skiagm::GMRegistry gR1(F1);
static skiagm::GMRegistry gR2(F2);
+static skiagm::GMRegistry gR3(F3);
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | src/gpu/SkGpuDevice.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698