mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1259621 - use AlphaBoxBlur in DrawTargetSkia::DrawSurfaceWithShadow. r=mchang
This commit is contained in:
parent
9393c2c705
commit
4c1b0ad4f8
@ -17,6 +17,7 @@
|
||||
#include "skia/include/core/SkColorFilter.h"
|
||||
#include "skia/include/effects/SkBlurImageFilter.h"
|
||||
#include "skia/include/effects/SkLayerRasterizer.h"
|
||||
#include "Blur.h"
|
||||
#include "Logging.h"
|
||||
#include "Tools.h"
|
||||
#include "DataSurfaceHelpers.h"
|
||||
@ -432,16 +433,37 @@ DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface *aSurface,
|
||||
// to blur the image ourselves.
|
||||
|
||||
SkPaint shadowPaint;
|
||||
SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(aSigma, aSigma));
|
||||
SkAutoTUnref<SkColorFilter> colorFilter(
|
||||
SkColorFilter::CreateModeFilter(ColorToSkColor(aColor, 1.0), SkXfermode::kSrcIn_Mode));
|
||||
|
||||
shadowPaint.setXfermode(paint.getXfermode());
|
||||
shadowPaint.setImageFilter(blurFilter.get());
|
||||
shadowPaint.setColorFilter(colorFilter.get());
|
||||
|
||||
IntPoint shadowDest = RoundedToInt(aDest + aOffset);
|
||||
mCanvas->drawBitmap(bitmap, shadowDest.x, shadowDest.y, &shadowPaint);
|
||||
|
||||
SkBitmap blurMask;
|
||||
if (!UsingSkiaGPU() &&
|
||||
bitmap.extractAlpha(&blurMask)) {
|
||||
// Prefer using our own box blur instead of Skia's when we're
|
||||
// not using the GPU. It currently performs much better than
|
||||
// SkBlurImageFilter or SkBlurMaskFilter on the CPU.
|
||||
AlphaBoxBlur blur(Rect(0, 0, blurMask.width(), blurMask.height()),
|
||||
int32_t(blurMask.rowBytes()),
|
||||
aSigma, aSigma);
|
||||
blurMask.lockPixels();
|
||||
blur.Blur(reinterpret_cast<uint8_t*>(blurMask.getPixels()));
|
||||
blurMask.unlockPixels();
|
||||
blurMask.notifyPixelsChanged();
|
||||
|
||||
shadowPaint.setColor(ColorToSkColor(aColor, 1.0f));
|
||||
|
||||
mCanvas->drawBitmap(blurMask, shadowDest.x, shadowDest.y, &shadowPaint);
|
||||
} else {
|
||||
SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(aSigma, aSigma));
|
||||
SkAutoTUnref<SkColorFilter> colorFilter(
|
||||
SkColorFilter::CreateModeFilter(ColorToSkColor(aColor, 1.0f), SkXfermode::kSrcIn_Mode));
|
||||
|
||||
shadowPaint.setImageFilter(blurFilter.get());
|
||||
shadowPaint.setColorFilter(colorFilter.get());
|
||||
|
||||
mCanvas->drawBitmap(bitmap, shadowDest.x, shadowDest.y, &shadowPaint);
|
||||
}
|
||||
|
||||
// Composite the original image after the shadow
|
||||
IntPoint dest = RoundedToInt(aDest);
|
||||
|
Loading…
Reference in New Issue
Block a user