diff --git a/mozilla/gfx/thebes/public/gfxContext.h b/mozilla/gfx/thebes/public/gfxContext.h index 31a24339079..f0475630e17 100644 --- a/mozilla/gfx/thebes/public/gfxContext.h +++ b/mozilla/gfx/thebes/public/gfxContext.h @@ -475,6 +475,12 @@ public: void Clip(gfxRect rect); // will clip to a rect void Clip(const gfxRegion& region); // will clip to a region + /** + * This will ensure that the surface actually has its clip set. + * Useful if you are doing native drawing. + */ + void UpdateSurfaceClip(); + /** * Groups */ @@ -488,26 +494,6 @@ public: gfxPattern *PopGroup(); void PopGroupToSource(); - /** - ** Filters/Group Rendering - ** XXX these aren't really "filters" and should be renamed properly. - **/ - enum FilterHints { - // Future drawing will completely cover the specified maxArea - FILTER_OPAQUE_DRAW - }; - - /** - * Start rendering under the filter. We guarantee not to draw outside 'maxArea'. - */ - void PushFilter(gfxFilter& filter, FilterHints hints, gfxRect& maxArea); - - /** - * Completed rendering under the filter, composite what we rendered back to the - * underlying surface using the filter. - */ - void PopFilter(); - /** * Printing functions */ diff --git a/mozilla/gfx/thebes/src/gfxContext.cpp b/mozilla/gfx/thebes/src/gfxContext.cpp index 2622d35b5c6..0c1eb5a6515 100644 --- a/mozilla/gfx/thebes/src/gfxContext.cpp +++ b/mozilla/gfx/thebes/src/gfxContext.cpp @@ -466,6 +466,12 @@ void gfxContext::ResetClip() cairo_reset_clip(mCairo); } +void gfxContext::UpdateSurfaceClip() +{ + NewPath(); + Rectangle(gfxRect(0,0,0,0)); + Fill(); +} // rendering sources @@ -525,17 +531,6 @@ void gfxContext::PopGroupToSource() cairo_pop_group_to_source(mCairo); } -// filters -void gfxContext::PushFilter(gfxFilter& filter, FilterHints hints, gfxRect& maxArea) -{ - -} - -void gfxContext::PopFilter() -{ - -} - void gfxContext::BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName) { mSurface->BeginPrinting(aTitle, aPrintToFileName); diff --git a/mozilla/layout/generic/Makefile.in b/mozilla/layout/generic/Makefile.in index eeb8fd4afb6..b274597f7c5 100644 --- a/mozilla/layout/generic/Makefile.in +++ b/mozilla/layout/generic/Makefile.in @@ -49,6 +49,8 @@ REQUIRES = xpcom \ string \ dom \ content \ + thebes \ + cairo \ gfx \ widget \ locale \ diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 81279ff04f4..5f373d6e57d 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -119,6 +119,10 @@ #include "nsPIPluginHost.h" #include "nsIPluginDocument.h" +#ifdef MOZ_CAIRO_GFX +#include "gfxContext.h" +#endif + // accessibility support #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" @@ -1095,8 +1099,27 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext, PRBool doupdatewindow = PR_FALSE; // check if we need to update hdc - void* hdc; - hdc = aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_WINDOWS_DC); + HDC hdc = (HDC)aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_WINDOWS_DC); + +#ifdef MOZ_CAIRO_GFX + SaveDC(hdc); + + nsRefPtr ctx = (gfxContext*)aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT); + nsRefPtr surf = ctx->CurrentGroupSurface(); + if (!surf) + surf = ctx->CurrentSurface(); + + /* Need to force the clip to be set */ + ctx->UpdateSurfaceClip(); + + /* Set the device offsets as appropriate */ + gfxFloat xoff, yoff; + POINT origViewportOrigin; + surf->GetDeviceOffset(&xoff, &yoff); + GetViewportOrgEx(hdc, &origViewportOrigin); + SetViewportOrgEx(hdc, origViewportOrigin.x + (int) xoff, origViewportOrigin.y + (int) yoff, NULL); +#endif + if (NS_REINTERPRET_CAST(PRUint32, window->window) != (PRUint32)(HDC)hdc) { window->window = NS_REINTERPRET_CAST(nsPluginPort*, hdc); doupdatewindow = PR_TRUE; @@ -1178,6 +1201,12 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext, // XXX I wonder if this breaks if we give the frame a border so the // frame origin and plugin origin are not the same mInstanceOwner->Paint(aDirtyRect, (PRUint32)(HDC)hdc); + +#ifdef MOZ_CAIRO_GFX + RestoreDC(hdc, -1); + + surf->MarkDirty(); +#endif } } #endif /* !XP_MAC */ diff --git a/mozilla/widget/src/windows/nsNativeThemeWin.cpp b/mozilla/widget/src/windows/nsNativeThemeWin.cpp index 54a0ac7bca1..d26264bac43 100644 --- a/mozilla/widget/src/windows/nsNativeThemeWin.cpp +++ b/mozilla/widget/src/windows/nsNativeThemeWin.cpp @@ -770,9 +770,7 @@ nsNativeThemeWin::DrawWidgetBackground(nsIRenderingContext* aContext, SetGraphicsMode(hdc, GM_ADVANCED); /* Need to force the clip to be set */ - ctx->NewPath(); - ctx->Rectangle(gfxRect(0,0,0,0)); - ctx->Fill(); + ctx->UpdateSurfaceClip(); //ctx->CurrentSurface()->Flush(); @@ -1829,9 +1827,7 @@ nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(nsIRenderingContext* aCon SetGraphicsMode(hdc, GM_ADVANCED); /* Need to force the clip to be set */ - ctx->NewPath(); - ctx->Rectangle(gfxRect(0,0,0,0)); - ctx->Fill(); + ctx->UpdateSurfaceClip(); /* Set the device offsets as appropriate */ gfxFloat xoff, yoff;