mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1089177, part 1 - Expose PatternFromState to help with Moz2D porting. r=mattwoodrow
This commit is contained in:
parent
d6bd4e18e3
commit
99eeb78806
@ -36,22 +36,16 @@ using namespace mozilla::gfx;
|
||||
|
||||
UserDataKey gfxContext::sDontUseAsSourceKey;
|
||||
|
||||
/* This class lives on the stack and allows gfxContext users to easily, and
|
||||
* performantly get a gfx::Pattern to use for drawing in their current context.
|
||||
*/
|
||||
class PatternFromState
|
||||
{
|
||||
public:
|
||||
explicit PatternFromState(gfxContext *aContext) : mContext(aContext), mPattern(nullptr) {}
|
||||
~PatternFromState() { if (mPattern) { mPattern->~Pattern(); } }
|
||||
|
||||
operator mozilla::gfx::Pattern&()
|
||||
PatternFromState::operator mozilla::gfx::Pattern&()
|
||||
{
|
||||
gfxContext::AzureState &state = mContext->CurrentState();
|
||||
|
||||
if (state.pattern) {
|
||||
return *state.pattern->GetPattern(mContext->mDT, state.patternTransformChanged ? &state.patternTransform : nullptr);
|
||||
} else if (state.sourceSurface) {
|
||||
}
|
||||
|
||||
if (state.sourceSurface) {
|
||||
Matrix transform = state.surfTransform;
|
||||
|
||||
if (state.patternTransformChanged) {
|
||||
@ -67,22 +61,13 @@ public:
|
||||
mPattern = new (mSurfacePattern.addr())
|
||||
SurfacePattern(state.sourceSurface, ExtendMode::CLAMP, transform);
|
||||
return *mPattern;
|
||||
} else {
|
||||
}
|
||||
|
||||
mPattern = new (mColorPattern.addr())
|
||||
ColorPattern(state.color);
|
||||
return *mPattern;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
union {
|
||||
mozilla::AlignedStorage2<mozilla::gfx::ColorPattern> mColorPattern;
|
||||
mozilla::AlignedStorage2<mozilla::gfx::SurfacePattern> mSurfacePattern;
|
||||
};
|
||||
|
||||
gfxContext *mContext;
|
||||
Pattern *mPattern;
|
||||
};
|
||||
|
||||
gfxContext::gfxContext(DrawTarget *aTarget, const Point& aDeviceOffset)
|
||||
: mPathIsRect(false)
|
||||
|
@ -844,4 +844,25 @@ private:
|
||||
bool mSubpixelAntialiasingEnabled;
|
||||
};
|
||||
|
||||
/* This class lives on the stack and allows gfxContext users to easily, and
|
||||
* performantly get a gfx::Pattern to use for drawing in their current context.
|
||||
*/
|
||||
class PatternFromState
|
||||
{
|
||||
public:
|
||||
explicit PatternFromState(gfxContext *aContext) : mContext(aContext), mPattern(nullptr) {}
|
||||
~PatternFromState() { if (mPattern) { mPattern->~Pattern(); } }
|
||||
|
||||
operator mozilla::gfx::Pattern&();
|
||||
|
||||
private:
|
||||
union {
|
||||
mozilla::AlignedStorage2<mozilla::gfx::ColorPattern> mColorPattern;
|
||||
mozilla::AlignedStorage2<mozilla::gfx::SurfacePattern> mSurfacePattern;
|
||||
};
|
||||
|
||||
gfxContext *mContext;
|
||||
mozilla::gfx::Pattern *mPattern;
|
||||
};
|
||||
|
||||
#endif /* GFX_CONTEXT_H */
|
||||
|
Loading…
Reference in New Issue
Block a user