Thread GrShaderDataManager through Image filters
TBR=bsalomon@google.com BUG=skia: Review URL: https://codereview.chromium.org/1229613002
This commit is contained in:
parent
711a245dda
commit
85ff25e8d9
@ -16,6 +16,7 @@
|
|||||||
#include "SkTemplates.h"
|
#include "SkTemplates.h"
|
||||||
|
|
||||||
class GrFragmentProcessor;
|
class GrFragmentProcessor;
|
||||||
|
class GrShaderDataManager;
|
||||||
class GrTexture;
|
class GrTexture;
|
||||||
class SkBaseDevice;
|
class SkBaseDevice;
|
||||||
class SkBitmap;
|
class SkBitmap;
|
||||||
@ -340,8 +341,8 @@ protected:
|
|||||||
* will be called with (NULL, NULL, SkMatrix::I()) to query for support,
|
* will be called with (NULL, NULL, SkMatrix::I()) to query for support,
|
||||||
* so returning "true" indicates support for all possible matrices.
|
* so returning "true" indicates support for all possible matrices.
|
||||||
*/
|
*/
|
||||||
virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
|
virtual bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*,
|
||||||
const SkIRect& bounds) const;
|
const SkMatrix&, const SkIRect& bounds) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SkGraphics;
|
friend class SkGraphics;
|
||||||
|
@ -23,11 +23,11 @@ protected:
|
|||||||
SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input);
|
SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input);
|
||||||
void flatten(SkWriteBuffer&) const override;
|
void flatten(SkWriteBuffer&) const override;
|
||||||
|
|
||||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||||
SkBitmap* result, SkIPoint* offset) const override;
|
SkBitmap* result, SkIPoint* offset) const override;
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
|
bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*,
|
||||||
const SkIRect& bounds) const override;
|
const SkMatrix&, const SkIRect& bounds) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -77,14 +77,14 @@ protected:
|
|||||||
const CropRect* cropRect);
|
const CropRect* cropRect);
|
||||||
void flatten(SkWriteBuffer&) const override;
|
void flatten(SkWriteBuffer&) const override;
|
||||||
|
|
||||||
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||||
SkBitmap* result, SkIPoint* loc) const override;
|
SkBitmap* result, SkIPoint* loc) const override;
|
||||||
bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override;
|
bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override;
|
||||||
|
|
||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
|
bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*,
|
||||||
const SkIRect& bounds) const override;
|
const SkMatrix&, const SkIRect& bounds) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -232,7 +232,7 @@ bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SkImageFilter::canFilterImageGPU() const {
|
bool SkImageFilter::canFilterImageGPU() const {
|
||||||
return this->asFragmentProcessor(NULL, NULL, SkMatrix::I(), SkIRect());
|
return this->asFragmentProcessor(NULL, NULL, NULL, SkMatrix::I(), SkIRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
||||||
@ -275,9 +275,9 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
|
|||||||
bounds.offset(-srcOffset);
|
bounds.offset(-srcOffset);
|
||||||
SkMatrix matrix(ctx.ctm());
|
SkMatrix matrix(ctx.ctm());
|
||||||
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
|
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
|
||||||
if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) {
|
|
||||||
SkASSERT(fp);
|
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
|
if (this->asFragmentProcessor(&fp, paint.getShaderDataManager(), srcTexture, matrix, bounds)) {
|
||||||
|
SkASSERT(fp);
|
||||||
paint.addColorProcessor(fp)->unref();
|
paint.addColorProcessor(fp)->unref();
|
||||||
|
|
||||||
GrDrawContext* drawContext = context->drawContext();
|
GrDrawContext* drawContext = context->drawContext();
|
||||||
@ -374,8 +374,8 @@ bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
|
bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*,
|
||||||
const SkIRect&) const {
|
const SkMatrix&, const SkIRect&) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ protected:
|
|||||||
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
||||||
SkBitmap* result, SkIPoint* offset) const override;
|
SkBitmap* result, SkIPoint* offset) const override;
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
|
bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrTexture*,
|
||||||
const SkIRect& bounds) const override;
|
const SkMatrix&, const SkIRect& bounds) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -265,6 +265,7 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
|
|||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
|
bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
|
||||||
|
GrShaderDataManager*,
|
||||||
GrTexture* texture,
|
GrTexture* texture,
|
||||||
const SkMatrix& in_matrix,
|
const SkMatrix& in_matrix,
|
||||||
const SkIRect&) const {
|
const SkIRect&) const {
|
||||||
|
@ -276,8 +276,9 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, GrTexture* texture,
|
bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, GrShaderDataManager*,
|
||||||
const SkMatrix&, const SkIRect&bounds) const {
|
GrTexture* texture, const SkMatrix&,
|
||||||
|
const SkIRect&bounds) const {
|
||||||
if (fp) {
|
if (fp) {
|
||||||
SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcRect.y() :
|
SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcRect.y() :
|
||||||
texture->height() - fSrcRect.height() * texture->height() / bounds.height()
|
texture->height() - fSrcRect.height() * texture->height() / bounds.height()
|
||||||
|
@ -348,6 +348,7 @@ static GrTextureDomain::Mode convert_tilemodes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SkMatrixConvolutionImageFilter::asFragmentProcessor(GrFragmentProcessor** fp,
|
bool SkMatrixConvolutionImageFilter::asFragmentProcessor(GrFragmentProcessor** fp,
|
||||||
|
GrShaderDataManager*,
|
||||||
GrTexture* texture,
|
GrTexture* texture,
|
||||||
const SkMatrix&,
|
const SkMatrix&,
|
||||||
const SkIRect& bounds) const {
|
const SkIRect& bounds) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user