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

Unified Diff: gm/imageblur2.cpp

Issue 418223009: 2D kernel initial wiring for Guassian (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Small cleanups Created 6 years, 5 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
Index: gm/imageblur2.cpp
diff --git a/gm/imageblur2.cpp b/gm/imageblur2.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2c7294dc0e098270654796e8bcf2b6c0eda387d6
--- /dev/null
+++ b/gm/imageblur2.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2011 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 "SkBlurImageFilter.h"
+#include "SkRandom.h"
+
+// TODO deprecate imageblur
+
+#define WIDTH 500
+#define HEIGHT 500
+#include <stdio.h>
Stephen White 2014/07/25 20:43:17 Is this needed? If so, put it with the other #incl
+
+// TODO this surely exists somewhere
Stephen White 2014/07/25 20:43:17 Try SK_ARRAY_COUNT.
+#define LENGTH(x) (sizeof((x)) / sizeof((x)[0]))
+
+static const float kBlurSigmas[] = {
+ 0.0, 0.3f, 0.5f, 2.0f, 32.0f, 80.0f };
+
+const char* kTestStrings[] = {
+ "The quick`~",
+ "brown fox[]",
+ "jumped over",
+ "the lazy@#$",
+ "dog.{}!%^&",
+ "*()+=-\\'\"/",
+};
+
+namespace skiagm {
+
+class ImageBlur2GM : public GM {
Stephen White 2014/07/25 20:43:17 Let's call it BlurImageFilter (like the other imag
+public:
+ ImageBlur2GM() {
+ this->setBGColor(0xFFFFFFFF);
+ fName.printf("imageblur2");
+ }
+
+protected:
+ virtual uint32_t onGetFlags() const SK_OVERRIDE {
+ return kSkipTiled_Flag;
+ }
+
+ virtual SkString onShortName() {
+ return fName;
+ }
+
+ virtual SkISize onISize() {
+ return SkISize::Make(WIDTH, HEIGHT);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ const int sigmaCount = LENGTH(kBlurSigmas);
+ const int testStringCount = LENGTH(kTestStrings);
+ SkScalar dx = WIDTH / sigmaCount;
+ SkScalar dy = HEIGHT / sigmaCount;
+ const int textSize = 12;
+
+ for (int x = 0; x < sigmaCount; x++) {
+ SkScalar sigmaX = kBlurSigmas[x];
+ for (int y = 0; y < sigmaCount; y++) {
+ SkScalar sigmaY = kBlurSigmas[y];
+
+ SkPaint paint;
+ paint.setImageFilter(SkBlurImageFilter::Create(sigmaX, sigmaY))->unref();
+ canvas->saveLayer(NULL, &paint);
+
+ SkRandom rand;
+ SkPaint textPaint;
+ textPaint.setAntiAlias(true);
+ textPaint.setColor(rand.nextBits(24) | 0xFF000000);
+ textPaint.setTextSize(textSize);
+
+ for (int i = 0; i < testStringCount; i++) {
+ canvas->drawText(kTestStrings[i],
+ strlen(kTestStrings[i]),
+ SkIntToScalar(x * dx),
+ SkIntToScalar(y * dy + textSize * i + textSize),
+ textPaint);
+ }
+ canvas->restore();
+ }
+ }
+ }
+
+private:
+ SkString fName;
+
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static GM* MyFactory(void*) { return new ImageBlur2GM; }
+static GMRegistry reg(MyFactory);
+
+}

Powered by Google App Engine
This is Rietveld 408576698