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

Side by Side Diff: src/core/SkImageFilter.cpp

Issue 13602013: Allow single-pass filters (which use asNewEffect()) to participate in the image filter DAG. This w… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix return value of SkImageFilter::asNewEffect(). Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « include/effects/SkMatrixConvolutionImageFilter.h ('k') | src/core/SkImageFilterUtils.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 2012 The Android Open Source Project 2 * Copyright 2012 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 "SkImageFilter.h" 8 #include "SkImageFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkFlattenableBuffers.h" 11 #include "SkFlattenableBuffers.h"
12 #include "SkRect.h" 12 #include "SkRect.h"
13 #if SK_SUPPORT_GPU
14 #include "GrContext.h"
15 #include "GrTexture.h"
16 #include "SkImageFilterUtils.h"
17 #endif
13 18
14 SK_DEFINE_INST_COUNT(SkImageFilter) 19 SK_DEFINE_INST_COUNT(SkImageFilter)
15 20
16 SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs) 21 SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs)
17 : fInputCount(inputCount), fInputs(new SkImageFilter*[inputCount]) { 22 : fInputCount(inputCount), fInputs(new SkImageFilter*[inputCount]) {
18 for (int i = 0; i < inputCount; ++i) { 23 for (int i = 0; i < inputCount; ++i) {
19 fInputs[i] = inputs[i]; 24 fInputs[i] = inputs[i];
20 SkSafeRef(fInputs[i]); 25 SkSafeRef(fInputs[i]);
21 } 26 }
22 } 27 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 SkASSERT(dst); 102 SkASSERT(dst);
98 return this->onFilterBounds(src, ctm, dst); 103 return this->onFilterBounds(src, ctm, dst);
99 } 104 }
100 105
101 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&, 106 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&,
102 SkBitmap*, SkIPoint*) { 107 SkBitmap*, SkIPoint*) {
103 return false; 108 return false;
104 } 109 }
105 110
106 bool SkImageFilter::canFilterImageGPU() const { 111 bool SkImageFilter::canFilterImageGPU() const {
107 return false; 112 return asNewEffect(NULL, NULL);
bsalomon 2013/04/08 19:38:30 this->
108 } 113 }
109 114
110 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) { 115 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) {
111 SkASSERT(false); // Should never be called, since canFilterImageGPU() retur ned false. 116 #if SK_SUPPORT_GPU
117 SkBitmap input;
118 SkASSERT(fInputCount == 1);
119 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &input)) {
bsalomon 2013/04/08 19:38:30 this->
120 return false;
121 }
122 GrTexture* srcTexture = (GrTexture*) input.getTexture();
123 SkRect rect;
124 src.getBounds(&rect);
125 GrContext* context = srcTexture->getContext();
126
127 GrTextureDesc desc;
128 desc.fFlags = kRenderTarget_GrTextureFlagBit,
129 desc.fWidth = input.width();
130 desc.fHeight = input.height();
131 desc.fConfig = kRGBA_8888_GrPixelConfig;
132
133 GrAutoScratchTexture dst(context, desc);
134 GrContext::AutoMatrix am;
135 am.setIdentity(context);
136 GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
137 GrContext::AutoClip acs(context, rect);
138 GrEffectRef* effect;
139 asNewEffect(&effect, srcTexture);
bsalomon 2013/04/08 19:38:30 this->
140 SkASSERT(effect);
141 SkAutoUnref effectRef(effect);
142 GrPaint paint;
143 paint.colorStage(0)->setEffect(effect);
144 context->drawRect(paint, rect);
145 SkAutoTUnref<GrTexture> resultTex(dst.detach());
146 SkImageFilterUtils::WrapTexture(resultTex, input.width(), input.height(), re sult);
147 return true;
148 #else
112 return false; 149 return false;
150 #endif
113 } 151 }
114 152
115 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, 153 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
116 SkIRect* dst) { 154 SkIRect* dst) {
117 *dst = src; 155 *dst = src;
118 return true; 156 return true;
119 } 157 }
120 158
121 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*) const { 159 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*) const {
122 return false; 160 return false;
123 } 161 }
124 162
125 bool SkImageFilter::asColorFilter(SkColorFilter**) const { 163 bool SkImageFilter::asColorFilter(SkColorFilter**) const {
126 return false; 164 return false;
127 } 165 }
OLDNEW
« no previous file with comments | « include/effects/SkMatrixConvolutionImageFilter.h ('k') | src/core/SkImageFilterUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698