2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
12 #include "SkSurface.h"
14 static SkImage* make_image() {
15 const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52);
16 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
17 SkCanvas* canvas = surface->getCanvas();
18 canvas->drawColor(0xFFF8F8F8);
21 paint.setAntiAlias(true);
23 paint.setStyle(SkPaint::kStroke_Style);
24 for (int i = 0; i < 20; ++i) {
25 canvas->drawCircle(-4, 25, 20, paint);
26 canvas->translate(25, 0);
28 return surface->newImageSnapshot();
31 static void test_mip(SkCanvas* canvas) {
32 SkAutoTUnref<SkImage> img(make_image());//SkImage::NewFromData(data));
35 const SkRect dst = SkRect::MakeWH(177, 15);
37 paint.setTextSize(30);
39 str.printf("scale %g %g", dst.width() / img->width(), dst.height() / img->height());
40 // canvas->drawText(str.c_str(), str.size(), 300, 100, paint);
42 canvas->translate(20, 20);
43 for (int i = 0; i < 4; ++i) {
44 paint.setFilterQuality(SkFilterQuality(i));
45 canvas->drawImageRect(img, NULL, dst, &paint);
46 canvas->translate(0, 20);
48 canvas->drawImage(img, 20, 20, NULL);
51 class MipMapGM : public skiagm::GM {
56 SkString onShortName() SK_OVERRIDE { return SkString("mipmap"); }
58 SkISize onISize() SK_OVERRIDE { return SkISize::Make(400, 200); }
60 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
65 typedef skiagm::GM INHERITED;
67 DEF_GM( return new MipMapGM; )