mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1161642 - Utilize primitive blends where available for faster blending on D2D 1.1. r=bas
This commit is contained in:
parent
9bc9a44e62
commit
a5dc2315a8
@ -944,12 +944,16 @@ DrawTargetD2D1::PrepareForDrawing(CompositionOp aOp, const Pattern &aPattern)
|
||||
{
|
||||
MarkChanged();
|
||||
|
||||
if (aOp == CompositionOp::OP_OVER && IsPatternSupportedByD2D(aPattern)) {
|
||||
if (D2DSupportsPrimitiveBlendMode(aOp) && IsPatternSupportedByD2D(aPattern)) {
|
||||
// It's important to do this before FlushTransformToDC! As this will cause
|
||||
// the transform to become dirty.
|
||||
PushAllClips();
|
||||
|
||||
FlushTransformToDC();
|
||||
|
||||
if (aOp != CompositionOp::OP_OVER)
|
||||
mDC->SetPrimitiveBlend(D2DPrimitiveBlendMode(aOp));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -967,7 +971,9 @@ DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern)
|
||||
{
|
||||
bool patternSupported = IsPatternSupportedByD2D(aPattern);
|
||||
|
||||
if (aOp == CompositionOp::OP_OVER && patternSupported) {
|
||||
if (D2DSupportsPrimitiveBlendMode(aOp) && patternSupported) {
|
||||
if (aOp != CompositionOp::OP_OVER)
|
||||
mDC->SetPrimitiveBlend(D2D1_PRIMITIVE_BLEND_SOURCE_OVER);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <dwrite.h>
|
||||
#include <VersionHelpers.h>
|
||||
#include "2D.h"
|
||||
#include "Logging.h"
|
||||
#include "Tools.h"
|
||||
@ -272,6 +273,41 @@ static inline D2D1_BLEND_MODE D2DBlendMode(CompositionOp aOp)
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool D2DSupportsPrimitiveBlendMode(CompositionOp aOp)
|
||||
{
|
||||
switch (aOp) {
|
||||
case CompositionOp::OP_OVER:
|
||||
// case CompositionOp::OP_SOURCE:
|
||||
return true;
|
||||
// case CompositionOp::OP_DARKEN:
|
||||
case CompositionOp::OP_ADD:
|
||||
return IsWindows8Point1OrGreater();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline D2D1_PRIMITIVE_BLEND D2DPrimitiveBlendMode(CompositionOp aOp)
|
||||
{
|
||||
switch (aOp) {
|
||||
case CompositionOp::OP_OVER:
|
||||
return D2D1_PRIMITIVE_BLEND_SOURCE_OVER;
|
||||
// D2D1_PRIMITIVE_BLEND_COPY should leave pixels out of the source's
|
||||
// bounds unchanged, but doesn't- breaking unbounded ops.
|
||||
// D2D1_PRIMITIVE_BLEND_MIN doesn't quite work like darken either, as it
|
||||
// accounts for the source alpha.
|
||||
//
|
||||
// case CompositionOp::OP_SOURCE:
|
||||
// return D2D1_PRIMITIVE_BLEND_COPY;
|
||||
// case CompositionOp::OP_DARKEN:
|
||||
// return D2D1_PRIMITIVE_BLEND_MIN;
|
||||
case CompositionOp::OP_ADD:
|
||||
return D2D1_PRIMITIVE_BLEND_ADD;
|
||||
default:
|
||||
return D2D1_PRIMITIVE_BLEND_SOURCE_OVER;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsPatternSupportedByD2D(const Pattern &aPattern)
|
||||
{
|
||||
if (aPattern.GetType() != PatternType::RADIAL_GRADIENT) {
|
||||
|
Loading…
Reference in New Issue
Block a user