1/* 2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18 */ 19 20#ifndef CoordinatedBackingStore_h 21#define CoordinatedBackingStore_h 22 23#if USE(COORDINATED_GRAPHICS) 24 25#include "TextureMapper.h" 26#include "TextureMapperBackingStore.h" 27#include "TextureMapperTile.h" 28#include <wtf/HashMap.h> 29#include <wtf/HashSet.h> 30 31namespace WebCore { 32 33class CoordinatedSurface; 34 35class CoordinatedBackingStoreTile : public TextureMapperTile { 36public: 37 explicit CoordinatedBackingStoreTile(float scale = 1) 38 : TextureMapperTile(FloatRect()) 39 , m_scale(scale) 40 { 41 } 42 43 inline float scale() const { return m_scale; } 44 void swapBuffers(TextureMapper*); 45 void setBackBuffer(const IntRect&, const IntRect&, PassRefPtr<CoordinatedSurface> buffer, const IntPoint&); 46 47private: 48 RefPtr<CoordinatedSurface> m_surface; 49 IntRect m_sourceRect; 50 IntRect m_tileRect; 51 IntPoint m_surfaceOffset; 52 float m_scale; 53}; 54 55class CoordinatedBackingStore : public TextureMapperBackingStore { 56public: 57 void createTile(uint32_t tileID, float); 58 void removeTile(uint32_t tileID); 59 void removeAllTiles(); 60 void updateTile(uint32_t tileID, const IntRect&, const IntRect&, PassRefPtr<CoordinatedSurface>, const IntPoint&); 61 static PassRefPtr<CoordinatedBackingStore> create() { return adoptRef(new CoordinatedBackingStore); } 62 void commitTileOperations(TextureMapper*); 63 PassRefPtr<BitmapTexture> texture() const; 64 void setSize(const FloatSize&); 65 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float); 66 virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) override; 67 virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) override; 68 69private: 70 CoordinatedBackingStore() 71 : m_scale(1.) 72 { } 73 void paintTilesToTextureMapper(Vector<TextureMapperTile*>&, TextureMapper*, const TransformationMatrix&, float, const FloatRect&); 74 TransformationMatrix adjustedTransformForRect(const FloatRect&); 75 FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); } 76 77 typedef HashMap<uint32_t, CoordinatedBackingStoreTile> CoordinatedBackingStoreTileMap; 78 CoordinatedBackingStoreTileMap m_tiles; 79 HashSet<uint32_t> m_tilesToRemove; 80 // FIXME: m_pendingSize should be removed after the following bug is fixed: https://bugs.webkit.org/show_bug.cgi?id=108294 81 FloatSize m_pendingSize; 82 FloatSize m_size; 83 float m_scale; 84}; 85 86} // namespace WebCore 87 88#endif // USE(COORDINATED_GRAPHICS) 89 90#endif // CoordinatedBackingStore_h 91