OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 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 * |
| 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. |
| 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ |
| 25 |
| 26 #ifndef TiledLayerChromium_h |
| 27 #define TiledLayerChromium_h |
| 28 |
| 29 #if USE(ACCELERATED_COMPOSITING) |
| 30 |
| 31 #include "LayerChromium.h" |
| 32 #include "LayerTextureUpdater.h" |
| 33 #include "cc/CCLayerTilingData.h" |
| 34 |
| 35 namespace WebCore { |
| 36 class UpdatableTile; |
| 37 |
| 38 class TiledLayerChromium : public LayerChromium { |
| 39 public: |
| 40 enum TilingOption { AlwaysTile, NeverTile, AutoTile }; |
| 41 |
| 42 virtual ~TiledLayerChromium(); |
| 43 |
| 44 virtual void setIsMask(bool) OVERRIDE; |
| 45 |
| 46 virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE; |
| 47 |
| 48 virtual bool drawsContent() const OVERRIDE; |
| 49 virtual bool needsContentsScale() const OVERRIDE; |
| 50 |
| 51 virtual IntSize contentBounds() const OVERRIDE; |
| 52 |
| 53 virtual void setNeedsDisplayRect(const FloatRect&) OVERRIDE; |
| 54 |
| 55 virtual void setIsNonCompositedContent(bool) OVERRIDE; |
| 56 |
| 57 virtual void setLayerTreeHost(CCLayerTreeHost*) OVERRIDE; |
| 58 |
| 59 // Reserves all existing and valid tile textures to protect them from being |
| 60 // recycled by the texture manager. |
| 61 void protectTileTextures(const IntRect& layerRect); |
| 62 |
| 63 virtual void reserveTextures() OVERRIDE; |
| 64 |
| 65 virtual Region visibleContentOpaqueRegion() const OVERRIDE; |
| 66 |
| 67 protected: |
| 68 TiledLayerChromium(); |
| 69 |
| 70 void updateTileSizeAndTilingOption(); |
| 71 void updateBounds(); |
| 72 |
| 73 // Exposed to subclasses for testing. |
| 74 void setTileSize(const IntSize&); |
| 75 void setTextureFormat(GC3Denum textureFormat) { m_textureFormat = textureFor
mat; } |
| 76 void setBorderTexelOption(CCLayerTilingData::BorderTexelOption); |
| 77 void setSampledTexelFormat(LayerTextureUpdater::SampledTexelFormat sampledTe
xelFormat) { m_sampledTexelFormat = sampledTexelFormat; } |
| 78 size_t numPaintedTiles() { return m_tiler->tiles().size(); } |
| 79 |
| 80 virtual LayerTextureUpdater* textureUpdater() const = 0; |
| 81 virtual void createTextureUpdaterIfNeeded() = 0; |
| 82 |
| 83 // Set invalidations to be potentially repainted during update(). |
| 84 void invalidateRect(const IntRect& layerRect); |
| 85 |
| 86 // Reset state on tiles that will be used for updating the layer. |
| 87 void resetUpdateState(); |
| 88 |
| 89 // Prepare data needed to update textures that intersect with layerRect. |
| 90 void updateLayerRect(CCTextureUpdater&, const IntRect& layerRect, const CCOc
clusionTracker*); |
| 91 |
| 92 // Same as above, but this will try to paint additional surrounding content
if idle. |
| 93 void idleUpdateLayerRect(CCTextureUpdater&, const IntRect& layerRect, const
CCOcclusionTracker*); |
| 94 |
| 95 // After preparing an update, returns true if more pre-painting is needed. |
| 96 bool needsIdlePaint(const IntRect& layerRect); |
| 97 |
| 98 IntRect idlePaintRect(const IntRect& visibleLayerRect); |
| 99 |
| 100 bool skipsDraw() const { return m_skipsDraw; } |
| 101 |
| 102 // Virtual for testing |
| 103 virtual TextureManager* textureManager() const; |
| 104 |
| 105 private: |
| 106 virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl() OVERRIDE; |
| 107 |
| 108 void createTilerIfNeeded(); |
| 109 void setTilingOption(TilingOption); |
| 110 |
| 111 bool tileOnlyNeedsPartialUpdate(UpdatableTile*); |
| 112 bool tileNeedsBufferedUpdate(UpdatableTile*); |
| 113 |
| 114 void updateTiles(bool idle, int left, int top, int right, int bottom, CCText
ureUpdater&, const CCOcclusionTracker*); |
| 115 |
| 116 UpdatableTile* tileAt(int, int) const; |
| 117 UpdatableTile* createTile(int, int); |
| 118 |
| 119 GC3Denum m_textureFormat; |
| 120 bool m_skipsDraw; |
| 121 bool m_skipsIdlePaint; |
| 122 LayerTextureUpdater::SampledTexelFormat m_sampledTexelFormat; |
| 123 |
| 124 // Tracks if we've done any painting on this update cycle. |
| 125 bool m_didPaint; |
| 126 |
| 127 TilingOption m_tilingOption; |
| 128 OwnPtr<CCLayerTilingData> m_tiler; |
| 129 }; |
| 130 |
| 131 } |
| 132 #endif // USE(ACCELERATED_COMPOSITING) |
| 133 |
| 134 #endif |
OLD | NEW |