AcagiTiledBackingStore.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
  3. Copyright (C) 2014 Sony Computer Entertainment Inc.
  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. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef AcagiTiledBackingStore_h
  18. #define AcagiTiledBackingStore_h
  19. #if USE(ACCELERATED_COMPOSITING) && USE(ACAGI)
  20. #include "AcagiBackingStore.h"
  21. #include "AcagiTile.h"
  22. #include "FloatRect.h"
  23. #include "Image.h"
  24. #include <wtf/RefPtr.h>
  25. namespace WebCore {
  26. class AcagiCompositor;
  27. class AcagiTiledBackingStore : public AcagiBackingStore {
  28. public:
  29. static PassRefPtr<AcagiTiledBackingStore> create() { return adoptRef(new AcagiTiledBackingStore); }
  30. virtual ~AcagiTiledBackingStore() { }
  31. virtual PassRefPtr<AcagiBitmapTexture> texture() const OVERRIDE;
  32. virtual void compositeContents(AcagiCompositor*, const FloatRect&, const TransformationMatrix&, float) OVERRIDE;
  33. virtual void drawBorder(AcagiCompositor*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
  34. virtual void drawRepaintCounter(AcagiCompositor*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) OVERRIDE;
  35. void updateContents(AcagiCompositor*, Image*, const FloatSize&, const IntRect&, AcagiBitmapTexture::UpdateContentsFlag);
  36. void updateContents(AcagiCompositor*, GraphicsLayer*, const FloatSize&, const FloatRect&, const IntRect&, AcagiBitmapTexture::UpdateContentsFlag);
  37. void setContentsToImage(Image* image) { m_image = image; }
  38. private:
  39. AcagiTiledBackingStore();
  40. void createOrDestroyTilesIfNeeded(const FloatSize& backingStoreSize, const FloatRect& visibleContentRect, float contentsScale, const IntSize& tileSize, bool hasAlpha);
  41. void updateContentsFromImageIfNeeded(AcagiCompositor*);
  42. TransformationMatrix adjustedTransformForRect(const FloatRect&);
  43. inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
  44. Vector<AcagiTile> m_tiles;
  45. FloatSize m_size;
  46. FloatRect m_coveredRect;
  47. float m_contentsScale;
  48. RefPtr<Image> m_image;
  49. };
  50. } // namespace WebCore
  51. #endif
  52. #endif