992c7b03ef
Allow GM results to be compared across machines and platforms by standardizing the fonts used by all tests. This adds runtime flags to DM to use either the system font context (the default), the fonts in the resources directory ( --resourceFonts ) or a set of canonical paths generated from the fonts ( --portableFonts ). This CL should leave the current DM results unchanged by default. If the portable font data or resource font is missing when DM is run, it falls back to using the system font context. The create_test_font tool generates the paths and metrics read by DM with the --portableFonts flag set, and generates the font substitution tables read by DM with the --resourceFonts flag set. If DM is run in SkDebug mode with the --reportUsedChars flag set, it generates the corresponding data compiled into the create_test_font tool. All GM tests set their typeface information by calling either sk_tool_utils::set_portable_typeface or sk_tool_utils::portable_typeface . (The former takes the paint, the latter returns a SkTypeface.) These calls can be removed in the future when the Font Manager can be superceded. BUG=skia:2687 R=mtklein@google.com Review URL: https://codereview.chromium.org/407183003
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
/*
|
|
* Copyright 2014 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"
|
|
|
|
#define WIDTH 640
|
|
#define HEIGHT 480
|
|
|
|
namespace skiagm {
|
|
|
|
class ImageBlurTiledGM : public GM {
|
|
public:
|
|
ImageBlurTiledGM(SkScalar sigmaX, SkScalar sigmaY)
|
|
: fSigmaX(sigmaX), fSigmaY(sigmaY) {
|
|
}
|
|
|
|
protected:
|
|
virtual SkString onShortName() {
|
|
return SkString("imageblurtiled");
|
|
}
|
|
|
|
virtual SkISize onISize() {
|
|
return SkISize::Make(WIDTH, HEIGHT);
|
|
}
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
SkPaint paint;
|
|
paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
|
|
const SkScalar tile_size = SkIntToScalar(128);
|
|
SkRect bounds;
|
|
if (!canvas->getClipBounds(&bounds)) {
|
|
bounds.setEmpty();
|
|
}
|
|
for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) {
|
|
for (SkScalar x = bounds.left(); x < bounds.right(); x += tile_size) {
|
|
canvas->save();
|
|
canvas->clipRect(SkRect::MakeXYWH(x, y, tile_size, tile_size));
|
|
canvas->saveLayer(NULL, &paint);
|
|
const char* str[] = {
|
|
"The quick",
|
|
"brown fox",
|
|
"jumped over",
|
|
"the lazy dog.",
|
|
};
|
|
SkPaint textPaint;
|
|
textPaint.setAntiAlias(true);
|
|
sk_tool_utils::set_portable_typeface(&textPaint);
|
|
textPaint.setTextSize(SkIntToScalar(100));
|
|
int posY = 0;
|
|
for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) {
|
|
posY += 100;
|
|
canvas->drawText(str[i], strlen(str[i]), SkIntToScalar(0),
|
|
SkIntToScalar(posY), textPaint);
|
|
}
|
|
canvas->restore();
|
|
canvas->restore();
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
SkScalar fSigmaX;
|
|
SkScalar fSigmaY;
|
|
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
static GM* MyFactory1(void*) { return new ImageBlurTiledGM(3.0f, 3.0f); }
|
|
static GMRegistry reg1(MyFactory1);
|
|
|
|
}
|