OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 The Android Open Source Project |
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 "SkXfermodeImageFilter.h" | 8 #include "SkXfermodeImageFilter.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 const SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(
), | 97 const SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(
), |
98 kPremul_SkAlphaType); | 98 kPremul_SkAlphaType); |
99 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); | 99 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); |
100 if (!surf) { | 100 if (!surf) { |
101 return nullptr; | 101 return nullptr; |
102 } | 102 } |
103 | 103 |
104 SkCanvas* canvas = surf->getCanvas(); | 104 SkCanvas* canvas = surf->getCanvas(); |
105 SkASSERT(canvas); | 105 SkASSERT(canvas); |
106 | 106 |
| 107 canvas->clear(0x0); // can't count on background to fully clear the backgrou
nd |
| 108 |
107 canvas->translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()
)); | 109 canvas->translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()
)); |
108 | 110 |
109 SkPaint paint; | 111 SkPaint paint; |
110 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 112 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
111 | 113 |
112 if (background) { | 114 if (background) { |
113 background->draw(canvas, | 115 background->draw(canvas, |
114 SkIntToScalar(backgroundOffset.fX), SkIntToScalar(backg
roundOffset.fY), | 116 SkIntToScalar(backgroundOffset.fX), SkIntToScalar(backg
roundOffset.fY), |
115 &paint); | 117 &paint); |
116 } | 118 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 SkMatrix matrix; | 250 SkMatrix matrix; |
249 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); | 251 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); |
250 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds
)); | 252 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds
)); |
251 | 253 |
252 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he
ight()), | 254 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.he
ight()), |
253 kNeedNewImageUniqueID_SpecialImage, | 255 kNeedNewImageUniqueID_SpecialImage, |
254 drawContext->asTexture()); | 256 drawContext->asTexture()); |
255 } | 257 } |
256 | 258 |
257 #endif | 259 #endif |
OLD | NEW |