File indexing completed on 2024-04-21 14:57:38

0001 /*
0002     Large image displaying library.
0003 
0004     Copyright (C) 2004,2005 Maks Orlovich (maksim@kde.org)
0005 
0006     Permission is hereby granted, free of charge, to any person obtaining a copy
0007     of this software and associated documentation files (the "Software"), to deal
0008     in the Software without restriction, including without limitation the rights
0009     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0010     copies of the Software, and to permit persons to whom the Software is
0011     furnished to do so, subject to the following conditions:
0012 
0013     The above copyright notice and this permission notice shall be included in
0014     all copies or substantial portions of the Software.
0015 
0016     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0017     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0018     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0019     AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0020     AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0021     CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0022 
0023 */
0024 #ifndef IMAGE_PLANE_H
0025 #define IMAGE_PLANE_H
0026 
0027 #include "plane.h"
0028 #include "pixmaptile.h"
0029 #include "imageformat.h"
0030 
0031 namespace khtmlImLoad
0032 {
0033 
0034 /**
0035  Image planes represent client-side image data, and are primarily an
0036  abstraction for pushing data to the server, as needed.
0037 */
0038 class ImagePlane: public Plane
0039 {
0040 public:
0041     ImageFormat format;
0042 
0043     ImagePlane(unsigned int _width, unsigned int _height): Plane(_width, _height)
0044     {}
0045 
0046     virtual void flushCache() = 0;
0047 
0048     /**
0049      Returns true if the given pixmap tile is up-to-date.
0050      Note that this should compare the information in the pixmap with ideal the
0051      up-to-date image using the decoding information thus far, and not
0052      with the state of the image proper. (Which might not even be in memory)
0053     */
0054     virtual bool isUpToDate(unsigned int tileX, unsigned int tileY,
0055                             PixmapTile *tile) = 0;
0056 
0057     /**
0058      Ensures that the given pixmap tile is up-to-date.
0059     */
0060     virtual void ensureUpToDate(unsigned int tileX, unsigned int tileY,
0061                                 PixmapTile *tile) = 0;
0062 
0063     virtual ~ImagePlane();
0064 protected:
0065     //Helpers for subclasses.
0066 
0067     /**
0068      Checks whether the tile is up-to-date for a given version array
0069     */
0070     bool checkUpToDate(const unsigned char *versions, PixmapTile *tile);
0071 
0072     /**
0073      Creates the pixmap in the tile
0074     */
0075     void setupTile(unsigned int tileX, unsigned int tileY, PixmapTile *tile);
0076 
0077     /**
0078       Update the pixmap using the appropriate image, starting from
0079       offset (offX, offY), and the matching version array
0080     */
0081     void updatePixmap(PixmapTile *tile, const QImage &image,
0082                       unsigned int tileX, unsigned int tileY,
0083                       unsigned int offX,  unsigned int offY,
0084                       unsigned char *versions);
0085 
0086 };
0087 
0088 }
0089 
0090 #endif