Bug 584841 patch 1: Create mozilla::imagelib::Image abstract class. r=bholley a=blocking

This commit is contained in:
Daniel Holbert 2010-08-13 21:09:48 -07:00
parent 5b754a5516
commit 615dfd73de
5 changed files with 119 additions and 10 deletions

View File

@ -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

View File

@ -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_

View File

@ -51,6 +51,7 @@ LIBXUL_LIBRARY = 1
CPPSRCS = \
Image.cpp \
imgContainer.cpp \
imgFrame.cpp \
imgLoader.cpp \

View File

@ -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),

View File

@ -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<char> 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?