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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 SkBitmap background = src, foreground = src; | 57 SkBitmap background = src, foreground = src; |
58 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 58 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
59 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun
dOffset)) { | 59 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun
dOffset)) { |
60 background.reset(); | 60 background.reset(); |
61 } | 61 } |
62 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); | 62 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); |
63 if (!this->filterInputDeprecated(1, proxy, src, ctx, &foreground, &foregroun
dOffset)) { | 63 if (!this->filterInputDeprecated(1, proxy, src, ctx, &foreground, &foregroun
dOffset)) { |
64 foreground.reset(); | 64 foreground.reset(); |
65 } | 65 } |
66 | 66 |
67 SkIRect bounds, foregroundBounds; | 67 SkIRect foregroundBounds = foreground.bounds(); |
68 SkIRect foregroundSrcBounds = foreground.bounds(); | 68 foregroundBounds.offset(foregroundOffset); |
69 foregroundSrcBounds.offset(foregroundOffset); | 69 SkIRect srcBounds = background.bounds(); |
70 if (!applyCropRect(ctx, foregroundSrcBounds, &foregroundBounds)) { | 70 srcBounds.offset(backgroundOffset); |
71 foregroundBounds.setEmpty(); | 71 srcBounds.join(foregroundBounds); |
72 foreground.reset(); | 72 SkIRect bounds; |
73 } | 73 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
74 SkIRect backgroundSrcBounds = background.bounds(); | |
75 backgroundSrcBounds.offset(backgroundOffset); | |
76 if (!applyCropRect(ctx, backgroundSrcBounds, &bounds)) { | |
77 bounds.setEmpty(); | |
78 background.reset(); | |
79 } | |
80 bounds.join(foregroundBounds); | |
81 if (bounds.isEmpty()) { | |
82 return false; | 74 return false; |
83 } | 75 } |
84 | 76 |
85 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 77 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
86 if (nullptr == device.get()) { | 78 if (nullptr == device.get()) { |
87 return false; | 79 return false; |
88 } | 80 } |
89 SkCanvas canvas(device); | 81 SkCanvas canvas(device); |
90 canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())
); | 82 canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())
); |
91 SkPaint paint; | 83 SkPaint paint; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); | 240 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top
())); |
249 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds
)); | 241 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds
)); |
250 | 242 |
251 offset->fX = bounds.left(); | 243 offset->fX = bounds.left(); |
252 offset->fY = bounds.top(); | 244 offset->fY = bounds.top(); |
253 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); | 245 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); |
254 return true; | 246 return true; |
255 } | 247 } |
256 | 248 |
257 #endif | 249 #endif |
OLD | NEW |