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

Side by Side Diff: gm/imagemagnifier.cpp

Issue 407183003: add portable and canonical font support for DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add atexit; rename to create_... Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « gm/imagefiltersgraph.cpp ('k') | gm/imageresizetiled.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkMagnifierImageFilter.h" 9 #include "SkMagnifierImageFilter.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 26 matching lines...) Expand all
37 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 37 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
38 SkPaint paint; 38 SkPaint paint;
39 paint.setImageFilter( 39 paint.setImageFilter(
40 SkMagnifierImageFilter::Create( 40 SkMagnifierImageFilter::Create(
41 SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100), 41 SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100),
42 SkIntToScalar(WIDTH / 2), 42 SkIntToScalar(WIDTH / 2),
43 SkIntToScalar(HEIGHT / 2)), 43 SkIntToScalar(HEIGHT / 2)),
44 100))->unref(); 44 100))->unref();
45 canvas->saveLayer(NULL, &paint); 45 canvas->saveLayer(NULL, &paint);
46 paint.setAntiAlias(true); 46 paint.setAntiAlias(true);
47 sk_tool_utils::set_portable_typeface(&paint);
47 const char* str = "The quick brown fox jumped over the lazy dog."; 48 const char* str = "The quick brown fox jumped over the lazy dog.";
48 SkRandom rand; 49 SkRandom rand;
49 for (int i = 0; i < 25; ++i) { 50 for (int i = 0; i < 25; ++i) {
50 int x = rand.nextULessThan(WIDTH); 51 int x = rand.nextULessThan(WIDTH);
51 int y = rand.nextULessThan(HEIGHT); 52 int y = rand.nextULessThan(HEIGHT);
52 paint.setColor(rand.nextBits(24) | 0xFF000000); 53 paint.setColor(rand.nextBits(24) | 0xFF000000);
53 paint.setTextSize(rand.nextRangeScalar(0, 300)); 54 paint.setTextSize(rand.nextRangeScalar(0, 300));
54 canvas->drawText(str, strlen(str), SkIntToScalar(x), 55 canvas->drawText(str, strlen(str), SkIntToScalar(x),
55 SkIntToScalar(y), paint); 56 SkIntToScalar(y), paint);
56 } 57 }
57 canvas->restore(); 58 canvas->restore();
58 } 59 }
59 60
60 private: 61 private:
61 typedef GM INHERITED; 62 typedef GM INHERITED;
62 }; 63 };
63 64
64 ////////////////////////////////////////////////////////////////////////////// 65 //////////////////////////////////////////////////////////////////////////////
65 66
66 static GM* MyFactory(void*) { return new ImageMagnifierGM; } 67 static GM* MyFactory(void*) { return new ImageMagnifierGM; }
67 static GMRegistry reg(MyFactory); 68 static GMRegistry reg(MyFactory);
68 69
69 } 70 }
OLDNEW
« no previous file with comments | « gm/imagefiltersgraph.cpp ('k') | gm/imageresizetiled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698