| 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 "gm.h" |    8 #include "gm.h" | 
|    9 #include "sk_tool_utils.h" |    9 #include "sk_tool_utils.h" | 
|   10 #include "SkArithmeticMode.h" |   10 #include "SkArithmeticMode.h" | 
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  176             y += fBitmap.height() + MARGIN; |  176             y += fBitmap.height() + MARGIN; | 
|  177         } |  177         } | 
|  178         // Test small fg, large bg with Screen (uses shader blend) |  178         // Test small fg, large bg with Screen (uses shader blend) | 
|  179         paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropp
     ed, nullptr)); |  179         paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropp
     ed, nullptr)); | 
|  180         DrawClippedPaint(canvas, clipRect, paint, x, y); |  180         DrawClippedPaint(canvas, clipRect, paint, x, y); | 
|  181         x += fBitmap.width() + MARGIN; |  181         x += fBitmap.width() + MARGIN; | 
|  182         if (x + fBitmap.width() > WIDTH) { |  182         if (x + fBitmap.width() > WIDTH) { | 
|  183             x = 0; |  183             x = 0; | 
|  184             y += fBitmap.height() + MARGIN; |  184             y += fBitmap.height() + MARGIN; | 
|  185         } |  185         } | 
 |  186         // Test small fg, large bg with SrcIn with a crop that forces it to full
      size. | 
 |  187         // This tests that SkXfermodeImageFilter correctly applies the compositi
     ng mode to | 
 |  188         // the region outside the foreground. | 
 |  189         mode = SkXfermode::Make(SkXfermode::kSrcIn_Mode); | 
 |  190         SkImageFilter::CropRect cropRectFull(SkRect::MakeXYWH(0, 0, 80, 80)); | 
 |  191         paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropp
     ed, &cropRectFull)); | 
 |  192         DrawClippedPaint(canvas, clipRect, paint, x, y); | 
 |  193         x += fBitmap.width() + MARGIN; | 
 |  194         if (x + fBitmap.width() > WIDTH) { | 
 |  195             x = 0; | 
 |  196             y += fBitmap.height() + MARGIN; | 
 |  197         } | 
|  186     } |  198     } | 
|  187  |  199  | 
|  188 private: |  200 private: | 
|  189     static void DrawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, cons
     t SkPaint& paint, |  201     static void DrawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, cons
     t SkPaint& paint, | 
|  190                            int x, int y) { |  202                            int x, int y) { | 
|  191         canvas->save(); |  203         canvas->save(); | 
|  192         canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); |  204         canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); | 
|  193         canvas->clipRect(SkRect::MakeWH( |  205         canvas->clipRect(SkRect::MakeWH( | 
|  194             SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); |  206             SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); | 
|  195         canvas->drawBitmap(bitmap, 0, 0, &paint); |  207         canvas->drawBitmap(bitmap, 0, 0, &paint); | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  209     sk_sp<SkImage>  fCheckerboard; |  221     sk_sp<SkImage>  fCheckerboard; | 
|  210  |  222  | 
|  211     typedef GM INHERITED; |  223     typedef GM INHERITED; | 
|  212 }; |  224 }; | 
|  213  |  225  | 
|  214 ////////////////////////////////////////////////////////////////////////////// |  226 ////////////////////////////////////////////////////////////////////////////// | 
|  215  |  227  | 
|  216 DEF_GM( return new XfermodeImageFilterGM; ); |  228 DEF_GM( return new XfermodeImageFilterGM; ); | 
|  217  |  229  | 
|  218 } |  230 } | 
| OLD | NEW |