2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "sk_tool_utils.h"
10 #include "SkImageFilter.h"
16 #define RESIZE_FACTOR SkIntToScalar(2)
18 DEF_SIMPLE_GM(imageresizetiled, canvas, WIDTH, HEIGHT) {
21 matrix.setScale(RESIZE_FACTOR, RESIZE_FACTOR);
22 paint.setImageFilter(SkImageFilter::MakeMatrixFilter(matrix,
23 kNone_SkFilterQuality,
25 const SkScalar tile_size = SkIntToScalar(100);
26 for (SkScalar y = 0; y < HEIGHT; y += tile_size) {
27 for (SkScalar x = 0; x < WIDTH; x += tile_size) {
29 canvas->clipRect(SkRect::MakeXYWH(x, y, tile_size, tile_size));
30 canvas->scale(SkScalarInvert(RESIZE_FACTOR),
31 SkScalarInvert(RESIZE_FACTOR));
32 canvas->saveLayer(nullptr, &paint);
40 textPaint.setAntiAlias(true);
41 sk_tool_utils::set_portable_typeface(&textPaint);
42 textPaint.setTextSize(SkIntToScalar(100));
44 for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) {
46 canvas->drawString(str[i], SkIntToScalar(0),
47 SkIntToScalar(posY), textPaint);