OLD | NEW |
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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SkColorFilterImageFilter.h" | 9 #include "SkColorFilterImageFilter.h" |
10 #include "SkColorMatrixFilter.h" | 10 #include "SkColorMatrixFilter.h" |
11 #include "SkImage.h" | 11 #include "SkImage.h" |
12 #include "SkImageSource.h" | 12 #include "SkImageSource.h" |
13 #include "SkTileImageFilter.h" | 13 #include "SkTileImageFilter.h" |
14 #include "gm.h" | 14 #include "gm.h" |
15 | 15 |
16 #define WIDTH 400 | 16 #define WIDTH 400 |
17 #define HEIGHT 100 | 17 #define HEIGHT 200 |
18 #define MARGIN 12 | 18 #define MARGIN 12 |
19 | 19 |
20 namespace skiagm { | 20 namespace skiagm { |
21 | 21 |
22 class TileImageFilterGM : public GM { | 22 class TileImageFilterGM : public GM { |
23 public: | 23 public: |
24 TileImageFilterGM() { | 24 TileImageFilterGM() { |
25 this->setBGColor(0xFF000000); | 25 this->setBGColor(0xFF000000); |
26 } | 26 } |
27 | 27 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 paint.setImageFilter(cfif); | 100 paint.setImageFilter(cfif); |
101 canvas->save(); | 101 canvas->save(); |
102 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 102 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |
103 canvas->clipRect(dstRect); | 103 canvas->clipRect(dstRect); |
104 canvas->saveLayer(&dstRect, &paint); | 104 canvas->saveLayer(&dstRect, &paint); |
105 canvas->drawImage(fBitmap.get(), 0, 0); | 105 canvas->drawImage(fBitmap.get(), 0, 0); |
106 canvas->restore(); | 106 canvas->restore(); |
107 canvas->drawRect(srcRect, red); | 107 canvas->drawRect(srcRect, red); |
108 canvas->drawRect(dstRect, blue); | 108 canvas->drawRect(dstRect, blue); |
109 canvas->restore(); | 109 canvas->restore(); |
| 110 |
| 111 canvas->translate(0, SkIntToScalar(100)); |
| 112 |
| 113 srcRect = SkRect::MakeXYWH(0, 0, 50, 50); |
| 114 dstRect = SkRect::MakeXYWH(0, 0, 100, 100); |
| 115 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(5, 5, 40, 40)); |
| 116 sk_sp<SkColorFilter> greenCF = SkColorFilter::MakeModeFilter(SK_ColorGRE
EN, |
| 117 SkXfermode:
:kSrc_Mode); |
| 118 SkAutoTUnref<SkImageFilter> green(SkColorFilterImageFilter::Create(green
CF.get(), nullptr, |
| 119 &crop
Rect)); |
| 120 tile.reset(SkTileImageFilter::Create(srcRect, dstRect, green)); |
| 121 paint.setColor(SK_ColorRED); |
| 122 paint.setImageFilter(tile); |
| 123 canvas->drawRect(dstRect, paint); |
110 } | 124 } |
111 private: | 125 private: |
112 sk_sp<SkImage> fBitmap, fCheckerboard; | 126 sk_sp<SkImage> fBitmap, fCheckerboard; |
113 | 127 |
114 typedef GM INHERITED; | 128 typedef GM INHERITED; |
115 }; | 129 }; |
116 | 130 |
117 ////////////////////////////////////////////////////////////////////////////// | 131 ////////////////////////////////////////////////////////////////////////////// |
118 | 132 |
119 DEF_GM(return new TileImageFilterGM;) | 133 DEF_GM(return new TileImageFilterGM;) |
120 } | 134 } |
OLD | NEW |