• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

Image.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
00003  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00015  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00018  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00025  */
00026 
00027 #ifndef Image_h
00028 #define Image_h
00029 
00030 #include "Color.h"
00031 #include "GraphicsTypes.h"
00032 #include "ImageSource.h"
00033 #include <wtf/RefPtr.h>
00034 #include <wtf/PassRefPtr.h>
00035 #include "SharedBuffer.h"
00036 
00037 #if PLATFORM(MAC)
00038 #ifdef __OBJC__
00039 @class NSImage;
00040 #else
00041 class NSImage;
00042 #endif
00043 #endif
00044 
00045 #if PLATFORM(CG)
00046 struct CGContext;
00047 #endif
00048 
00049 #if PLATFORM(WIN)
00050 typedef struct HBITMAP__ *HBITMAP;
00051 #endif
00052 
00053 #if PLATFORM(QT)
00054 #include <QPixmap>
00055 #endif
00056 
00057 namespace WebCore {
00058 
00059 class AffineTransform;
00060 class FloatPoint;
00061 class FloatRect;
00062 class FloatSize;
00063 class GraphicsContext;
00064 class IntRect;
00065 class IntSize;
00066 class SharedBuffer;
00067 //class String;
00068 
00069 // This class gets notified when an image creates or destroys decoded frames and when it advances animation frames.
00070 class ImageObserver;
00071 
00072 class Image : Noncopyable {
00073     friend class GeneratedImage;
00074     friend class GraphicsContext;
00075 public:
00076     Image(ImageObserver* = 0);
00077     virtual ~Image();
00078     
00079     static Image* loadPlatformResource(const char* name);
00080     static bool supportsType(const String&); 
00081 
00082     bool isNull() const;
00083 
00084     // These are only used for SVGImage right now
00085     virtual void setContainerSize(const IntSize&) { }
00086     virtual bool usesContainerSize() const { return false; }
00087     virtual bool hasRelativeWidth() const { return false; }
00088     virtual bool hasRelativeHeight() const { return false; }
00089 
00090     virtual IntSize size() const = 0;
00091     IntRect rect() const;
00092     int width() const;
00093     int height() const;
00094 
00095     bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
00096     virtual bool dataChanged(bool allDataReceived) { return false; }
00097     
00098     // FIXME: PDF/SVG will be underreporting decoded sizes and will be unable to prune because these functions are not
00099     // implemented yet for those image types.
00100     virtual void destroyDecodedData(bool incremental = false) {};
00101     virtual unsigned decodedSize() const { return 0; }
00102 
00103     SharedBuffer* data() { return m_data.get(); }
00104 
00105     // It may look unusual that there is no start animation call as public API.  This is because
00106     // we start and stop animating lazily.  Animation begins whenever someone draws the image.  It will
00107     // automatically pause once all observers no longer want to render the image anywhere.
00108     virtual void stopAnimation() {}
00109     virtual void resetAnimation() {}
00110     
00111     // Typically the CachedImage that owns us.
00112     ImageObserver* imageObserver() const { return m_imageObserver; }
00113 
00114     enum TileRule { StretchTile, RoundTile, RepeatTile };
00115 
00116     virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
00117     
00118 #if PLATFORM(MAC)
00119     // Accessors for native image formats.
00120     virtual NSImage* getNSImage() { return 0; }
00121     virtual CFDataRef getTIFFRepresentation() { return 0; }
00122 #endif
00123 
00124 #if PLATFORM(CG)
00125     virtual CGImageRef getCGImageRef() { return 0; }
00126 #endif
00127 
00128 #if PLATFORM(QT)
00129     virtual QPixmap* getPixmap() const { return 0; }
00130 #endif
00131 
00132 #if PLATFORM(WIN)
00133     virtual bool getHBITMAP(HBITMAP) { return false; }
00134     virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE) { return false; }
00135 #endif
00136 
00137 protected:
00138     static void fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect, const Color& color, CompositeOperator op);
00139 
00140 protected:
00141 #if PLATFORM(WIN)
00142     virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator) { }
00143 #endif
00144     virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator) = 0;
00145     void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, CompositeOperator);
00146     void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, CompositeOperator);
00147 
00148     // Supporting tiled drawing
00149     virtual bool mayFillWithSolidColor() const { return false; }
00150     virtual Color solidColor() const { return Color(); }
00151     
00152     virtual void startAnimation() { }
00153     
00154     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
00155                              const FloatPoint& phase, CompositeOperator, const FloatRect& destRect);
00156 #if PLATFORM(CG)
00157     // These are private to CG.  Ideally they would be only in the .cpp file, but the callback requires access
00158     // to the private function nativeImageForCurrentFrame()
00159     static void drawPatternCallback(void* info, CGContext*);
00160 #endif
00161     
00162 protected:
00163     RefPtr<SharedBuffer> m_data; // The encoded raw data for the image. 
00164     ImageObserver* m_imageObserver;
00165 };
00166 
00167 }
00168 
00169 #endif

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal