Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: src/effects/SkXfermodeImageFilter.cpp

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 canvas.drawPaint(paint); 101 canvas.drawPaint(paint);
102 *dst = device->accessBitmap(false); 102 *dst = device->accessBitmap(false);
103 offset->fX = bounds.left(); 103 offset->fX = bounds.left();
104 offset->fY = bounds.top(); 104 offset->fY = bounds.top();
105 return true; 105 return true;
106 } 106 }
107 107
108 #if SK_SUPPORT_GPU 108 #if SK_SUPPORT_GPU
109 109
110 bool SkXfermodeImageFilter::canFilterImageGPU() const { 110 bool SkXfermodeImageFilter::canFilterImageGPU() const {
111 return fMode && fMode->asNewEffect(NULL, NULL) && !cropRectIsSet(); 111 return fMode && fMode->asFragmentProcessor(NULL, NULL) && !cropRectIsSet();
112 } 112 }
113 113
114 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, 114 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
115 const SkBitmap& src, 115 const SkBitmap& src,
116 const Context& ctx, 116 const Context& ctx,
117 SkBitmap* result, 117 SkBitmap* result,
118 SkIPoint* offset) const { 118 SkIPoint* offset) const {
119 SkBitmap background = src; 119 SkBitmap background = src;
120 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); 120 SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
121 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &backgro und, 121 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &backgro und,
122 &backgroundOffset)) { 122 &backgroundOffset)) {
123 return onFilterImage(proxy, src, ctx, result, offset); 123 return onFilterImage(proxy, src, ctx, result, offset);
124 } 124 }
125 GrTexture* backgroundTex = background.getTexture(); 125 GrTexture* backgroundTex = background.getTexture();
126 SkBitmap foreground = src; 126 SkBitmap foreground = src;
127 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); 127 SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
128 if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foregro und, 128 if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foregro und,
129 &foregroundOffset)) { 129 &foregroundOffset)) {
130 return onFilterImage(proxy, src, ctx, result, offset); 130 return onFilterImage(proxy, src, ctx, result, offset);
131 } 131 }
132 GrTexture* foregroundTex = foreground.getTexture(); 132 GrTexture* foregroundTex = foreground.getTexture();
133 GrContext* context = foregroundTex->getContext(); 133 GrContext* context = foregroundTex->getContext();
134 134
135 GrEffect* xferEffect = NULL; 135 GrFragmentProcessor* xferProcessor = NULL;
136 136
137 GrTextureDesc desc; 137 GrTextureDesc desc;
138 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 138 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
139 desc.fWidth = src.width(); 139 desc.fWidth = src.width();
140 desc.fHeight = src.height(); 140 desc.fHeight = src.height();
141 desc.fConfig = kSkia8888_GrPixelConfig; 141 desc.fConfig = kSkia8888_GrPixelConfig;
142 142
143 GrAutoScratchTexture ast(context, desc); 143 GrAutoScratchTexture ast(context, desc);
144 if (NULL == ast.texture()) { 144 if (NULL == ast.texture()) {
145 return false; 145 return false;
146 } 146 }
147 SkAutoTUnref<GrTexture> dst(ast.detach()); 147 SkAutoTUnref<GrTexture> dst(ast.detach());
148 148
149 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); 149 GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
150 150
151 if (!fMode || !fMode->asNewEffect(&xferEffect, backgroundTex)) { 151 if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) {
152 // canFilterImageGPU() should've taken care of this 152 // canFilterImageGPU() should've taken care of this
153 SkASSERT(false); 153 SkASSERT(false);
154 return false; 154 return false;
155 } 155 }
156 156
157 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg roundTex); 157 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg roundTex);
158 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf fset.fX), 158 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf fset.fX),
159 SkIntToScalar(backgroundOffset.fY-foregroundOf fset.fY)); 159 SkIntToScalar(backgroundOffset.fY-foregroundOf fset.fY));
160 160
161 161
162 SkRect srcRect; 162 SkRect srcRect;
163 src.getBounds(&srcRect); 163 src.getBounds(&srcRect);
164 164
165 GrPaint paint; 165 GrPaint paint;
166 paint.addColorTextureEffect(foregroundTex, foregroundMatrix); 166 paint.addColorTextureProcessor(foregroundTex, foregroundMatrix);
167 paint.addColorEffect(xferEffect)->unref(); 167 paint.addColorProcessor(xferProcessor)->unref();
168 context->drawRect(paint, srcRect); 168 context->drawRect(paint, srcRect);
169 169
170 offset->fX = backgroundOffset.fX; 170 offset->fX = backgroundOffset.fX;
171 offset->fY = backgroundOffset.fY; 171 offset->fY = backgroundOffset.fY;
172 WrapTexture(dst, src.width(), src.height(), result); 172 WrapTexture(dst, src.width(), src.height(), result);
173 return true; 173 return true;
174 } 174 }
175 175
176 #endif 176 #endif
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698