2015-02-19 19:39:46 +00:00
|
|
|
/*
|
|
|
|
* 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();
|
2015-07-29 12:27:47 +00:00
|
|
|
canvas->drawColor(sk_tool_utils::color_to_565(0xFFF8F8F8));
|
2015-02-19 19:39:46 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2015-09-09 15:16:41 +00:00
|
|
|
DEF_SIMPLE_GM(mipmap, canvas, 400, 200) {
|
2015-07-09 18:47:36 +00:00
|
|
|
SkAutoTUnref<SkImage> img(make_image());//SkImage::NewFromEncoded(data));
|
2015-02-19 19:39:46 +00:00
|
|
|
|
|
|
|
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) {
|
2015-03-16 17:08:34 +00:00
|
|
|
paint.setFilterQuality(SkFilterQuality(i));
|
2015-08-06 17:02:53 +00:00
|
|
|
canvas->drawImageRect(img, dst, &paint);
|
2015-02-19 19:39:46 +00:00
|
|
|
canvas->translate(0, 20);
|
|
|
|
}
|
2015-08-27 14:41:13 +00:00
|
|
|
canvas->drawImage(img, 20, 20, nullptr);
|
2015-02-19 19:39:46 +00:00
|
|
|
}
|
|
|
|
|