From 615dfd73dee6e86ff597cbaf394a964de3aa09d8 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Fri, 13 Aug 2010 21:09:48 -0700 Subject: [PATCH] Bug 584841 patch 1: Create mozilla::imagelib::Image abstract class. r=bholley a=blocking --- modules/libpr0n/src/Image.cpp | 51 ++++++++++++++++++++++ modules/libpr0n/src/Image.h | 65 ++++++++++++++++++++++++++++ modules/libpr0n/src/Makefile.in | 1 + modules/libpr0n/src/imgContainer.cpp | 2 - modules/libpr0n/src/imgContainer.h | 10 +---- 5 files changed, 119 insertions(+), 10 deletions(-) create mode 100644 modules/libpr0n/src/Image.cpp create mode 100644 modules/libpr0n/src/Image.h diff --git a/modules/libpr0n/src/Image.cpp b/modules/libpr0n/src/Image.cpp new file mode 100644 index 00000000000..53dd3973e84 --- /dev/null +++ b/modules/libpr0n/src/Image.cpp @@ -0,0 +1,51 @@ +/* -*- 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 mozilla.org code. + * + * 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 "Image.h" + +namespace mozilla { +namespace imagelib { + +// Constructor +Image::Image() : + mStatusTracker(this), + mInitialized(PR_FALSE) +{ +} + +} // namespace imagelib +} // namespace mozilla diff --git a/modules/libpr0n/src/Image.h b/modules/libpr0n/src/Image.h new file mode 100644 index 00000000000..2e5c9da3a7a --- /dev/null +++ b/modules/libpr0n/src/Image.h @@ -0,0 +1,65 @@ +/* -*- 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 mozilla.org code. + * + * 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 MOZILLA_IMAGELIB_IMAGE_H_ +#define MOZILLA_IMAGELIB_IMAGE_H_ + +#include "imgIContainer.h" +#include "imgStatusTracker.h" +#include "prtypes.h" + +namespace mozilla { +namespace imagelib { + +class Image : public imgIContainer +{ +public: + imgStatusTracker& GetStatusTracker() { return mStatusTracker; } + PRBool IsInitialized() const { return mInitialized; } + +protected: + Image(); + + // Member data shared by all implementations of this abstract class + imgStatusTracker mStatusTracker; + PRPackedBool mInitialized; // Have we been initalized? +}; + +} // namespace imagelib +} // namespace mozilla + +#endif // MOZILLA_IMAGELIB_IMAGE_H_ diff --git a/modules/libpr0n/src/Makefile.in b/modules/libpr0n/src/Makefile.in index 173ce28ee12..6f30ae7e92a 100644 --- a/modules/libpr0n/src/Makefile.in +++ b/modules/libpr0n/src/Makefile.in @@ -51,6 +51,7 @@ LIBXUL_LIBRARY = 1 CPPSRCS = \ + Image.cpp \ imgContainer.cpp \ imgFrame.cpp \ imgLoader.cpp \ diff --git a/modules/libpr0n/src/imgContainer.cpp b/modules/libpr0n/src/imgContainer.cpp index 1a3adab1c45..7bb7d24645c 100644 --- a/modules/libpr0n/src/imgContainer.cpp +++ b/modules/libpr0n/src/imgContainer.cpp @@ -144,7 +144,6 @@ imgContainer::imgContainer() : mLoopCount(-1), mObserver(nsnull), mLockCount(0), - mStatusTracker(this), mDecoder(nsnull), mWorker(nsnull), mBytesDecoded(0), @@ -152,7 +151,6 @@ imgContainer::imgContainer() : mHasSize(PR_FALSE), mDecodeOnDraw(PR_FALSE), mMultipart(PR_FALSE), - mInitialized(PR_FALSE), mDiscardable(PR_FALSE), mHasSourceData(PR_FALSE), mDecoded(PR_FALSE), diff --git a/modules/libpr0n/src/imgContainer.h b/modules/libpr0n/src/imgContainer.h index 540cd2c7d86..087916adb31 100644 --- a/modules/libpr0n/src/imgContainer.h +++ b/modules/libpr0n/src/imgContainer.h @@ -53,6 +53,7 @@ #ifndef __imgContainer_h__ #define __imgContainer_h__ +#include "Image.h" #include "nsCOMArray.h" #include "nsCOMPtr.h" #include "imgIContainer.h" @@ -64,7 +65,6 @@ #include "imgFrame.h" #include "nsThreadUtils.h" #include "imgDiscardTracker.h" -#include "imgStatusTracker.h" #define NS_IMGCONTAINER_CID \ { /* 376ff2c1-9bf6-418a-b143-3340c00112f7 */ \ @@ -137,7 +137,7 @@ * in Init(). */ class imgDecodeWorker; -class imgContainer : public imgIContainer, +class imgContainer : public mozilla::imagelib::Image, public nsITimerCallback, public nsIProperties, public nsSupportsWeakReference @@ -162,9 +162,6 @@ public: /* Triggers discarding. */ void Discard(); - imgStatusTracker& GetStatusTracker() { return mStatusTracker; } - PRBool IsInitialized() const { return mInitialized; } - private: struct Anim { @@ -335,8 +332,6 @@ private: // data nsTArray mSourceData; nsCString mSourceDataMimeType; - imgStatusTracker mStatusTracker; - friend class imgDecodeWorker; friend class imgDiscardTracker; @@ -350,7 +345,6 @@ private: // data PRPackedBool mHasSize:1; // Has SetSize() been called? PRPackedBool mDecodeOnDraw:1; // Decoding on draw? PRPackedBool mMultipart:1; // Multipart? - PRPackedBool mInitialized:1; // Have we been initalized? PRPackedBool mDiscardable:1; // Is container discardable? PRPackedBool mHasSourceData:1; // Do we have source data?