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

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: Remove SkSinglePassImageFilter class; move impl into SkImageFilter::filterImageGPU(). 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
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 false;
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)) {
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 SkAutoTUnref<GrEffectRef> effect(asNewEffect(srcTexture));
bsalomon 2013/04/08 17:52:17 this->asNewEffect()
139 SkASSERT(effect);
140 GrPaint paint;
141 paint.colorStage(0)->setEffect(effect);
142 context->drawRect(paint, rect);
143 SkAutoTUnref<GrTexture> resultTex(dst.detach());
144 SkImageFilterUtils::WrapTexture(resultTex, input.width(), input.height(), re sult);
145 return true;
146 #else
112 return false; 147 return false;
148 #endif
113 } 149 }
114 150
115 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, 151 bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
116 SkIRect* dst) { 152 SkIRect* dst) {
117 *dst = src; 153 *dst = src;
118 return true; 154 return true;
119 } 155 }
120 156
121 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*) const { 157 GrEffectRef* SkImageFilter::asNewEffect(GrTexture*) const {
122 return false; 158 return NULL;
123 } 159 }
124 160
125 bool SkImageFilter::asColorFilter(SkColorFilter**) const { 161 bool SkImageFilter::asColorFilter(SkColorFilter**) const {
126 return false; 162 return false;
127 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698