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

Side by Side Diff: gm/imagemagnifier.cpp

Issue 1864843002: Update MagnifierImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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
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"
11 11
12 #define WIDTH 500 12 #define WIDTH 500
13 #define HEIGHT 500 13 #define HEIGHT 500
14 14
15 DEF_SIMPLE_GM_BG(imagemagnifier, canvas, WIDTH, HEIGHT, SK_ColorBLACK) { 15 DEF_SIMPLE_GM_BG(imagemagnifier, canvas, WIDTH, HEIGHT, SK_ColorBLACK) {
16 SkPaint filterPaint; 16 SkPaint filterPaint;
17 filterPaint.setImageFilter( 17 filterPaint.setImageFilter(
18 SkMagnifierImageFilter::Create( 18 SkMagnifierImageFilter::Make(
19 SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100), 19 SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100),
20 SkIntToScalar(WIDTH / 2), 20 SkIntToScalar(WIDTH / 2),
21 SkIntToScalar(HEIGHT / 2)), 21 SkIntToScalar(HEIGHT / 2)),
22 100))->unref(); 22 100, nullptr));
23 canvas->saveLayer(nullptr, &filterPaint); 23 canvas->saveLayer(nullptr, &filterPaint);
24 const char* str = "The quick brown fox jumped over the lazy dog."; 24 const char* str = "The quick brown fox jumped over the lazy dog.";
25 SkRandom rand; 25 SkRandom rand;
26 for (int i = 0; i < 25; ++i) { 26 for (int i = 0; i < 25; ++i) {
27 int x = rand.nextULessThan(WIDTH); 27 int x = rand.nextULessThan(WIDTH);
28 int y = rand.nextULessThan(HEIGHT); 28 int y = rand.nextULessThan(HEIGHT);
29 SkPaint paint; 29 SkPaint paint;
30 sk_tool_utils::set_portable_typeface(&paint); 30 sk_tool_utils::set_portable_typeface(&paint);
31 paint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF0 00000)); 31 paint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF0 00000));
32 paint.setTextSize(rand.nextRangeScalar(0, 300)); 32 paint.setTextSize(rand.nextRangeScalar(0, 300));
33 paint.setAntiAlias(true); 33 paint.setAntiAlias(true);
34 canvas->drawText(str, strlen(str), SkIntToScalar(x), 34 canvas->drawText(str, strlen(str), SkIntToScalar(x),
35 SkIntToScalar(y), paint); 35 SkIntToScalar(y), paint);
36 } 36 }
37 canvas->restore(); 37 canvas->restore();
38 } 38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698