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

Unified Diff: gm/mipmap.cpp

Issue 942593002: gm to illustrate mipmap layer choice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/mipmap.cpp
diff --git a/gm/mipmap.cpp b/gm/mipmap.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..948fd99dedb8d69ee05bf2d84e70d0214e0bdcc4
--- /dev/null
+++ b/gm/mipmap.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2015 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 "SkCanvas.h"
+#include "SkImage.h"
+#include "SkRandom.h"
+#include "SkSurface.h"
+
+static SkImage* make_image() {
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52);
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ SkCanvas* canvas = surface->getCanvas();
+ canvas->drawColor(0xFFF8F8F8);
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+
+ paint.setStyle(SkPaint::kStroke_Style);
+ for (int i = 0; i < 20; ++i) {
+ canvas->drawCircle(-4, 25, 20, paint);
+ canvas->translate(25, 0);
+ }
+ return surface->newImageSnapshot();
+}
+
+static void test_mip(SkCanvas* canvas) {
+ SkAutoTUnref<SkImage> img(make_image());//SkImage::NewFromData(data));
+
+ SkPaint paint;
+ const SkRect dst = SkRect::MakeWH(177, 15);
+
+ paint.setTextSize(30);
+ SkString str;
+ str.printf("scale %g %g", dst.width() / img->width(), dst.height() / img->height());
+// canvas->drawText(str.c_str(), str.size(), 300, 100, paint);
+
+ canvas->translate(20, 20);
+ for (int i = 0; i < 4; ++i) {
+ paint.setFilterLevel(SkPaint::FilterLevel(i));
+ canvas->drawImageRect(img, NULL, dst, &paint);
+ canvas->translate(0, 20);
+ }
+ canvas->drawImage(img, 20, 20, NULL);
+}
+
+class MipMapGM : public skiagm::GM {
+public:
+ MipMapGM() {}
+
+protected:
+ SkString onShortName() SK_OVERRIDE { return SkString("mipmap"); }
+
+ SkISize onISize() SK_OVERRIDE { return SkISize::Make(400, 200); }
+
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ test_mip(canvas);
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new MipMapGM; )
+
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698