Chromium Code Reviews| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 if (fMode) { | 105 if (fMode) { |
| 106 fMode->toString(str); | 106 fMode->toString(str); |
| 107 } | 107 } |
| 108 str->append("))"); | 108 str->append("))"); |
| 109 } | 109 } |
| 110 #endif | 110 #endif |
| 111 | 111 |
| 112 #if SK_SUPPORT_GPU | 112 #if SK_SUPPORT_GPU |
| 113 | 113 |
| 114 bool SkXfermodeImageFilter::canFilterImageGPU() const { | 114 bool SkXfermodeImageFilter::canFilterImageGPU() const { |
| 115 // This is checked with the background texture as NULL here since we have no actual texture, | |
|
bsalomon
2015/01/14 15:18:13
Does this comment add much? Maybe just "Call asFra
| |
| 116 // however it will be assumed that a valid texture is used if asFragmentProc essor is called | |
| 117 // outside of checking return values. | |
| 115 return fMode && fMode->asFragmentProcessor(NULL, NULL) && !cropRectIsSet(); | 118 return fMode && fMode->asFragmentProcessor(NULL, NULL) && !cropRectIsSet(); |
| 116 } | 119 } |
| 117 | 120 |
| 118 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, | 121 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, |
| 119 const SkBitmap& src, | 122 const SkBitmap& src, |
| 120 const Context& ctx, | 123 const Context& ctx, |
| 121 SkBitmap* result, | 124 SkBitmap* result, |
| 122 SkIPoint* offset) const { | 125 SkIPoint* offset) const { |
| 123 SkBitmap background = src; | 126 SkBitmap background = src; |
| 124 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 127 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
| 125 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &backgro und, | 128 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &backgro und, |
| 126 &backgroundOffset)) { | 129 &backgroundOffset)) { |
| 127 return onFilterImage(proxy, src, ctx, result, offset); | 130 return onFilterImage(proxy, src, ctx, result, offset); |
| 128 } | 131 } |
| 129 GrTexture* backgroundTex = background.getTexture(); | 132 GrTexture* backgroundTex = background.getTexture(); |
| 133 | |
| 134 if (NULL == backgroundTex) { | |
| 135 SkASSERT(false); | |
| 136 return false; | |
| 137 } | |
| 138 | |
| 130 SkBitmap foreground = src; | 139 SkBitmap foreground = src; |
| 131 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); | 140 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); |
| 132 if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foregro und, | 141 if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foregro und, |
| 133 &foregroundOffset)) { | 142 &foregroundOffset)) { |
| 134 return onFilterImage(proxy, src, ctx, result, offset); | 143 return onFilterImage(proxy, src, ctx, result, offset); |
| 135 } | 144 } |
| 136 GrTexture* foregroundTex = foreground.getTexture(); | 145 GrTexture* foregroundTex = foreground.getTexture(); |
| 137 GrContext* context = foregroundTex->getContext(); | 146 GrContext* context = foregroundTex->getContext(); |
| 138 | 147 |
| 139 GrFragmentProcessor* xferProcessor = NULL; | 148 GrFragmentProcessor* xferProcessor = NULL; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 170 context->drawRect(paint, SkMatrix::I(), srcRect); | 179 context->drawRect(paint, SkMatrix::I(), srcRect); |
| 171 | 180 |
| 172 offset->fX = backgroundOffset.fX; | 181 offset->fX = backgroundOffset.fX; |
| 173 offset->fY = backgroundOffset.fY; | 182 offset->fY = backgroundOffset.fY; |
| 174 WrapTexture(dst, src.width(), src.height(), result); | 183 WrapTexture(dst, src.width(), src.height(), result); |
| 175 return true; | 184 return true; |
| 176 } | 185 } |
| 177 | 186 |
| 178 #endif | 187 #endif |
| 179 | 188 |
| OLD | NEW |