Add push/pop translation functions to nsIRenderingContext

RESOLVED FIXED

Status

RESOLVED FIXED
14 years ago
10 years ago

People

(Reporter: roc, Assigned: roc)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

In a couple of places frames need to save and restore the current translation in
the rendering context while they paint a child. We don't use PushState/PopState
because those do a lot more work than we really need to do. We can't just apply
a negative translation at the end because roundoff errors can accumulate.
Instead we save and restore part of the translation matrix. This causes problems
for Cairo since Cairo doesn't have a translation matrix; what actually happens
is that it conses up a fake one, and when frames poke the translation matrix to
restore the old translation, that has no effect.
Created attachment 180776 [details] [diff] [review]
fix

This just moves the save and restore code behind virtual functions in
nsIRenderingContext so that I can override them to do something else in
nsCairoRenderingContext.
Attachment #180776 - Flags: superreview?(bzbarsky)
Attachment #180776 - Flags: review?(bzbarsky)
Comment on attachment 180776 [details] [diff] [review]
fix

>Index: gfx/public/nsIRenderingContext.h

>+  struct PushedTranslation {
>+    float mSavedX, mSavedY;
>+  };
>+  NS_IMETHOD PushTranslation(PushedTranslation* aState) = 0;
>+
>+  NS_IMETHOD PopTranslation(PushedTranslation* aState) = 0;

Is there a reason to have PopTranslation called manually instead of having the
PushedTranslation destructor pop?  The latter can't be forgotten and all...

>Index: gfx/src/shared/nsRenderingContextImpl.cpp

> nsRenderingContextImpl::PushTranslation(PushedTranslation* aState)

NS_PRECONDITION(aState, ...)

> nsRenderingContextImpl::PopTranslation(PushedTranslation* aState)

NS_PRECONDITION(aState, ....)

r+sr=bzbarsky, with either approach on popping...
Attachment #180776 - Flags: superreview?(bzbarsky)
Attachment #180776 - Flags: superreview+
Attachment #180776 - Flags: review?(bzbarsky)
Attachment #180776 - Flags: review+
Created attachment 181100 [details] [diff] [review]
fix #2

OK, here's the patch with an auto-object to do the popping.
Attachment #180776 - Attachment is obsolete: true
Attachment #181100 - Flags: superreview?(bzbarsky)
Attachment #181100 - Flags: review?(bzbarsky)
Comment on attachment 181100 [details] [diff] [review]
fix #2

Looks good.
Attachment #181100 - Flags: superreview?(bzbarsky)
Attachment #181100 - Flags: superreview+
Attachment #181100 - Flags: review?(bzbarsky)
Attachment #181100 - Flags: review+
Comment on attachment 181100 [details] [diff] [review]
fix #2

Modest code refactoring that should have no effect on the regular builds but is
needed for Cairo Gfx to work.
Attachment #181100 - Flags: approval1.8b2?
*** Bug 290903 has been marked as a duplicate of this bug. ***

Comment 7

14 years ago
Comment on attachment 181100 [details] [diff] [review]
fix #2

a=asa
Attachment #181100 - Flags: approval1.8b2? → approval1.8b2+
checked in
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED

Updated

14 years ago
Blocks: 291058
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.