Upstreaming DropShadowImageFilter into skia, from Blink
GM imagefiltersbase will need rebaselining after this change R=senorblanco@chromium.org Committed: https://code.google.com/p/skia/source/detail?r=10583 Review URL: https://codereview.chromium.org/22258005 git-svn-id: http://skia.googlecode.com/svn/trunk@10626 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
d79277f678
commit
f44fcdca01
@ -13,6 +13,7 @@
|
||||
|
||||
#include "SkBlurImageFilter.h"
|
||||
#include "SkColorFilterImageFilter.h"
|
||||
#include "SkDropShadowImageFilter.h"
|
||||
#include "SkTestImageFilters.h"
|
||||
|
||||
class FailImageFilter : public SkImageFilter {
|
||||
@ -156,7 +157,7 @@ protected:
|
||||
return SkString("imagefiltersbase");
|
||||
}
|
||||
|
||||
virtual SkISize onISize() { return SkISize::Make(700, 460); }
|
||||
virtual SkISize onISize() { return SkISize::Make(700, 500); }
|
||||
|
||||
void draw_frame(SkCanvas* canvas, const SkRect& r) {
|
||||
SkPaint paint;
|
||||
@ -189,6 +190,7 @@ protected:
|
||||
new FailImageFilter,
|
||||
SkColorFilterImageFilter::Create(cf),
|
||||
new SkBlurImageFilter(12.0f, 0.0f),
|
||||
new SkDropShadowImageFilter(10.0f, 5.0f, 3.0f, SK_ColorBLUE),
|
||||
};
|
||||
cf->unref();
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
'<(skia_src_path)/effects/SkDashPathEffect.cpp',
|
||||
'<(skia_src_path)/effects/SkDiscretePathEffect.cpp',
|
||||
'<(skia_src_path)/effects/SkDisplacementMapEffect.cpp',
|
||||
'<(skia_src_path)/effects/SkDropShadowImageFilter.cpp',
|
||||
'<(skia_src_path)/effects/SkEmbossMask.cpp',
|
||||
'<(skia_src_path)/effects/SkEmbossMask.h',
|
||||
'<(skia_src_path)/effects/SkEmbossMask_Table.h',
|
||||
@ -90,6 +91,7 @@
|
||||
'<(skia_include_path)/effects/SkDiscretePathEffect.h',
|
||||
'<(skia_include_path)/effects/SkDisplacementMapEffect.h',
|
||||
'<(skia_include_path)/effects/SkDrawExtraPathEffect.h',
|
||||
'<(skia_include_path)/effects/SkDropShadowImageFilter.h',
|
||||
'<(skia_include_path)/effects/SkEmbossMaskFilter.h',
|
||||
'<(skia_include_path)/effects/SkGradientShader.h',
|
||||
'<(skia_include_path)/effects/SkKernel33MaskFilter.h',
|
||||
|
26
include/effects/SkDropShadowImageFilter.h
Normal file
26
include/effects/SkDropShadowImageFilter.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkColor.h"
|
||||
#include "SkImageFilter.h"
|
||||
#include "SkScalar.h"
|
||||
|
||||
class SK_API SkDropShadowImageFilter : public SkImageFilter {
|
||||
public:
|
||||
SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor, SkImageFilter* input = NULL);
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
|
||||
|
||||
protected:
|
||||
explicit SkDropShadowImageFilter(SkFlattenableReadBuffer&);
|
||||
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
||||
virtual bool onFilterImage(Proxy*, const SkBitmap& source, const SkMatrix&, SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkScalar fDx, fDy, fSigma;
|
||||
SkColor fColor;
|
||||
typedef SkImageFilter INHERITED;
|
||||
};
|
63
src/effects/SkDropShadowImageFilter.cpp
Normal file
63
src/effects/SkDropShadowImageFilter.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkDropShadowImageFilter.h"
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBlurImageFilter.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorMatrixFilter.h"
|
||||
#include "SkDevice.h"
|
||||
#include "SkFlattenableBuffers.h"
|
||||
|
||||
SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor color, SkImageFilter* input)
|
||||
: SkImageFilter(input)
|
||||
, fDx(dx)
|
||||
, fDy(dy)
|
||||
, fSigma(sigma)
|
||||
, fColor(color)
|
||||
{
|
||||
}
|
||||
|
||||
SkDropShadowImageFilter::SkDropShadowImageFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer)
|
||||
{
|
||||
fDx = buffer.readScalar();
|
||||
fDy = buffer.readScalar();
|
||||
fSigma = buffer.readScalar();
|
||||
fColor = buffer.readColor();
|
||||
}
|
||||
|
||||
void SkDropShadowImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const
|
||||
{
|
||||
this->INHERITED::flatten(buffer);
|
||||
buffer.writeScalar(fDx);
|
||||
buffer.writeScalar(fDy);
|
||||
buffer.writeScalar(fSigma);
|
||||
buffer.writeColor(fColor);
|
||||
}
|
||||
|
||||
bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc)
|
||||
{
|
||||
SkBitmap src = source;
|
||||
if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc))
|
||||
return false;
|
||||
|
||||
SkAutoTUnref<SkDevice> device(proxy->createDevice(src.width(), src.height()));
|
||||
SkCanvas canvas(device.get());
|
||||
|
||||
SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigma, fSigma));
|
||||
SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fColor, SkXfermode::kSrcIn_Mode));
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(blurFilter.get());
|
||||
paint.setColorFilter(colorFilter.get());
|
||||
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
canvas.drawBitmap(src, fDx, fDy, &paint);
|
||||
canvas.drawBitmap(src, 0, 0);
|
||||
*result = device->accessBitmap(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "SkDataSet.h"
|
||||
#include "SkDiscretePathEffect.h"
|
||||
#include "SkDisplacementMapEffect.h"
|
||||
#include "SkDropShadowImageFilter.h"
|
||||
#include "SkEmptyShader.h"
|
||||
#include "SkEmbossMaskFilter.h"
|
||||
#include "SkFlattenable.h"
|
||||
@ -78,6 +79,7 @@ void SkFlattenable::InitializeFlattenables() {
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDisplacementMapEffect)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDropShadowImageFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmbossMaskFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmptyShader)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkErodeImageFilter)
|
||||
|
Loading…
Reference in New Issue
Block a user