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

Side by Side Diff: gm/arithmode.cpp

Issue 1514503004: SkBitmap move (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-10 (Thursday) 17:55:13 EST Created 5 years 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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkShader.h" 11 #include "SkShader.h"
12 12
13 #include "SkArithmeticMode.h" 13 #include "SkArithmeticMode.h"
14 #include "SkGradientShader.h" 14 #include "SkGradientShader.h"
15 #define WW 100 15 #define WW 100
16 #define HH 32 16 #define HH 32
17 17
18 static SkBitmap make_bm() { 18 static SkBitmap make_bm() {
19 SkBitmap bm; 19 SkBitmap bm;
20 bm.allocN32Pixels(WW, HH); 20 bm.allocN32Pixels(WW, HH);
21 bm.eraseColor(SK_ColorTRANSPARENT); 21 bm.eraseColor(SK_ColorTRANSPARENT);
22 return bm; 22 return skstd::move(bm);
23 } 23 }
24 24
25 static SkBitmap make_src() { 25 static SkBitmap make_src() {
26 SkBitmap bm = make_bm(); 26 SkBitmap bm = make_bm();
27 SkCanvas canvas(bm); 27 SkCanvas canvas(bm);
28 SkPaint paint; 28 SkPaint paint;
29 SkPoint pts[] = { {0, 0}, {SkIntToScalar(WW), SkIntToScalar(HH)} }; 29 SkPoint pts[] = { {0, 0}, {SkIntToScalar(WW), SkIntToScalar(HH)} };
30 SkColor colors[] = { 30 SkColor colors[] = {
31 SK_ColorTRANSPARENT, SK_ColorGREEN, SK_ColorCYAN, 31 SK_ColorTRANSPARENT, SK_ColorGREEN, SK_ColorCYAN,
32 SK_ColorRED, SK_ColorMAGENTA, SK_ColorWHITE, 32 SK_ColorRED, SK_ColorMAGENTA, SK_ColorWHITE,
33 }; 33 };
34 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_ COUNT(colors), 34 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_ COUNT(colors),
35 SkShader::kClamp_TileMode); 35 SkShader::kClamp_TileMode);
36 paint.setShader(s)->unref(); 36 paint.setShader(s)->unref();
37 canvas.drawPaint(paint); 37 canvas.drawPaint(paint);
38 return bm; 38 return skstd::move(bm);
39 } 39 }
40 40
41 static SkBitmap make_dst() { 41 static SkBitmap make_dst() {
42 SkBitmap bm = make_bm(); 42 SkBitmap bm = make_bm();
43 SkCanvas canvas(bm); 43 SkCanvas canvas(bm);
44 SkPaint paint; 44 SkPaint paint;
45 SkPoint pts[] = { {0, SkIntToScalar(HH)}, {SkIntToScalar(WW), 0} }; 45 SkPoint pts[] = { {0, SkIntToScalar(HH)}, {SkIntToScalar(WW), 0} };
46 SkColor colors[] = { 46 SkColor colors[] = {
47 SK_ColorBLUE, SK_ColorYELLOW, SK_ColorBLACK, SK_ColorGREEN, 47 SK_ColorBLUE, SK_ColorYELLOW, SK_ColorBLACK, SK_ColorGREEN,
48 sk_tool_utils::color_to_565(SK_ColorGRAY) 48 sk_tool_utils::color_to_565(SK_ColorGRAY)
49 }; 49 };
50 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_ COUNT(colors), 50 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_ COUNT(colors),
51 SkShader::kClamp_TileMode); 51 SkShader::kClamp_TileMode);
52 paint.setShader(s)->unref(); 52 paint.setShader(s)->unref();
53 canvas.drawPaint(paint); 53 canvas.drawPaint(paint);
54 return bm; 54 return skstd::move(bm);
55 } 55 }
56 56
57 static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar k[]) { 57 static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar k[]) {
58 SkPaint paint; 58 SkPaint paint;
59 paint.setTextSize(SkIntToScalar(24)); 59 paint.setTextSize(SkIntToScalar(24));
60 paint.setAntiAlias(true); 60 paint.setAntiAlias(true);
61 sk_tool_utils::set_portable_typeface(&paint); 61 sk_tool_utils::set_portable_typeface(&paint);
62 for (int i = 0; i < 4; ++i) { 62 for (int i = 0; i < 4; ++i) {
63 SkString str; 63 SkString str;
64 str.appendScalar(k[i]); 64 str.appendScalar(k[i]);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 } 159 }
160 160
161 private: 161 private:
162 typedef GM INHERITED; 162 typedef GM INHERITED;
163 }; 163 };
164 164
165 /////////////////////////////////////////////////////////////////////////////// 165 ///////////////////////////////////////////////////////////////////////////////
166 166
167 DEF_GM( return new ArithmodeGM; ) 167 DEF_GM( return new ArithmodeGM; )
OLDNEW
« no previous file with comments | « gm/all_bitmap_configs.cpp ('k') | gm/bitmappremul.cpp » ('j') | src/core/SkBitmap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698