Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: ui/cc/TextureLayerChromium.cpp

Issue 10701016: Initial import attempt, just to play with. Many things disabled/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/cc/TextureLayerChromium.h ('k') | ui/cc/TextureManager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "config.h"
27
28 #if USE(ACCELERATED_COMPOSITING)
29
30 #include "TextureLayerChromium.h"
31
32 #include "cc/CCLayerTreeHost.h"
33 #include "cc/CCTextureLayerImpl.h"
34 #include <public/WebGraphicsContext3D.h>
35
36 namespace WebCore {
37
38 PassRefPtr<TextureLayerChromium> TextureLayerChromium::create(TextureLayerChromi umClient* client)
39 {
40 return adoptRef(new TextureLayerChromium(client));
41 }
42
43 TextureLayerChromium::TextureLayerChromium(TextureLayerChromiumClient* client)
44 : LayerChromium()
45 , m_client(client)
46 , m_flipped(true)
47 , m_uvRect(0, 0, 1, 1)
48 , m_premultipliedAlpha(true)
49 , m_rateLimitContext(false)
50 , m_contextLost(false)
51 , m_textureId(0)
52 {
53 }
54
55 TextureLayerChromium::~TextureLayerChromium()
56 {
57 if (layerTreeHost()) {
58 if (m_textureId)
59 layerTreeHost()->acquireLayerTextures();
60 if (m_rateLimitContext && m_client)
61 layerTreeHost()->stopRateLimiter(m_client->context());
62 }
63 }
64
65 PassOwnPtr<CCLayerImpl> TextureLayerChromium::createCCLayerImpl()
66 {
67 return CCTextureLayerImpl::create(m_layerId);
68 }
69
70 void TextureLayerChromium::setFlipped(bool flipped)
71 {
72 m_flipped = flipped;
73 setNeedsCommit();
74 }
75
76 void TextureLayerChromium::setUVRect(const FloatRect& rect)
77 {
78 m_uvRect = rect;
79 setNeedsCommit();
80 }
81
82 void TextureLayerChromium::setPremultipliedAlpha(bool premultipliedAlpha)
83 {
84 m_premultipliedAlpha = premultipliedAlpha;
85 setNeedsCommit();
86 }
87
88 void TextureLayerChromium::setRateLimitContext(bool rateLimit)
89 {
90 if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost())
91 layerTreeHost()->stopRateLimiter(m_client->context());
92
93 m_rateLimitContext = rateLimit;
94 }
95
96 void TextureLayerChromium::setTextureId(unsigned id)
97 {
98 if (m_textureId == id)
99 return;
100 if (m_textureId && layerTreeHost())
101 layerTreeHost()->acquireLayerTextures();
102 m_textureId = id;
103 setNeedsCommit();
104 }
105
106 void TextureLayerChromium::willModifyTexture()
107 {
108 if (layerTreeHost())
109 layerTreeHost()->acquireLayerTextures();
110 }
111
112 void TextureLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
113 {
114 LayerChromium::setNeedsDisplayRect(dirtyRect);
115
116 if (m_rateLimitContext && m_client && layerTreeHost())
117 layerTreeHost()->startRateLimiter(m_client->context());
118 }
119
120 void TextureLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
121 {
122 if (m_textureId && layerTreeHost() && host != layerTreeHost())
123 layerTreeHost()->acquireLayerTextures();
124 LayerChromium::setLayerTreeHost(host);
125 }
126
127 bool TextureLayerChromium::drawsContent() const
128 {
129 return (m_client || m_textureId) && !m_contextLost && LayerChromium::drawsCo ntent();
130 }
131
132 void TextureLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTr acker*)
133 {
134 if (m_client) {
135 m_textureId = m_client->prepareTexture(updater);
136 m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GL_N O_ERROR;
137 }
138
139 m_needsDisplay = false;
140 }
141
142 void TextureLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
143 {
144 LayerChromium::pushPropertiesTo(layer);
145
146 CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer);
147 textureLayer->setFlipped(m_flipped);
148 textureLayer->setUVRect(m_uvRect);
149 textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
150 textureLayer->setTextureId(m_textureId);
151 }
152
153 }
154 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « ui/cc/TextureLayerChromium.h ('k') | ui/cc/TextureManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698