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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 81 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
82 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX), | 82 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX), |
83 SkIntToScalar(backgroundOffset.fY), &paint); | 83 SkIntToScalar(backgroundOffset.fY), &paint); |
84 paint.setXfermode(fMode); | 84 paint.setXfermode(fMode); |
85 canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX), | 85 canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX), |
86 SkIntToScalar(foregroundOffset.fY), &paint); | 86 SkIntToScalar(foregroundOffset.fY), &paint); |
87 canvas.clipRect(SkRect::Make(foregroundBounds), SkRegion::kDifference_Op); | 87 canvas.clipRect(SkRect::Make(foregroundBounds), SkRegion::kDifference_Op); |
88 paint.setColor(SK_ColorTRANSPARENT); | 88 paint.setColor(SK_ColorTRANSPARENT); |
89 canvas.drawPaint(paint); | 89 canvas.drawPaint(paint); |
90 *dst = device->accessBitmap(false); | 90 *dst = device->accessBitmap(false); |
91 offset->fX += bounds.left(); | 91 offset->fX = bounds.left(); |
92 offset->fY += bounds.top(); | 92 offset->fY = bounds.top(); |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 #if SK_SUPPORT_GPU | 96 #if SK_SUPPORT_GPU |
97 | 97 |
98 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, | 98 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, |
99 const SkBitmap& src, | 99 const SkBitmap& src, |
100 const SkMatrix& ctm, | 100 const SkMatrix& ctm, |
101 SkBitmap* result, | 101 SkBitmap* result, |
102 SkIPoint* offset) { | 102 SkIPoint* offset) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 GrPaint backgroundPaint; | 150 GrPaint backgroundPaint; |
151 SkMatrix backgroundMatrix = GrEffect::MakeDivByTextureWHMatrix(backgroun
dTex); | 151 SkMatrix backgroundMatrix = GrEffect::MakeDivByTextureWHMatrix(backgroun
dTex); |
152 backgroundPaint.addColorTextureEffect(backgroundTex, backgroundMatrix); | 152 backgroundPaint.addColorTextureEffect(backgroundTex, backgroundMatrix); |
153 context->drawRect(backgroundPaint, srcRect); | 153 context->drawRect(backgroundPaint, srcRect); |
154 | 154 |
155 GrPaint foregroundPaint; | 155 GrPaint foregroundPaint; |
156 foregroundPaint.setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblen
d(dm)); | 156 foregroundPaint.setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblen
d(dm)); |
157 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix); | 157 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix); |
158 context->drawRect(foregroundPaint, srcRect); | 158 context->drawRect(foregroundPaint, srcRect); |
159 } | 159 } |
160 offset->fX += backgroundOffset.fX; | 160 offset->fX = backgroundOffset.fX; |
161 offset->fY += backgroundOffset.fY; | 161 offset->fY = backgroundOffset.fY; |
162 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul
t); | 162 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul
t); |
163 } | 163 } |
164 | 164 |
165 #endif | 165 #endif |
OLD | NEW |