Closed Bug 354866 Opened 18 years ago Closed 18 years ago

Replace nsSVGCairoCanvas with gfxContext

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: tor, Assigned: tor)

References

Details

Attachments

(2 files, 8 obsolete files)

Start of the switch of SVG code to thebes...
Attached patch snapshot of work (obsolete) (deleted) β€” β€” Splinter Review
Attached patch remove svg renderer layer (obsolete) (deleted) β€” β€” Splinter Review
Start of the move over to thebes entirely in the SVG code.  This only removes the remains of the renderer layer (nsSVGRendererCanvas) - later bugs/patches will continue to remove the direct cairo usage.

I'll post to .builds announcing that SVG will soon switch to depend on cairo gfx.
Attachment #240649 - Attachment is obsolete: true
Attachment #240955 - Flags: review?(roc)
Attached patch missed uuid updates (obsolete) (deleted) β€” β€” Splinter Review
Attachment #240955 - Attachment is obsolete: true
Attachment #240963 - Flags: review?(roc)
Attachment #240955 - Flags: review?(roc)
Blocks: 355043
Do you want me to review this now? You can't land it yet, I assume.
(In reply to comment #4)
> Do you want me to review this now? You can't land it yet, I assume.

Yes, I would like it reviewed now.

Why couldn't I land it?  I just need to coordinate with the tinderboxes to have svg turned off on OS-X for now.

Attached patch merge to tip (obsolete) (deleted) β€” β€” Splinter Review
Attachment #240963 - Attachment is obsolete: true
Attachment #242910 - Flags: review?(roc)
Attachment #240963 - Flags: review?(roc)
Attached patch merge to tip (obsolete) (deleted) β€” β€” Splinter Review
Attachment #242910 - Attachment is obsolete: true
Attachment #243819 - Flags: review?(roc)
Attachment #242910 - Flags: review?(roc)
+  nsSVGOuterSVGFrame* outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(this);
+  if (!outerSVGFrame)
+    return NS_ERROR_FAILURE;
+
+  nsCOMPtr<nsIRenderingContext> ctx = outerSVGFrame->GetRenderingContext();

Why are we getting nsIRenderingContext from the outerSVGFrame? Can't we just create a temporary nsIRenderingContext that wraps aContext?
(In reply to comment #8)
> +  nsSVGOuterSVGFrame* outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(this);
> +  if (!outerSVGFrame)
> +    return NS_ERROR_FAILURE;
> +
> +  nsCOMPtr<nsIRenderingContext> ctx = outerSVGFrame->GetRenderingContext();
> 
> Why are we getting nsIRenderingContext from the outerSVGFrame? Can't we just
> create a temporary nsIRenderingContext that wraps aContext?

Partly because I didn't think of it, partly because doing that seems to require having a nsIDeviceContext which isn't available.

+  nsresult SetupCairoFill(gfxContext *aContext,
                           cairo_t *aCtx,
                           void **aClosure);

Why do we need to pass both aContext and aCtx here? Can't we just pass aContext and use aContext->GetCairo as needed?

+  nsresult GetGlobalTransform(cairo_t *ctx, gfxContext *aContext);

Same question

+  nsRefPtr<gfxContext> ctx =
+    (gfxContext *)aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);

Why do you need a strong ref here? Also, use NS_STATIC_CAST.

+already_AddRefed<nsIRenderingContext>
+nsSVGOuterSVGFrame::GetRenderingContext()

And why does this need to add a ref?

+nsSVGPathGeometryFrame::GeneratePath(cairo_t *ctx, gfxContext* aContext)

It's not really clear why we need two context parameters here. Is it because we don't have a gfxContext when we're hit testing, but we need the aContext to get its matrix when drawing? Could we create a temporary aContext for hit-testing?

+  nsRefPtr<gfxUnknownSurface> tmpSurface =
+    new gfxUnknownSurface(patternSurface);
+  if (!tmpSurface)
+    return NS_ERROR_FAILURE;

Could we stack-allocate this? If we can't, it would be nice to change things so we can allocate temporary wrappers (like you did with gfxContext earlier). Check with vlad/pav?

I'm not really comfortable with the global render-mode. Should we perhaps define some sort of nsSVGRenderState struct containing the render mode, the gfxContext, and possibly other things, and use that as the parameter to PaintSVG? It seems to me that the current code would at least need to save and restore the render mode when it changes the render mode, e.g. in nsSVGClipPathFrame.cpp. If we had nsSVGRenderState we could put the nsIRenderingContext* in there too, so we wouldn't need the cache-it-in-nsSVGOuterFrame hack.



Attached patch update per review comments (obsolete) (deleted) β€” β€” Splinter Review
Attachment #243819 - Attachment is obsolete: true
Attachment #244245 - Flags: review?(roc)
Attachment #243819 - Flags: review?(roc)
Comment on attachment 244245 [details] [diff] [review]
update per review comments

+  cairo_t *aCtx = aContext->GetCairo();

Take the plunge and rename to "ctx", please :-)

+  nsCOMPtr<nsIRenderingContext> mRenderingContext;

We don't need this in nsSVGOuterSVGFrame any more, right?

This is nice. One more thing we could do. nsSVGRenderState doesn't need an nsTArray stack. Instead we could have a helper class ... nsAutoSVGRenderMode say ... whose constructor saves the current render mode and sets the new mode, and whose destructor restores the old render mode.
Attached patch all stack, all the time :) (deleted) β€” β€” Splinter Review
Attachment #244245 - Attachment is obsolete: true
Attachment #244320 - Flags: review?(roc)
Attachment #244245 - Flags: review?(roc)
Comment on attachment 244320 [details] [diff] [review]
all stack, all the time :)

Move nsAutoSVGRenderMode to nsSVGUtils.h next to nsSVGRenderState.
Attachment #244320 - Flags: superreview+
Attachment #244320 - Flags: review?(roc)
Attachment #244320 - Flags: review+
Attached patch checkin version - nsAutoSVGRenderMode moved (obsolete) (deleted) β€” β€” Splinter Review
Version for checkin, once I've reminded people that svg will need to be disabled on non-cairo builds and had the tinderbox configurations prepared.
Depends on: 359101
Attached patch update to tip (obsolete) (deleted) β€” β€” Splinter Review
Attachment #244344 - Attachment is obsolete: true
Attached patch update to tip (deleted) β€” β€” Splinter Review
Attachment #245571 - Attachment is obsolete: true
Checked in.  Needed to disable SVG on Camino until they switch to cairo gfx (bug 358390).
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
No longer blocks: 355043
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: