add |svg_images| patch, which right now just tries to write a block of FFFFFF pixels.
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 07 May 2010 16:50:52 -0700
changeset 1562 70a80121927daf521d67d8e4e028bb61cf4736c8
parent 1561 13878b706dbd4e25ff932ff301f72d9502b6c061
child 1563 59d52fa39c2301c76f3375015eae69abe992fe1a
push id1259
push userdholbert@mozilla.com
push dateFri, 07 May 2010 23:50:55 +0000
add |svg_images| patch, which right now just tries to write a block of FFFFFF pixels.
series
svg_images
--- a/series
+++ b/series
@@ -1,7 +1,8 @@
+svg_images #+svgimages
 smil_infallibleMisc #+WIP
 smil_541297ChangeAbortToWarning
 smil_541297Fix
 smil_debuggingCode #+debug
 smil_misc #+nits
 smil_cacheTextZoom #+notsure
 smil_alwaysRecomposeDebugging #+debug
new file mode 100644
--- /dev/null
+++ b/svg_images
@@ -0,0 +1,393 @@
+From: Daniel Holbert <dholbert@cs.stanford.edu>
+
+diff --git a/configure.in b/configure.in
+--- a/configure.in
++++ b/configure.in
+@@ -6245,16 +6245,20 @@ dnl ====================================
+ dnl SVG
+ dnl ========================================================
+ MOZ_ARG_DISABLE_BOOL(svg,
+ [  --disable-svg            Disable SVG support],
+     MOZ_SVG=,
+     MOZ_SVG=1 )
+ if test -n "$MOZ_SVG"; then
+   AC_DEFINE(MOZ_SVG)
++
++  # Add SVG to list of decoders, & remove dupes in case it's already there.
++  MOZ_IMG_DECODERS="$MOZ_IMG_DECODERS svg"      
++  MOZ_IMG_DECODERS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_IMG_DECODERS}`
+ fi
+ 
+ dnl ========================================================
+ dnl SMIL
+ dnl ========================================================
+ MOZ_SMIL=1
+ MOZ_ARG_DISABLE_BOOL(smil,
+ [  --disable-smil           Disable SMIL animation support],
+diff --git a/modules/libpr0n/build/nsImageModule.cpp b/modules/libpr0n/build/nsImageModule.cpp
+--- a/modules/libpr0n/build/nsImageModule.cpp
++++ b/modules/libpr0n/build/nsImageModule.cpp
+@@ -75,16 +75,21 @@
+ #include "nsPNGDecoder.h"
+ #endif
+ 
+ #ifdef IMG_BUILD_DECODER_jpeg
+ // jpeg
+ #include "nsJPEGDecoder.h"
+ #endif
+ 
++#ifdef IMG_BUILD_DECODER_svg
++// svg
++#include "nsSVGDecoder.h"
++#endif
++
+ #ifdef IMG_BUILD_ENCODER_png
+ // png
+ #include "nsPNGEncoder.h"
+ #endif
+ #ifdef IMG_BUILD_ENCODER_jpeg
+ // jpeg
+ #include "nsJPEGEncoder.h"
+ #endif
+@@ -120,16 +125,20 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsBMPDeco
+ #ifdef IMG_BUILD_DECODER_png
+ // png
+ NS_GENERIC_FACTORY_CONSTRUCTOR(nsPNGDecoder)
+ #endif
+ #ifdef IMG_BUILD_ENCODER_png
+ // png
+ NS_GENERIC_FACTORY_CONSTRUCTOR(nsPNGEncoder)
+ #endif
++#ifdef IMG_BUILD_DECODER_svg
++// svg
++NS_GENERIC_FACTORY_CONSTRUCTOR(nsSVGDecoder)
++#endif
+ 
+ static const char* gImageMimeTypes[] = {
+ #ifdef IMG_BUILD_DECODER_gif
+   "image/gif",
+ #endif
+ #ifdef IMG_BUILD_DECODER_jpeg
+   "image/jpeg",
+   "image/pjpeg",
+@@ -140,16 +149,19 @@ static const char* gImageMimeTypes[] = {
+   "image/vnd.microsoft.icon",
+   "image/bmp",
+   "image/x-ms-bmp",
+ #endif
+ #ifdef IMG_BUILD_DECODER_png
+   "image/png",
+   "image/x-png",
+ #endif
++#ifdef IMG_BUILD_DECODER_svg
++  "image/svg+xml",
++#endif
+ };
+ 
+ static NS_METHOD ImageRegisterProc(nsIComponentManager *aCompMgr,
+                                    nsIFile *aPath,
+                                    const char *registryLocation,
+                                    const char *componentType,
+                                    const nsModuleComponentInfo *info) {
+   nsresult rv;
+@@ -271,16 +283,23 @@ static const nsModuleComponentInfo compo
+ #endif
+ #ifdef IMG_BUILD_ENCODER_png
+   // png
+   { "PNG Encoder",
+     NS_PNGENCODER_CID,
+     "@mozilla.org/image/encoder;2?type=image/png",
+     nsPNGEncoderConstructor, },
+ #endif
++
++#ifdef IMG_BUILD_DECODER_svg
++  { "SVG Decoder",
++    NS_SVGDECODER_CID,
++    "@mozilla.org/image/decoder;3?type=image/svg+xml",
++    nsSVGDecoderConstructor, },
++#endif
+ };
+ 
+ static nsresult
+ imglib_Initialize(nsIModule* aSelf)
+ {
+   // Hack: We need the gfx module to be initialized because we use gfxPlatform
+   // in imgFrame. Request something from the gfx module to ensure that
+   // everything's set up for us.
+diff --git a/modules/libpr0n/decoders/svg/Makefile.in b/modules/libpr0n/decoders/svg/Makefile.in
+new file mode 100644
+--- /dev/null
++++ b/modules/libpr0n/decoders/svg/Makefile.in
+@@ -0,0 +1,60 @@
++#
++# ***** BEGIN LICENSE BLOCK *****
++# Version: MPL 1.1/GPL 2.0/LGPL 2.1
++#
++# The contents of this file are subject to the Mozilla Public License Version
++# 1.1 (the "License"); you may not use this file except in compliance with
++# the License. You may obtain a copy of the License at
++# http://www.mozilla.org/MPL/
++#
++# Software distributed under the License is distributed on an "AS IS" basis,
++# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++# for the specific language governing rights and limitations under the
++# License.
++#
++# The Original Code is mozilla.org code.
++#
++# The Initial Developer of the Original Code is
++# Netscape Communications Corporation.
++# Portions created by the Initial Developer are Copyright (C) 2010
++# the Initial Developer. All Rights Reserved.
++#
++# Contributor(s):
++#
++# Alternatively, the contents of this file may be used under the terms of
++# either the GNU General Public License Version 2 or later (the "GPL"), or
++# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++# in which case the provisions of the GPL or the LGPL are applicable instead
++# of those above. If you wish to allow use of your version of this file only
++# under the terms of either the GPL or the LGPL, and not to allow others to
++# use your version of this file under the terms of the MPL, indicate your
++# decision by deleting the provisions above and replace them with the notice
++# and other provisions required by the GPL or the LGPL. If you do not delete
++# the provisions above, a recipient may use your version of this file under
++# the terms of any one of the MPL, the GPL or the LGPL.
++#
++# ***** END LICENSE BLOCK *****
++
++DEPTH		= ../../../..
++topsrcdir	= @top_srcdir@
++srcdir		= @srcdir@
++VPATH		= @srcdir@
++
++include $(DEPTH)/config/autoconf.mk
++
++MODULE		= imgsvg
++LIBRARY_NAME	= imgsvg_s
++FORCE_STATIC_LIB = 1
++MODULE_NAME	= SVGDecoderModule
++LIBXUL_LIBRARY = 1
++
++EXTRA_DSO_LIBS	= gkgfx # XXXdholbert Needed? probably need content too...
++
++CPPSRCS		= nsSVGDecoder.cpp
++
++# XXXdholbert Use this if needed
++# nsGIFDecoder2.cpp includes imgContainer.h
++# LOCAL_INCLUDES += -I$(topsrcdir)/modules/libpr0n/src
++
++include $(topsrcdir)/config/rules.mk
++
+diff --git a/modules/libpr0n/decoders/svg/nsSVGDecoder.cpp b/modules/libpr0n/decoders/svg/nsSVGDecoder.cpp
+new file mode 100644
+--- /dev/null
++++ b/modules/libpr0n/decoders/svg/nsSVGDecoder.cpp
+@@ -0,0 +1,135 @@
++/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is the Mozilla SVG Module.
++ *
++ * The Initial Developer of the Original Code is
++ * the Mozilla Foundation.
++ * Portions created by the Initial Developer are Copyright (C) 2010
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either the GNU General Public License Version 2 or later (the "GPL"), or
++ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ * ***** END LICENSE BLOCK ***** */
++
++#include "nsSVGDecoder.h"
++#include "imgIContainer.h"
++#include "imgIDecoderObserver.h"
++#include "nsDebug.h"
++#include "prtypes.h"
++#include "gfxASurface.h"
++
++
++// XXXdholbert DEBUGGING
++#include <string.h>
++#define TMP_IMG_HEIGHT 50
++#define TMP_IMG_WIDTH  300
++// XXXdholbert END DEBUGGING
++
++NS_IMPL_ISUPPORTS1(nsSVGDecoder, imgIDecoder)
++
++nsSVGDecoder::nsSVGDecoder()
++{
++  // Nothing to do.
++}
++
++nsSVGDecoder::~nsSVGDecoder()
++{
++  // Nothing to do.
++}
++
++/** imgIDecoder methods **/
++
++/* void init (in imgIContainer aImage,
++              imgIDecoderObserver aObserver,
++              unsigned long aFlags); */
++NS_IMETHODIMP
++nsSVGDecoder::Init(imgIContainer *aImage,
++                   imgIDecoderObserver *aObserver,
++                   PRUint32 aFlags)
++{
++  NS_PRECONDITION(aImage,    "null image");
++  NS_PRECONDITION(aObserver, "null observer");
++  mImage = aImage;
++  mObserver = aObserver;
++  mFlags = aFlags;
++
++  mHaveWrittenData = PR_FALSE; // XXXdholbert DEBUG
++
++  // Fire OnStartDecode at init time to support bug 512435
++  if (!(mFlags & imgIDecoder::DECODER_FLAG_HEADERONLY) && mObserver)
++    mObserver->OnStartDecode(nsnull);
++
++  return NS_OK;
++}
++
++/* void close (); */
++NS_IMETHODIMP
++nsSVGDecoder::Close(PRUint32 aFlags)
++{
++  mImage->DecodingComplete();
++  if (mObserver) {
++    mObserver->OnStopContainer(nsnull, mImage);
++    mObserver->OnStopDecode(nsnull, NS_OK, nsnull);
++  }
++  mImage = nsnull;
++  return NS_OK;
++}
++
++/* void flush (); */
++NS_IMETHODIMP
++nsSVGDecoder::Flush()
++{
++  return NS_OK;
++}
++
++NS_IMETHODIMP
++nsSVGDecoder::Write(const char *aBuffer, PRUint32 aCount)
++{
++  // XXXdholbert TESTING
++  if (!mHaveWrittenData) {
++    PRUint8* imgDataPtr = nsnull;
++    PRUint32 imgDataLength;
++
++    mImage->SetSize(TMP_IMG_WIDTH, TMP_IMG_HEIGHT);
++    mImage->AppendFrame(0,0, TMP_IMG_WIDTH, TMP_IMG_HEIGHT,
++                        gfxASurface::ImageFormatARGB32,
++                        &imgDataPtr, &imgDataLength);
++
++
++    nsIntRect frameRect(0, 0, TMP_IMG_WIDTH, TMP_IMG_HEIGHT);
++    mImage->FrameUpdated(0, frameRect);
++    mObserver->OnDataAvailable(nsnull, PR_TRUE, &frameRect);
++
++    mImage->EndFrameDecode(0);
++    mImage->DecodingComplete();
++
++    memset(imgDataPtr, 0xff, imgDataLength);
++    mHaveWrittenData = PR_TRUE;
++    // XXXdholbert END TESTING
++  }
++  return NS_OK;
++}
+diff --git a/modules/libpr0n/decoders/svg/nsSVGDecoder.h b/modules/libpr0n/decoders/svg/nsSVGDecoder.h
+new file mode 100644
+--- /dev/null
++++ b/modules/libpr0n/decoders/svg/nsSVGDecoder.h
+@@ -0,0 +1,67 @@
++/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
++/* ***** BEGIN LICENSE BLOCK *****
++ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
++ *
++ * The contents of this file are subject to the Mozilla Public License Version
++ * 1.1 (the "License"); you may not use this file except in compliance with
++ * the License. You may obtain a copy of the License at
++ * http://www.mozilla.org/MPL/
++ *
++ * Software distributed under the License is distributed on an "AS IS" basis,
++ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
++ * for the specific language governing rights and limitations under the
++ * License.
++ *
++ * The Original Code is the Mozilla SVG Module.
++ *
++ * The Initial Developer of the Original Code is
++ * the Mozilla Foundation.
++ * Portions created by the Initial Developer are Copyright (C) 2010
++ * the Initial Developer. All Rights Reserved.
++ *
++ * Contributor(s):
++ *
++ * Alternatively, the contents of this file may be used under the terms of
++ * either the GNU General Public License Version 2 or later (the "GPL"), or
++ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
++ * in which case the provisions of the GPL or the LGPL are applicable instead
++ * of those above. If you wish to allow use of your version of this file only
++ * under the terms of either the GPL or the LGPL, and not to allow others to
++ * use your version of this file under the terms of the MPL, indicate your
++ * decision by deleting the provisions above and replace them with the notice
++ * and other provisions required by the GPL or the LGPL. If you do not delete
++ * the provisions above, a recipient may use your version of this file under
++ * the terms of any one of the MPL, the GPL or the LGPL.
++ *
++ * ***** END LICENSE BLOCK ***** */
++
++#ifndef NS_SVGDECODER_H_
++#define NS_SVGDECODER_H_
++
++#include "imgIDecoder.h"
++#include "nsAutoPtr.h"
++
++#define NS_SVGDECODER_CID \
++{ 0x74bedb60,                                      \
++  0xc188,                                          \
++  0x4e05,                                          \
++  {0x9b, 0x21, 0x24, 0xe0, 0xc0, 0x5e, 0xc9, 0xa3} \
++}
++
++class nsSVGDecoder : public imgIDecoder
++{
++public:
++  NS_DECL_ISUPPORTS
++  NS_DECL_IMGIDECODER
++  nsSVGDecoder();
++  virtual ~nsSVGDecoder();
++
++private:
++  nsCOMPtr<imgIContainer> mImage;
++  nsCOMPtr<imgIDecoderObserver> mObserver;
++  PRUint32 mFlags;
++
++  PRBool mHaveWrittenData; // XXXdholbert DEBUG
++};
++
++#endif //  NS_SVGDECODER_H_