Added ctm matrix to GPU path

There should be no changes in behavior caused by this cl, it just adds the ctm matrix to filterImageGPU so that it may be used for scaling on all platforms when it is implemented on the blink side.

BUG=
R=senorblanco@google.com, senorblanco@chromium.org

Author: sugoi@chromium.org

Review URL: https://chromiumcodereview.appspot.com/22209002

git-svn-id: http://skia.googlecode.com/svn/trunk@10536 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2013-08-05 16:53:50 +00:00
parent a27622c18d
commit 1aa54bf669
15 changed files with 52 additions and 46 deletions

View File

@ -114,7 +114,8 @@ public:
* relative to the src when it is drawn. The default implementation does
* single-pass processing using asNewEffect().
*/
virtual bool filterImageGPU(Proxy*, const SkBitmap& src, SkBitmap* result, SkIPoint* offset);
virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset);
/**
* Returns whether this image filter is a color filter and puts the color filter into the

View File

@ -29,7 +29,8 @@ public:
* will be processed in software and uploaded to the GPU.
*/
static bool GetInputResultGPU(SkImageFilter* filter, SkImageFilter::Proxy* proxy,
const SkBitmap& src, SkBitmap* result, SkIPoint* offset);
const SkBitmap& src, const SkMatrix& ctm, SkBitmap* result,
SkIPoint* offset);
};
#endif

View File

@ -43,8 +43,8 @@ protected:
#if SK_SUPPORT_GPU
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) SK_OVERRIDE;
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
#endif
private:

View File

@ -28,8 +28,8 @@ protected:
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
bool canFilterImageGPU() const SK_OVERRIDE { return true; }
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) SK_OVERRIDE;
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
private:
SkSize fSigma;

View File

@ -38,8 +38,8 @@ public:
SkIPoint* offset) SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) SK_OVERRIDE;
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
#endif
protected:

View File

@ -38,8 +38,8 @@ public:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) SK_OVERRIDE;
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
#endif
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter)
@ -59,8 +59,8 @@ public:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) SK_OVERRIDE;
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
#endif
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter)

View File

@ -35,8 +35,8 @@ public:
SkIPoint* offset) SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; }
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) SK_OVERRIDE;
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE;
#endif
protected:

View File

@ -105,12 +105,12 @@ bool SkImageFilter::canFilterImageGPU() const {
return this->asNewEffect(NULL, NULL, SkIPoint::Make(0, 0));
}
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) {
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
#if SK_SUPPORT_GPU
SkBitmap input;
SkASSERT(fInputCount == 1);
if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, &input, offset)) {
if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, ctm, &input, offset)) {
return false;
}
GrTexture* srcTexture = input.getTexture();

View File

@ -21,17 +21,15 @@ bool SkImageFilterUtils::WrapTexture(GrTexture* texture, int width, int height,
}
bool SkImageFilterUtils::GetInputResultGPU(SkImageFilter* filter, SkImageFilter::Proxy* proxy,
const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) {
const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
if (!filter) {
*result = src;
return true;
} else if (filter->canFilterImageGPU()) {
return filter->filterImageGPU(proxy, src, result, offset);
return filter->filterImageGPU(proxy, src, ctm, result, offset);
} else {
SkMatrix matrix;
matrix.reset();
if (filter->filterImage(proxy, src, matrix, result, offset)) {
if (filter->filterImage(proxy, src, ctm, result, offset)) {
if (!result->getTexture()) {
GrContext* context = ((GrTexture *) src.getTexture())->getContext();
GrTexture* resultTex = GrLockAndRefCachedBitmapTexture(context,

View File

@ -341,9 +341,10 @@ GrEffectRef* GrBicubicEffect::TestCreate(SkMWCRandom* random,
return GrBicubicEffect::Create(textures[texIdx], coefficients);
}
bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result, SkIPoint* offset) {
bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
SkBitmap srcBM;
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &srcBM, offset)) {
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &srcBM, offset)) {
return false;
}
GrTexture* srcTexture = srcBM.getTexture();

View File

@ -206,11 +206,11 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
return true;
}
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) {
bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
#if SK_SUPPORT_GPU
SkBitmap input;
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &input, offset)) {
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &input, offset)) {
return false;
}
GrTexture* source = input.getTexture();

View File

@ -275,19 +275,19 @@ private:
typedef GrEffect INHERITED;
};
bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) {
bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
SkBitmap colorBM;
SkIPoint colorOffset = SkIPoint::Make(0, 0);
if (!SkImageFilterUtils::GetInputResultGPU(getColorInput(), proxy, src, &colorBM,
if (!SkImageFilterUtils::GetInputResultGPU(getColorInput(), proxy, src, ctm, &colorBM,
&colorOffset)) {
return false;
}
GrTexture* color = colorBM.getTexture();
SkBitmap displacementBM;
SkIPoint displacementOffset = SkIPoint::Make(0, 0);
if (!SkImageFilterUtils::GetInputResultGPU(getDisplacementInput(), proxy, src, &displacementBM,
&displacementOffset)) {
if (!SkImageFilterUtils::GetInputResultGPU(getDisplacementInput(), proxy, src, ctm,
&displacementBM, &displacementOffset)) {
return false;
}
GrTexture* displacement = displacementBM.getTexture();

View File

@ -502,10 +502,10 @@ GrTexture* apply_morphology(GrTexture* srcTexture,
};
bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) {
bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
SkBitmap inputBM;
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &inputBM, offset)) {
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &inputBM, offset)) {
return false;
}
GrTexture* input = inputBM.getTexture();
@ -516,10 +516,10 @@ bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBi
return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(), result);
}
bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
SkIPoint* offset) {
bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
SkBitmap inputBM;
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &inputBM, offset)) {
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &inputBM, offset)) {
return false;
}
GrTexture* input = inputBM.getTexture();

View File

@ -78,18 +78,19 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
const SkBitmap& src,
const SkMatrix& ctm,
SkBitmap* result,
SkIPoint* offset) {
SkBitmap background;
SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &background,
if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &background,
&backgroundOffset)) {
return false;
}
GrTexture* backgroundTex = background.getTexture();
SkBitmap foreground;
SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
if (!SkImageFilterUtils::GetInputResultGPU(getInput(1), proxy, src, &foreground,
if (!SkImageFilterUtils::GetInputResultGPU(getInput(1), proxy, src, ctm, &foreground,
&foregroundOffset)) {
return false;
}

View File

@ -1372,7 +1372,8 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
static bool filter_texture(SkDevice* device, GrContext* context,
GrTexture* texture, SkImageFilter* filter,
int w, int h, SkBitmap* result, SkIPoint* offset) {
int w, int h, const SkMatrix& ctm, SkBitmap* result,
SkIPoint* offset) {
GrAssert(filter);
SkDeviceImageFilterProxy proxy(device);
@ -1380,7 +1381,7 @@ static bool filter_texture(SkDevice* device, GrContext* context,
// Save the render target and set it to NULL, so we don't accidentally draw to it in the
// filter. Also set the clip wide open and the matrix to identity.
GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
return filter->filterImageGPU(&proxy, wrap_texture(texture), result, offset);
return filter->filterImageGPU(&proxy, wrap_texture(texture), ctm, result, offset);
} else {
return false;
}
@ -1409,7 +1410,8 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
SkBitmap filteredBitmap;
if (NULL != filter) {
if (filter_texture(this, fContext, texture, filter, w, h, &filteredBitmap, &offset)) {
if (filter_texture(this, fContext, texture, filter, w, h, SkMatrix::I(), &filteredBitmap,
&offset)) {
texture = (GrTexture*) filteredBitmap.getTexture();
w = filteredBitmap.width();
h = filteredBitmap.height();
@ -1494,7 +1496,8 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
if (NULL != filter) {
SkIPoint offset = SkIPoint::Make(0, 0);
if (filter_texture(this, fContext, devTex, filter, w, h, &filteredBitmap, &offset)) {
if (filter_texture(this, fContext, devTex, filter, w, h, SkMatrix::I(), &filteredBitmap,
&offset)) {
devTex = filteredBitmap.getTexture();
w = filteredBitmap.width();
h = filteredBitmap.height();
@ -1547,7 +1550,8 @@ bool SkGpuDevice::filterImage(SkImageFilter* filter, const SkBitmap& src,
// must be pushed upstack.
SkAutoCachedTexture act(this, src, NULL, &texture);
return filter_texture(this, fContext, texture, filter, src.width(), src.height(), result, offset);
return filter_texture(this, fContext, texture, filter, src.width(), src.height(), ctm, result,
offset);
}
///////////////////////////////////////////////////////////////////////////////