| 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 23 matching lines...) Expand all Loading... |
| 34 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); | 34 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); |
| 35 SkAutoTUnref<SkXfermode> mode(buffer.readXfermode()); | 35 SkAutoTUnref<SkXfermode> mode(buffer.readXfermode()); |
| 36 return Create(mode, common.getInput(0), common.getInput(1), &common.cropRect
()); | 36 return Create(mode, common.getInput(0), common.getInput(1), &common.cropRect
()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const { | 39 void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 40 this->INHERITED::flatten(buffer); | 40 this->INHERITED::flatten(buffer); |
| 41 buffer.writeFlattenable(fMode); | 41 buffer.writeFlattenable(fMode); |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy, | 44 bool SkXfermodeImageFilter::onFilterImageDeprecated(Proxy* proxy, |
| 45 const SkBitmap& src, | 45 const SkBitmap& src, |
| 46 const Context& ctx, | 46 const Context& ctx, |
| 47 SkBitmap* dst, | 47 SkBitmap* dst, |
| 48 SkIPoint* offset) const { | 48 SkIPoint* offset) const { |
| 49 SkBitmap background = src, foreground = src; | 49 SkBitmap background = src, foreground = src; |
| 50 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 50 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
| 51 if (!this->filterInput(0, proxy, src, ctx, &background, &backgroundOffset))
{ | 51 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun
dOffset)) { |
| 52 background.reset(); | 52 background.reset(); |
| 53 } | 53 } |
| 54 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); | 54 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); |
| 55 if (!this->filterInput(1, proxy, src, ctx, &foreground, &foregroundOffset))
{ | 55 if (!this->filterInputDeprecated(1, proxy, src, ctx, &foreground, &foregroun
dOffset)) { |
| 56 foreground.reset(); | 56 foreground.reset(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 SkIRect bounds, foregroundBounds; | 59 SkIRect bounds, foregroundBounds; |
| 60 SkIRect foregroundSrcBounds = foreground.bounds(); | 60 SkIRect foregroundSrcBounds = foreground.bounds(); |
| 61 foregroundSrcBounds.offset(foregroundOffset); | 61 foregroundSrcBounds.offset(foregroundOffset); |
| 62 if (!applyCropRect(ctx, foregroundSrcBounds, &foregroundBounds)) { | 62 if (!applyCropRect(ctx, foregroundSrcBounds, &foregroundBounds)) { |
| 63 foregroundBounds.setEmpty(); | 63 foregroundBounds.setEmpty(); |
| 64 foreground.reset(); | 64 foreground.reset(); |
| 65 } | 65 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 #endif | 119 #endif |
| 120 | 120 |
| 121 #if SK_SUPPORT_GPU | 121 #if SK_SUPPORT_GPU |
| 122 | 122 |
| 123 bool SkXfermodeImageFilter::canFilterImageGPU() const { | 123 bool SkXfermodeImageFilter::canFilterImageGPU() const { |
| 124 return !this->cropRectIsSet(); | 124 return !this->cropRectIsSet(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 #include "SkXfermode_proccoeff.h" | 127 #include "SkXfermode_proccoeff.h" |
| 128 | 128 |
| 129 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, | 129 bool SkXfermodeImageFilter::filterImageGPUDeprecated(Proxy* proxy, |
| 130 const SkBitmap& src, | 130 const SkBitmap& src, |
| 131 const Context& ctx, | 131 const Context& ctx, |
| 132 SkBitmap* result, | 132 SkBitmap* result, |
| 133 SkIPoint* offset) const { | 133 SkIPoint* offset) const { |
| 134 GrContext* context = nullptr; | 134 GrContext* context = nullptr; |
| 135 SkBitmap background = src; | 135 SkBitmap background = src; |
| 136 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 136 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
| 137 if (!this->filterInputGPU(0, proxy, src, ctx, &background, &backgroundOffset
)) { | 137 if (!this->filterInputGPUDeprecated(0, proxy, src, ctx, &background, &backgr
oundOffset)) { |
| 138 background.reset(); | 138 background.reset(); |
| 139 } | 139 } |
| 140 GrTexture* backgroundTex = background.getTexture(); | 140 GrTexture* backgroundTex = background.getTexture(); |
| 141 if (backgroundTex) { | 141 if (backgroundTex) { |
| 142 context = backgroundTex->getContext(); | 142 context = backgroundTex->getContext(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 SkBitmap foreground = src; | 145 SkBitmap foreground = src; |
| 146 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); | 146 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); |
| 147 if (!this->filterInputGPU(1, proxy, src, ctx, &foreground, &foregroundOffset
)) { | 147 if (!this->filterInputGPUDeprecated(1, proxy, src, ctx, &foreground, &foregr
oundOffset)) { |
| 148 foreground.reset(); | 148 foreground.reset(); |
| 149 } | 149 } |
| 150 GrTexture* foregroundTex = foreground.getTexture(); | 150 GrTexture* foregroundTex = foreground.getTexture(); |
| 151 if (foregroundTex) { | 151 if (foregroundTex) { |
| 152 context = foregroundTex->getContext(); | 152 context = foregroundTex->getContext(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 if (!context) { | 155 if (!context) { |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds
)); | 241 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds
)); |
| 242 | 242 |
| 243 offset->fX = bounds.left(); | 243 offset->fX = bounds.left(); |
| 244 offset->fY = bounds.top(); | 244 offset->fY = bounds.top(); |
| 245 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); | 245 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); |
| 246 return true; | 246 return true; |
| 247 } | 247 } |
| 248 | 248 |
| 249 #endif | 249 #endif |
| 250 | 250 |
| OLD | NEW |