Closed
Bug 276692
Opened 20 years ago
Closed 20 years ago
move image->GdkPixbuf conversion code to nsImageGTK
Categories
(Core Graveyard :: GFX: Gtk, enhancement)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla1.8beta1
People
(Reporter: Biesinger, Assigned: Biesinger)
References
Details
Attachments
(2 files, 2 obsolete files)
13.22 KB,
patch
|
roc
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
1.95 KB,
patch
|
bryner
:
review+
dbaron
:
superreview+
|
Details | Diff | Splinter Review |
from bug 38447 comment 105 "I'd really like it if we could share this code to convert a gfxIImage to a GdkPixbuf. One way we could do this would be to subclass gfxImageFrame for gtk, and add a new interface that has a method something like: GdkPixbuf* ConvertToPixbuf(PRBool aForceAlphaChannel);" (and it turns out that I should have re-read that comment before writing the implementation. anyway...) I added this to nsImageGTK, which simplifies this code quite a bit since many function calls can now be member variable accessors. it also avoid creating a new class. this implementation now has no aForceAlphaChannel argument, it expects the caller to manually add it if desired. since this seems like a rarely used feature, that seems ok. but if reviewers prefer it, I can add it, I don't feel strongly about this one way or another.
Assignee | ||
Comment 1•20 years ago
|
||
Attachment #170043 -
Flags: review?(bryner)
Assignee | ||
Updated•20 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8beta
Comment 2•20 years ago
|
||
Comment on attachment 170043 [details] [diff] [review] patch as described >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ gfx/src/gtk/nsIGdkPixbufImage.h 1 Jan 2005 20:22:15 -0000 >+/** >+ * An interface that allows getting a GdkPixbuf*. >+ */ >+class nsIGdkPixbufImage : public nsISupports { Would it be possible to make this extend nsIImage instead of nsISupports? That way, we don't add extra bloat per-image (MI). >--- gfx/src/gtk/nsImageGTK.cpp 23 Sep 2004 23:02:19 -0000 1.141 >+++ gfx/src/gtk/nsImageGTK.cpp 1 Jan 2005 20:22:15 -0000 >+NS_IMETHODIMP_(GdkPixbuf*) >+nsImageGTK::GetGdkPixbuf() { >+ // Init ensures that we only have 24bpp images >+ NS_ASSERTION(mNumBytesPixel == 3, "Unexpected color depth"); >+ >+ nsresult rv = LockImagePixels(PR_FALSE); >+ NS_ENSURE_SUCCESS(rv, nsnull); >+ >+ // Since UnlockImagePixels potentially frees the image data (and since the >+ // buffer might outlive this object anyway), we have to copy the data. >+ guchar* pixels = NS_STATIC_CAST(guchar*, >+ nsMemory::Clone(mImageBits, mRowBytes * mHeight)); >+ UnlockImagePixels(PR_FALSE); >+ if (!pixels) >+ return NULL; >+ >+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(pixels, >+ GDK_COLORSPACE_RGB, >+ PR_FALSE, >+ 8, >+ mWidth, >+ mHeight, >+ mRowBytes, >+ pixbuf_free, >+ NULL); >+ if (!pixbuf) >+ return nsnull; Any reason this isn't consistent with respect to NULL and nsnull? >--- browser/components/shell/src/nsGNOMEShellService.cpp 15 Jul 2004 22:51:18 -0000 1.4 >+++ browser/components/shell/src/nsGNOMEShellService.cpp 1 Jan 2005 20:22:15 -0000 >@@ -355,119 +357,26 @@ nsGNOMEShellService::SetShouldCheckDefau > return NS_OK; > } > > static nsresult > WriteImage(const nsCString& aPath, gfxIImageFrame* aImage) > { >- PRInt32 width, height; >- aImage->GetWidth(&width); >- aImage->GetHeight(&height); >+ // We need the nsIImage, in order to get the nsIGdkPixbufImage >+ nsCOMPtr<nsIImage> img(do_GetInterface(aImage)); We could avoid the need for that by making gfxImageFrame::GetInterface call mImage->QueryInterface if the interface is nsIGdkPixbufImage. r=me with those fixed.
Attachment #170043 -
Flags: review?(bryner) → review+
Assignee | ||
Comment 3•20 years ago
|
||
>Would it be possible to make this extend nsIImage instead of nsISupports? That >way, we don't add extra bloat per-image (MI). that's an excellent idea; I'll do that. >Any reason this isn't consistent with respect to NULL and nsnull? not really... I think I used NULL for gdkpixbuf interaction and nsnull for the rest, but using nsnull consistently seems better. will fix. >We could avoid the need for that by making gfxImageFrame::GetInterface call >mImage->QueryInterface if the interface is nsIGdkPixbufImage. hm... maybe we can make gfxImageFrame::GetInterface unconditionally call mImage->QI? or I can just use that if.
Comment 4•20 years ago
|
||
(In reply to comment #3) > hm... maybe we can make gfxImageFrame::GetInterface unconditionally call > mImage->QI? or I can just use that if. Either way is fine with me.
Assignee | ||
Comment 5•20 years ago
|
||
ok, I decided to unconditionally call it.
Attachment #170043 -
Attachment is obsolete: true
Attachment #171827 -
Flags: superreview?(roc)
Comment on attachment 171827 [details] [diff] [review] patch v2 +#define NSIGDKPIXBUGIMAGE_IID \ ... + NS_DEFINE_STATIC_IID_ACCESSOR(NSIGDKPIXBUGIMAGE_IID) that's NSIGDKPIXBU*F* other than that, looks good. carrying forward bryner's r+
Attachment #171827 -
Flags: superreview?(roc)
Attachment #171827 -
Flags: superreview+
Attachment #171827 -
Flags: review+
Assignee | ||
Comment 7•20 years ago
|
||
heh, oops. thanks for catching the typo. Checking in browser/components/shell/src/nsGNOMEShellService.cpp; /cvsroot/mozilla/browser/components/shell/src/nsGNOMEShellService.cpp,v <-- nsGNOMEShellService.cpp new revision: 1.7; previous revision: 1.6 done Checking in gfx/src/gtk/Makefile.in; /cvsroot/mozilla/gfx/src/gtk/Makefile.in,v <-- Makefile.in new revision: 1.119; previous revision: 1.118 done RCS file: /cvsroot/mozilla/gfx/src/gtk/nsIGdkPixbufImage.h,v done Checking in gfx/src/gtk/nsIGdkPixbufImage.h; /cvsroot/mozilla/gfx/src/gtk/nsIGdkPixbufImage.h,v <-- nsIGdkPixbufImage.h initial revision: 1.1 done Checking in gfx/src/gtk/nsImageGTK.cpp; /cvsroot/mozilla/gfx/src/gtk/nsImageGTK.cpp,v <-- nsImageGTK.cpp new revision: 1.142; previous revision: 1.141 done Checking in gfx/src/gtk/nsImageGTK.h; /cvsroot/mozilla/gfx/src/gtk/nsImageGTK.h,v <-- nsImageGTK.h new revision: 1.54; previous revision: 1.53 done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 8•19 years ago
|
||
this was meant to be part of the patch (see comment 4, comment 5) but I apparently forgot to diff this file
Assignee | ||
Updated•19 years ago
|
Attachment #177750 -
Flags: superreview?(dbaron)
Comment on attachment 177750 [details] [diff] [review] missing part of the patch I'm a little skeptical that GetInterface implementations should just unconditionally forward to another object without some sort of IID check. You're then at the mercy of some other object for what your GetInterface does. I prefer to think of GetInterface as just a shortcut for an additional interface on which there's a getter. That getter would return something of a given interface, that could then be QIed. That said, maybe there's a good bit of precedent for it. So I think I actually prefer the approach I put in bug 38447.
Attachment #177750 -
Flags: superreview?(dbaron) → superreview-
Assignee | ||
Comment 10•19 years ago
|
||
OK, back to the approach as in the first version of this patch. bryner, given comment 9, is this ok with you?
Attachment #177750 -
Attachment is obsolete: true
Attachment #177988 -
Flags: superreview?(dbaron)
Attachment #177988 -
Flags: review?(bryner)
Attachment #177988 -
Flags: superreview?(dbaron) → superreview+
Updated•19 years ago
|
Attachment #177988 -
Flags: review?(bryner) → review+
Assignee | ||
Comment 11•19 years ago
|
||
attachment 177988 [details] [diff] [review] checked in.
Updated•16 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•