Bug 1168527 - Add support to gfxContext for clip exporting. r=jrmuizel

--HG--
extra : rebase_source : 3747753f0285a9fe9803d851b234744603e2e0f4
extra : histedit_source : 73abebe3363945850bc42d17144cb0e90e184a7e
This commit is contained in:
Andrew Comminos 2015-06-09 13:46:09 -04:00
Родитель fabe78f38d
Коммит 198ba930fe
2 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -636,6 +636,40 @@ gfxContext::HasComplexClip() const
return false;
}
bool
gfxContext::ExportClip(ClipExporter& aExporter)
{
unsigned int lastReset = 0;
for (int i = mStateStack.Length() - 1; i > 0; i--) {
if (mStateStack[i].clipWasReset) {
lastReset = i;
break;
}
}
for (unsigned int i = lastReset; i < mStateStack.Length(); i++) {
for (unsigned int c = 0; c < mStateStack[i].pushedClips.Length(); c++) {
AzureState::PushedClip &clip = mStateStack[i].pushedClips[c];
gfx::Matrix transform = clip.transform;
transform.PostTranslate(-GetDeviceOffset());
aExporter.BeginClip(transform);
if (clip.path) {
clip.path->StreamToSink(&aExporter);
} else {
aExporter.MoveTo(clip.rect.TopLeft());
aExporter.LineTo(clip.rect.TopRight());
aExporter.LineTo(clip.rect.BottomRight());
aExporter.LineTo(clip.rect.BottomLeft());
aExporter.Close();
}
aExporter.EndClip();
}
}
return true;
}
bool
gfxContext::ClipContainsRect(const gfxRect& aRect)
{

Просмотреть файл

@ -28,6 +28,8 @@ struct RectCornerRadii;
}
}
class ClipExporter;
/**
* This is the main class for doing actual drawing. It is initialized using
* a surface and can be drawn on. It manages various state information like
@ -457,6 +459,11 @@ public:
*/
bool ClipContainsRect(const gfxRect& aRect);
/**
* Exports the current clip using the provided exporter.
*/
bool ExportClip(ClipExporter& aExporter);
/**
* Groups
*/
@ -728,4 +735,12 @@ private:
mozilla::gfx::Pattern *mPattern;
};
/* This interface should be implemented to handle exporting the clip from a context.
*/
class ClipExporter : public mozilla::gfx::PathSink {
public:
virtual void BeginClip(const mozilla::gfx::Matrix& aMatrix) = 0;
virtual void EndClip() = 0;
};
#endif /* GFX_CONTEXT_H */