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

Side by Side Diff: gm/bitmapsource.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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/bitmapscroll.cpp ('k') | gm/bleed.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 2013 Google Inc. 2 * Copyright 2013 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 9
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
11 11
12 // This GM exercises the SkBitmapSource ImageFilter class. 12 // This GM exercises the SkBitmapSource ImageFilter class.
13 13
14 class BitmapSourceGM : public skiagm::GM { 14 class BitmapSourceGM : public skiagm::GM {
15 public: 15 public:
16 BitmapSourceGM() { 16 BitmapSourceGM() {
17 } 17 }
18 18
19 protected: 19 protected:
20 virtual SkString onShortName() SK_OVERRIDE { 20 SkString onShortName() SK_OVERRIDE {
21 return SkString("bitmapsource"); 21 return SkString("bitmapsource");
22 } 22 }
23 23
24 void makeBitmap() { 24 void makeBitmap() {
25 fBitmap.allocN32Pixels(100, 100); 25 fBitmap.allocN32Pixels(100, 100);
26 SkCanvas canvas(fBitmap); 26 SkCanvas canvas(fBitmap);
27 canvas.clear(0x00000000); 27 canvas.clear(0x00000000);
28 SkPaint paint; 28 SkPaint paint;
29 paint.setAntiAlias(true); 29 paint.setAntiAlias(true);
30 sk_tool_utils::set_portable_typeface(&paint); 30 sk_tool_utils::set_portable_typeface(&paint);
31 paint.setColor(0xFFFFFFFF); 31 paint.setColor(0xFFFFFFFF);
32 paint.setTextSize(SkIntToScalar(96)); 32 paint.setTextSize(SkIntToScalar(96));
33 const char* str = "e"; 33 const char* str = "e";
34 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint); 34 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
35 } 35 }
36 36
37 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(500, 150); } 37 SkISize onISize() SK_OVERRIDE { return SkISize::Make(500, 150); }
38 38
39 virtual void onOnceBeforeDraw() SK_OVERRIDE { 39 void onOnceBeforeDraw() SK_OVERRIDE {
40 this->makeBitmap(); 40 this->makeBitmap();
41 } 41 }
42 42
43 static void fillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkIma geFilter* filter) { 43 static void fillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkIma geFilter* filter) {
44 SkPaint paint; 44 SkPaint paint;
45 paint.setImageFilter(filter); 45 paint.setImageFilter(filter);
46 canvas->save(); 46 canvas->save();
47 canvas->clipRect(clipRect); 47 canvas->clipRect(clipRect);
48 canvas->drawPaint(paint); 48 canvas->drawPaint(paint);
49 canvas->restore(); 49 canvas->restore();
50 } 50 }
51 51
52 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 52 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
53 canvas->clear(0x00000000); 53 canvas->clear(0x00000000);
54 { 54 {
55 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30); 55 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
56 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60); 56 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60);
57 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100); 57 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100);
58 SkRect bounds; 58 SkRect bounds;
59 fBitmap.getBounds(&bounds); 59 fBitmap.getBounds(&bounds);
60 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit map)); 60 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit map));
61 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(SkBitmapSource::Crea te(fBitmap, srcRect, srcRect)); 61 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(SkBitmapSource::Crea te(fBitmap, srcRect, srcRect));
62 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(SkBitmapSourc e::Create(fBitmap, srcRect, dstRect)); 62 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(SkBitmapSourc e::Create(fBitmap, srcRect, dstRect));
(...skipping 18 matching lines...) Expand all
81 } 81 }
82 82
83 private: 83 private:
84 SkBitmap fBitmap; 84 SkBitmap fBitmap;
85 typedef GM INHERITED; 85 typedef GM INHERITED;
86 }; 86 };
87 87
88 /////////////////////////////////////////////////////////////////////////////// 88 ///////////////////////////////////////////////////////////////////////////////
89 89
90 DEF_GM( return new BitmapSourceGM; ) 90 DEF_GM( return new BitmapSourceGM; )
OLDNEW
« no previous file with comments | « gm/bitmapscroll.cpp ('k') | gm/bleed.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698