mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 924102 - Make DrawTargetSkia::DrawSurface support non-Skia DataSourceSurfaces. r=mstange
This commit is contained in:
parent
217a24a67f
commit
a6010e3f33
@ -153,6 +153,26 @@ DrawTargetSkia::PurgeTextureCaches()
|
||||
|
||||
#endif
|
||||
|
||||
static SkBitmap
|
||||
GetBitmapForSurface(SourceSurface *aSurface)
|
||||
{
|
||||
switch (aSurface->GetType()) {
|
||||
case SURFACE_SKIA:
|
||||
return static_cast<SourceSurfaceSkia*>(aSurface)->GetBitmap();
|
||||
case SURFACE_DATA:
|
||||
{
|
||||
DataSourceSurface* surf = static_cast<DataSourceSurface*>(aSurface);
|
||||
SkBitmap tmp;
|
||||
tmp.setConfig(GfxFormatToSkiaConfig(surf->GetFormat()),
|
||||
surf->GetSize().width, surf->GetSize().height, surf->Stride());
|
||||
tmp.setPixels(surf->GetData());
|
||||
return tmp;
|
||||
}
|
||||
default:
|
||||
MOZ_CRASH("Non-skia SourceSurfaces need to be DataSourceSurfaces");
|
||||
}
|
||||
}
|
||||
|
||||
DrawTargetSkia::DrawTargetSkia()
|
||||
: mSnapshot(nullptr)
|
||||
{
|
||||
@ -247,7 +267,7 @@ void SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, Float aAlpha = 1.
|
||||
}
|
||||
case PATTERN_SURFACE: {
|
||||
const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
|
||||
const SkBitmap& bitmap = static_cast<SourceSurfaceSkia*>(pat.mSurface.get())->GetBitmap();
|
||||
const SkBitmap& bitmap = GetBitmapForSurface(pat.mSurface);
|
||||
|
||||
SkShader::TileMode mode = ExtendModeToTileMode(pat.mExtendMode);
|
||||
SkShader* shader = SkShader::CreateBitmapShader(bitmap, mode, mode);
|
||||
@ -334,10 +354,6 @@ DrawTargetSkia::DrawSurface(SourceSurface *aSurface,
|
||||
const DrawSurfaceOptions &aSurfOptions,
|
||||
const DrawOptions &aOptions)
|
||||
{
|
||||
if (aSurface->GetType() != SURFACE_SKIA) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aSource.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -356,7 +372,7 @@ DrawTargetSkia::DrawSurface(SourceSurface *aSurface,
|
||||
SkRect sourceBoundingRect = RectToSkRect(boundingSource);
|
||||
SkIRect sourceBoundingIRect = RectToSkIRect(boundingSource);
|
||||
|
||||
const SkBitmap& bitmap = static_cast<SourceSurfaceSkia*>(aSurface)->GetBitmap();
|
||||
const SkBitmap& bitmap = GetBitmapForSurface(aSurface);
|
||||
|
||||
AutoPaintSetup paint(mCanvas.get(), aOptions);
|
||||
if (aSurfOptions.mFilter == FILTER_POINT) {
|
||||
@ -397,7 +413,7 @@ DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface *aSurface,
|
||||
|
||||
uint32_t blurFlags = SkBlurMaskFilter::kHighQuality_BlurFlag |
|
||||
SkBlurMaskFilter::kIgnoreTransform_BlurFlag;
|
||||
const SkBitmap& bitmap = static_cast<SourceSurfaceSkia*>(aSurface)->GetBitmap();
|
||||
const SkBitmap& bitmap = GetBitmapForSurface(aSurface);
|
||||
SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
|
||||
SkMatrix matrix;
|
||||
matrix.reset();
|
||||
@ -698,7 +714,7 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
|
||||
|
||||
MarkChanged();
|
||||
|
||||
const SkBitmap& bitmap = static_cast<SourceSurfaceSkia*>(aSurface)->GetBitmap();
|
||||
const SkBitmap& bitmap = GetBitmapForSurface(aSurface);
|
||||
|
||||
mCanvas->save();
|
||||
mCanvas->resetMatrix();
|
||||
|
Loading…
Reference in New Issue
Block a user