| OLD | NEW |
| 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkColorMatrixFilter.h" | 10 #include "SkColorMatrixFilter.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 matrix[0] = matrix[5] = matrix[10] = 0.2126f; | 38 matrix[0] = matrix[5] = matrix[10] = 0.2126f; |
| 39 matrix[1] = matrix[6] = matrix[11] = 0.7152f; | 39 matrix[1] = matrix[6] = matrix[11] = 0.7152f; |
| 40 matrix[2] = matrix[7] = matrix[12] = 0.0722f; | 40 matrix[2] = matrix[7] = matrix[12] = 0.0722f; |
| 41 matrix[18] = 1.0f; | 41 matrix[18] = 1.0f; |
| 42 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); | 42 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); |
| 43 return SkColorFilterImageFilter::Create(filter, input); | 43 return SkColorFilterImageFilter::Create(filter, input); |
| 44 } | 44 } |
| 45 | 45 |
| 46 static SkImageFilter* make_mode_blue(SkImageFilter* input = NULL) { | 46 static SkImageFilter* make_mode_blue(SkImageFilter* input = NULL) { |
| 47 SkAutoTUnref<SkColorFilter> filter( | 47 SkAutoTUnref<SkColorFilter> filter( |
| 48 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode)); | 48 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrc_Mode)); |
| 49 return SkColorFilterImageFilter::Create(filter, input); | 49 return SkColorFilterImageFilter::Create(filter, input); |
| 50 } | 50 } |
| 51 | 51 |
| 52 class ColorFilterImageFilterGM : public skiagm::GM { | 52 class ColorFilterImageFilterGM : public skiagm::GM { |
| 53 public: | 53 public: |
| 54 ColorFilterImageFilterGM () {} | 54 ColorFilterImageFilterGM () {} |
| 55 | 55 |
| 56 protected: | 56 protected: |
| 57 | 57 |
| 58 virtual SkString onShortName() { | 58 virtual SkString onShortName() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 drawClippedRect(canvas, r, paint); | 113 drawClippedRect(canvas, r, paint); |
| 114 canvas->translate(FILTER_WIDTH + MARGIN, 0); | 114 canvas->translate(FILTER_WIDTH + MARGIN, 0); |
| 115 } | 115 } |
| 116 { | 116 { |
| 117 SkAutoTUnref<SkImageFilter> blur(make_blur(3.0f)); | 117 SkAutoTUnref<SkImageFilter> blur(make_blur(3.0f)); |
| 118 SkAutoTUnref<SkImageFilter> brightness(make_brightness(0.5f, blur)); | 118 SkAutoTUnref<SkImageFilter> brightness(make_brightness(0.5f, blur)); |
| 119 paint.setImageFilter(brightness); | 119 paint.setImageFilter(brightness); |
| 120 drawClippedRect(canvas, r, paint, 3); | 120 drawClippedRect(canvas, r, paint, 3); |
| 121 canvas->translate(FILTER_WIDTH + MARGIN, 0); | 121 canvas->translate(FILTER_WIDTH + MARGIN, 0); |
| 122 } | 122 } |
| 123 { |
| 124 SkAutoTUnref<SkImageFilter> blue(make_mode_blue()); |
| 125 paint.setImageFilter(blue.get()); |
| 126 drawClippedRect(canvas, r, paint, 5); |
| 127 canvas->translate(FILTER_WIDTH + MARGIN, 0); |
| 128 } |
| 123 } | 129 } |
| 124 | 130 |
| 125 private: | 131 private: |
| 126 typedef GM INHERITED; | 132 typedef GM INHERITED; |
| 127 }; | 133 }; |
| 128 | 134 |
| 129 ////////////////////////////////////////////////////////////////////////////// | 135 ////////////////////////////////////////////////////////////////////////////// |
| 130 | 136 |
| 131 static skiagm::GM* MyFactory(void*) { return new ColorFilterImageFilterGM; } | 137 static skiagm::GM* MyFactory(void*) { return new ColorFilterImageFilterGM; } |
| 132 static skiagm::GMRegistry reg(MyFactory); | 138 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |