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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 !backgroundInput->filterImage(proxy, src, ctx, &background, &backgroundO
ffset)) { | 55 !backgroundInput->filterImage(proxy, src, ctx, &background, &backgroundO
ffset)) { |
56 return false; | 56 return false; |
57 } | 57 } |
58 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); | 58 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); |
59 if (foregroundInput && | 59 if (foregroundInput && |
60 !foregroundInput->filterImage(proxy, src, ctx, &foreground, &foregroundO
ffset)) { | 60 !foregroundInput->filterImage(proxy, src, ctx, &foreground, &foregroundO
ffset)) { |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 SkIRect bounds, foregroundBounds; | 64 SkIRect bounds, foregroundBounds; |
65 background.getBounds(&bounds); | 65 if (!applyCropRect(ctx, foreground, foregroundOffset, &foregroundBounds)) { |
66 bounds.offset(backgroundOffset); | |
67 foreground.getBounds(&foregroundBounds); | |
68 foregroundBounds.offset(foregroundOffset); | |
69 bounds.join(foregroundBounds); | |
70 if (!applyCropRect(&bounds, ctx.ctm())) { | |
71 return false; | 66 return false; |
72 } | 67 } |
| 68 if (!applyCropRect(ctx, background, backgroundOffset, &bounds)) { |
| 69 return false; |
| 70 } |
| 71 bounds.join(foregroundBounds); |
73 | 72 |
74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 73 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
75 if (NULL == device.get()) { | 74 if (NULL == device.get()) { |
76 return false; | 75 return false; |
77 } | 76 } |
78 SkCanvas canvas(device); | 77 SkCanvas canvas(device); |
79 canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())
); | 78 canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())
); |
80 SkPaint paint; | 79 SkPaint paint; |
81 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 80 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
82 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX), | 81 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix); | 156 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix); |
158 context->drawRect(foregroundPaint, srcRect); | 157 context->drawRect(foregroundPaint, srcRect); |
159 } | 158 } |
160 offset->fX = backgroundOffset.fX; | 159 offset->fX = backgroundOffset.fX; |
161 offset->fY = backgroundOffset.fY; | 160 offset->fY = backgroundOffset.fY; |
162 WrapTexture(dst, src.width(), src.height(), result); | 161 WrapTexture(dst, src.width(), src.height(), result); |
163 return true; | 162 return true; |
164 } | 163 } |
165 | 164 |
166 #endif | 165 #endif |
OLD | NEW |