1/* 2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 Copyright (C) 2012 Company 100, Inc. 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 21#ifndef UpdateAtlas_h 22#define UpdateAtlas_h 23 24#include "AreaAllocator.h" 25#include "CoordinatedSurface.h" 26#include "IntSize.h" 27 28#if USE(COORDINATED_GRAPHICS) 29 30namespace WebCore { 31class GraphicsContext; 32class IntPoint; 33 34class UpdateAtlas { 35 WTF_MAKE_NONCOPYABLE(UpdateAtlas); 36public: 37 class Client { 38 public: 39 virtual void createUpdateAtlas(uint32_t /* id */, PassRefPtr<CoordinatedSurface>) = 0; 40 virtual void removeUpdateAtlas(uint32_t /* id */) = 0; 41 }; 42 43 UpdateAtlas(Client*, int dimension, CoordinatedSurface::Flags); 44 ~UpdateAtlas(); 45 46 inline IntSize size() const { return m_surface->size(); } 47 48 // Returns false if there is no available buffer. 49 bool paintOnAvailableBuffer(const IntSize&, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client*); 50 void didSwapBuffers(); 51 bool supportsAlpha() const { return m_surface->supportsAlpha(); } 52 53 void addTimeInactive(double seconds) 54 { 55 ASSERT(!isInUse()); 56 m_inactivityInSeconds += seconds; 57 } 58 bool isInactive() const 59 { 60 const double inactiveSecondsTolerance = 3; 61 return m_inactivityInSeconds > inactiveSecondsTolerance; 62 } 63 bool isInUse() const { return m_areaAllocator; } 64 65private: 66 void buildLayoutIfNeeded(); 67 68private: 69 Client* m_client; 70 OwnPtr<GeneralAreaAllocator> m_areaAllocator; 71 RefPtr<CoordinatedSurface> m_surface; 72 double m_inactivityInSeconds; 73 uint32_t m_ID; 74}; 75 76} // namespace WebCore 77#endif // USE(COORDINATED_GRAPHICS) 78#endif // UpdateAtlas_h 79