1/* 2 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef CoordinatedTile_h 27#define CoordinatedTile_h 28 29#if USE(TILED_BACKING_STORE) 30 31#include "CoordinatedSurface.h" 32#include "IntRect.h" 33#include "Tile.h" 34#include "TiledBackingStore.h" 35 36namespace WebCore { 37 38class CoordinatedTileClient; 39class ImageBuffer; 40class SurfaceUpdateInfo; 41class TiledBackingStore; 42 43class CoordinatedTile : public Tile, public CoordinatedSurface::Client { 44public: 45 static PassRefPtr<Tile> create(CoordinatedTileClient* client, TiledBackingStore* tiledBackingStore, const Coordinate& tileCoordinate) { return adoptRef(new CoordinatedTile(client, tiledBackingStore, tileCoordinate)); } 46 ~CoordinatedTile(); 47 48 bool isDirty() const; 49 void invalidate(const IntRect&); 50 Vector<IntRect> updateBackBuffer(); 51 void swapBackBufferToFront(); 52 bool isReadyToPaint() const; 53 void paint(GraphicsContext*, const IntRect&); 54 55 const Coordinate& coordinate() const { return m_coordinate; } 56 const IntRect& rect() const { return m_rect; } 57 void resize(const IntSize&); 58 59 virtual void paintToSurfaceContext(GraphicsContext*) OVERRIDE; 60 61private: 62 CoordinatedTile(CoordinatedTileClient*, TiledBackingStore*, const Coordinate&); 63 64 CoordinatedTileClient* m_client; 65 TiledBackingStore* m_tiledBackingStore; 66 Coordinate m_coordinate; 67 IntRect m_rect; 68 69 uint32_t m_ID; 70 IntRect m_dirtyRect; 71 72 OwnPtr<ImageBuffer> m_localBuffer; 73}; 74 75class CoordinatedTileClient { 76public: 77 virtual ~CoordinatedTileClient() { } 78 virtual void createTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0; 79 virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0; 80 virtual void removeTile(uint32_t tileID) = 0; 81 virtual bool paintToSurface(const IntSize&, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0; 82}; 83 84class CoordinatedTileBackend : public TiledBackingStoreBackend { 85public: 86 static PassOwnPtr<TiledBackingStoreBackend> create(CoordinatedTileClient* client) { return adoptPtr(new CoordinatedTileBackend(client)); } 87 PassRefPtr<Tile> createTile(TiledBackingStore*, const Tile::Coordinate&); 88 void paintCheckerPattern(GraphicsContext*, const FloatRect&); 89 90private: 91 explicit CoordinatedTileBackend(CoordinatedTileClient*); 92 CoordinatedTileClient* m_client; 93}; 94 95} // namespace WebCore 96 97#endif // USE(TILED_BACKING_STORE) 98 99#endif // CoordinatedTile_h 100