| OLD | NEW |
| (Empty) |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 | |
| 7 #if USE(ACCELERATED_COMPOSITING) | |
| 8 | |
| 9 #include "TextureLayerChromium.h" | |
| 10 | |
| 11 #include "CCLayerTreeHost.h" | |
| 12 #include "CCTextureLayerImpl.h" | |
| 13 #include "GraphicsContext3D.h" | |
| 14 #include "TextureLayerChromiumClient.h" | |
| 15 #include <public/WebGraphicsContext3D.h> | |
| 16 | |
| 17 namespace cc { | |
| 18 | |
| 19 scoped_refptr<TextureLayerChromium> TextureLayerChromium::create(TextureLayerChr
omiumClient* client) | |
| 20 { | |
| 21 return scoped_refptr<TextureLayerChromium>(new TextureLayerChromium(client))
; | |
| 22 } | |
| 23 | |
| 24 TextureLayerChromium::TextureLayerChromium(TextureLayerChromiumClient* client) | |
| 25 : LayerChromium() | |
| 26 , m_client(client) | |
| 27 , m_flipped(true) | |
| 28 , m_uvRect(0, 0, 1, 1) | |
| 29 , m_premultipliedAlpha(true) | |
| 30 , m_rateLimitContext(false) | |
| 31 , m_contextLost(false) | |
| 32 , m_textureId(0) | |
| 33 { | |
| 34 } | |
| 35 | |
| 36 TextureLayerChromium::~TextureLayerChromium() | |
| 37 { | |
| 38 if (layerTreeHost()) { | |
| 39 if (m_textureId) | |
| 40 layerTreeHost()->acquireLayerTextures(); | |
| 41 if (m_rateLimitContext && m_client) | |
| 42 layerTreeHost()->stopRateLimiter(m_client->context()); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 scoped_ptr<CCLayerImpl> TextureLayerChromium::createCCLayerImpl() | |
| 47 { | |
| 48 return CCTextureLayerImpl::create(m_layerId).PassAs<CCLayerImpl>(); | |
| 49 } | |
| 50 | |
| 51 void TextureLayerChromium::setFlipped(bool flipped) | |
| 52 { | |
| 53 m_flipped = flipped; | |
| 54 setNeedsCommit(); | |
| 55 } | |
| 56 | |
| 57 void TextureLayerChromium::setUVRect(const FloatRect& rect) | |
| 58 { | |
| 59 m_uvRect = rect; | |
| 60 setNeedsCommit(); | |
| 61 } | |
| 62 | |
| 63 void TextureLayerChromium::setPremultipliedAlpha(bool premultipliedAlpha) | |
| 64 { | |
| 65 m_premultipliedAlpha = premultipliedAlpha; | |
| 66 setNeedsCommit(); | |
| 67 } | |
| 68 | |
| 69 void TextureLayerChromium::setRateLimitContext(bool rateLimit) | |
| 70 { | |
| 71 if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost()) | |
| 72 layerTreeHost()->stopRateLimiter(m_client->context()); | |
| 73 | |
| 74 m_rateLimitContext = rateLimit; | |
| 75 } | |
| 76 | |
| 77 void TextureLayerChromium::setTextureId(unsigned id) | |
| 78 { | |
| 79 if (m_textureId == id) | |
| 80 return; | |
| 81 if (m_textureId && layerTreeHost()) | |
| 82 layerTreeHost()->acquireLayerTextures(); | |
| 83 m_textureId = id; | |
| 84 setNeedsCommit(); | |
| 85 } | |
| 86 | |
| 87 void TextureLayerChromium::willModifyTexture() | |
| 88 { | |
| 89 if (layerTreeHost()) | |
| 90 layerTreeHost()->acquireLayerTextures(); | |
| 91 } | |
| 92 | |
| 93 void TextureLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect) | |
| 94 { | |
| 95 LayerChromium::setNeedsDisplayRect(dirtyRect); | |
| 96 | |
| 97 if (m_rateLimitContext && m_client && layerTreeHost()) | |
| 98 layerTreeHost()->startRateLimiter(m_client->context()); | |
| 99 } | |
| 100 | |
| 101 void TextureLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) | |
| 102 { | |
| 103 if (m_textureId && layerTreeHost() && host != layerTreeHost()) | |
| 104 layerTreeHost()->acquireLayerTextures(); | |
| 105 LayerChromium::setLayerTreeHost(host); | |
| 106 } | |
| 107 | |
| 108 bool TextureLayerChromium::drawsContent() const | |
| 109 { | |
| 110 return (m_client || m_textureId) && !m_contextLost && LayerChromium::drawsCo
ntent(); | |
| 111 } | |
| 112 | |
| 113 void TextureLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusion
Tracker*, CCRenderingStats&) | |
| 114 { | |
| 115 if (m_client) { | |
| 116 m_textureId = m_client->prepareTexture(queue); | |
| 117 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != Grap
hicsContext3D::NO_ERROR; | |
| 118 } | |
| 119 | |
| 120 m_needsDisplay = false; | |
| 121 } | |
| 122 | |
| 123 void TextureLayerChromium::pushPropertiesTo(CCLayerImpl* layer) | |
| 124 { | |
| 125 LayerChromium::pushPropertiesTo(layer); | |
| 126 | |
| 127 CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer); | |
| 128 textureLayer->setFlipped(m_flipped); | |
| 129 textureLayer->setUVRect(m_uvRect); | |
| 130 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha); | |
| 131 textureLayer->setTextureId(m_textureId); | |
| 132 } | |
| 133 | |
| 134 } | |
| 135 #endif // USE(ACCELERATED_COMPOSITING) | |
| OLD | NEW |