Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "SkBitmapSource.h" | |
| 14 #include "SkGradientShader.h" | 15 #include "SkGradientShader.h" |
| 16 #include "SkXfermodeImageFilter.h" | |
| 15 #define WW 100 | 17 #define WW 100 |
| 16 #define HH 32 | 18 #define HH 32 |
| 17 | 19 |
| 18 static SkBitmap make_bm() { | 20 static SkBitmap make_bm() { |
| 19 SkBitmap bm; | 21 SkBitmap bm; |
| 20 bm.setConfig(SkBitmap::kARGB_8888_Config, WW, HH); | 22 bm.setConfig(SkBitmap::kARGB_8888_Config, WW, HH); |
| 21 bm.allocPixels(); | 23 bm.allocPixels(); |
| 22 bm.eraseColor(SK_ColorTRANSPARENT); | 24 bm.eraseColor(SK_ColorTRANSPARENT); |
| 23 return bm; | 25 return bm; |
| 24 } | 26 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 SkScalar x = 0; | 108 SkScalar x = 0; |
| 107 canvas->drawBitmap(src, x, y, NULL); | 109 canvas->drawBitmap(src, x, y, NULL); |
| 108 x += gap; | 110 x += gap; |
| 109 canvas->drawBitmap(dst, x, y, NULL); | 111 canvas->drawBitmap(dst, x, y, NULL); |
| 110 x += gap; | 112 x += gap; |
| 111 SkRect rect = SkRect::MakeXYWH(x, y, SkIntToScalar(WW), SkIntToScala r(HH)); | 113 SkRect rect = SkRect::MakeXYWH(x, y, SkIntToScalar(WW), SkIntToScala r(HH)); |
| 112 canvas->saveLayer(&rect, NULL); | 114 canvas->saveLayer(&rect, NULL); |
| 113 canvas->drawBitmap(dst, x, y, NULL); | 115 canvas->drawBitmap(dst, x, y, NULL); |
| 114 SkXfermode* xfer = SkArithmeticMode::Create(k[0], k[1], k[2], k[3]); | 116 SkXfermode* xfer = SkArithmeticMode::Create(k[0], k[1], k[2], k[3]); |
| 115 SkPaint paint; | 117 SkPaint paint; |
| 116 paint.setXfermode(xfer)->unref(); | 118 if ((k - K) % 2 != 0) { |
| 119 // Test out an arithmode filter created as an xfermode image fil ter | |
| 120 SkAutoTUnref<SkImageFilter> background(new SkBitmapSource(dst)); | |
| 121 SkXfermode* xfer = SkArithmeticMode::Create(0, one, one, 0); | |
|
reed1
2013/05/30 20:42:44
I think this xfer leaks, and it makes us leak the
Stephen White
2013/05/30 20:50:26
Good point. This whole whole section never gets ex
| |
| 122 SkAutoTUnref<SkImageFilter> filter(new SkXfermodeImageFilter(xfe r, background)); | |
| 123 paint.setImageFilter(filter); | |
| 124 } else { | |
| 125 paint.setXfermode(xfer)->unref(); | |
| 126 } | |
| 117 canvas->drawBitmap(src, x, y, &paint); | 127 canvas->drawBitmap(src, x, y, &paint); |
| 118 canvas->restore(); | 128 canvas->restore(); |
| 119 x += gap; | 129 x += gap; |
| 120 show_k_text(canvas, x, y, k); | 130 show_k_text(canvas, x, y, k); |
| 121 k += 4; | 131 k += 4; |
| 122 y += SkIntToScalar(src.height() + 12); | 132 y += SkIntToScalar(src.height() + 12); |
| 123 } | 133 } |
| 124 } | 134 } |
| 125 | 135 |
| 126 private: | 136 private: |
| 127 typedef GM INHERITED; | 137 typedef GM INHERITED; |
| 128 }; | 138 }; |
| 129 | 139 |
| 130 /////////////////////////////////////////////////////////////////////////////// | 140 /////////////////////////////////////////////////////////////////////////////// |
| 131 | 141 |
| 132 static skiagm::GM* MyFactory(void*) { return new ArithmodeGM; } | 142 static skiagm::GM* MyFactory(void*) { return new ArithmodeGM; } |
| 133 static skiagm::GMRegistry reg(MyFactory); | 143 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |