Closed Bug 290432 Opened 19 years ago Closed 19 years ago

Add push/pop translation functions to nsIRenderingContext

Categories

(Core Graveyard :: GFX, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: roc, Assigned: roc)

References

Details

Attachments

(1 file, 1 obsolete file)

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.
Attached patch fix (obsolete) — Splinter Review
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+
Attached patch fix #2Splinter Review
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 on attachment 181100 [details] [diff] [review]
fix #2

a=asa
Attachment #181100 - Flags: approval1.8b2? → approval1.8b2+
checked in
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Blocks: 291058
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: