OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2010 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 |
| 27 #ifndef TextureLayerChromium_h |
| 28 #define TextureLayerChromium_h |
| 29 |
| 30 #if USE(ACCELERATED_COMPOSITING) |
| 31 |
| 32 #include "LayerChromium.h" |
| 33 |
| 34 namespace WebKit { |
| 35 class WebGraphicsContext3D; |
| 36 } |
| 37 |
| 38 namespace WebCore { |
| 39 |
| 40 class TextureLayerChromiumClient { |
| 41 public: |
| 42 // Called to prepare this layer's texture for compositing. The client may qu
eue a texture |
| 43 // upload or copy on the CCTextureUpdater. |
| 44 // Returns the texture ID to be used for compositing. |
| 45 virtual unsigned prepareTexture(CCTextureUpdater&) = 0; |
| 46 |
| 47 // Returns the context that is providing the texture. Used for rate limiting
and detecting lost context. |
| 48 virtual WebKit::WebGraphicsContext3D* context() = 0; |
| 49 |
| 50 protected: |
| 51 virtual ~TextureLayerChromiumClient() { } |
| 52 }; |
| 53 |
| 54 // A Layer containing a the rendered output of a plugin instance. |
| 55 class TextureLayerChromium : public LayerChromium { |
| 56 public: |
| 57 // If this texture layer requires special preparation logic for each frame d
riven by |
| 58 // the compositor, pass in a non-nil client. Pass in a nil client pointer if
texture updates |
| 59 // are driven by an external process. |
| 60 static PassRefPtr<TextureLayerChromium> create(TextureLayerChromiumClient*); |
| 61 virtual ~TextureLayerChromium(); |
| 62 |
| 63 void clearClient() { m_client = 0; } |
| 64 |
| 65 virtual PassOwnPtr<CCLayerImpl> createCCLayerImpl() OVERRIDE; |
| 66 |
| 67 // Sets whether this texture should be Y-flipped at draw time. Defaults to t
rue. |
| 68 void setFlipped(bool); |
| 69 |
| 70 // Sets a UV transform to be used at draw time. Defaults to (0, 0, 1, 1). |
| 71 void setUVRect(const FloatRect&); |
| 72 |
| 73 // Sets whether the alpha channel is premultiplied or unpremultiplied. Defau
lts to true. |
| 74 void setPremultipliedAlpha(bool); |
| 75 |
| 76 // Sets whether this context should rate limit on damage to prevent too many
frames from |
| 77 // being queued up before the compositor gets a chance to run. Requires a no
n-nil client. |
| 78 // Defaults to false. |
| 79 void setRateLimitContext(bool); |
| 80 |
| 81 // Code path for plugins which supply their own texture ID. |
| 82 void setTextureId(unsigned); |
| 83 |
| 84 void willModifyTexture(); |
| 85 |
| 86 virtual void setNeedsDisplayRect(const FloatRect&) OVERRIDE; |
| 87 |
| 88 virtual void setLayerTreeHost(CCLayerTreeHost*) OVERRIDE; |
| 89 virtual bool drawsContent() const OVERRIDE; |
| 90 virtual void update(CCTextureUpdater&, const CCOcclusionTracker*) OVERRIDE; |
| 91 virtual void pushPropertiesTo(CCLayerImpl*) OVERRIDE; |
| 92 |
| 93 protected: |
| 94 explicit TextureLayerChromium(TextureLayerChromiumClient*); |
| 95 |
| 96 private: |
| 97 TextureLayerChromiumClient* m_client; |
| 98 |
| 99 bool m_flipped; |
| 100 FloatRect m_uvRect; |
| 101 bool m_premultipliedAlpha; |
| 102 bool m_rateLimitContext; |
| 103 bool m_contextLost; |
| 104 |
| 105 unsigned m_textureId; |
| 106 }; |
| 107 |
| 108 } |
| 109 #endif // USE(ACCELERATED_COMPOSITING) |
| 110 |
| 111 #endif |
OLD | NEW |