OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/delegating_renderer.h" | 5 #include "cc/delegating_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); | 63 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); |
64 | 64 |
65 if (!context3d) { | 65 if (!context3d) { |
66 // Software compositing. | 66 // Software compositing. |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 if (!context3d->makeContextCurrent()) | 70 if (!context3d->makeContextCurrent()) |
71 return false; | 71 return false; |
72 | 72 |
73 context3d->setContextLostCallback(this); | |
74 context3d->pushGroupMarkerEXT("CompositorContext"); | 73 context3d->pushGroupMarkerEXT("CompositorContext"); |
75 | 74 |
76 std::string extensionsString = | 75 std::string extensionsString = |
77 UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); | 76 UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); |
78 | 77 |
79 std::vector<std::string> extensions; | 78 std::vector<std::string> extensions; |
80 base::SplitString(extensionsString, ' ', &extensions); | 79 base::SplitString(extensionsString, ' ', &extensions); |
81 | 80 |
82 // TODO(danakj): We need non-GPU-specific paths for these things. This | 81 // TODO(danakj): We need non-GPU-specific paths for these things. This |
83 // renderer shouldn't need to use context3d extensions directly. | 82 // renderer shouldn't need to use context3d extensions directly. |
(...skipping 30 matching lines...) Expand all Loading... |
114 capabilities_.usingSetVisibility = hasSetVisibility; | 113 capabilities_.usingSetVisibility = hasSetVisibility; |
115 | 114 |
116 // TODO(danakj): Support GpuMemoryManager. | 115 // TODO(danakj): Support GpuMemoryManager. |
117 capabilities_.usingGpuMemoryManager = false; | 116 capabilities_.usingGpuMemoryManager = false; |
118 | 117 |
119 capabilities_.usingEglImage = hasEGLImage; | 118 capabilities_.usingEglImage = hasEGLImage; |
120 | 119 |
121 return true; | 120 return true; |
122 } | 121 } |
123 | 122 |
124 DelegatingRenderer::~DelegatingRenderer() { | 123 DelegatingRenderer::~DelegatingRenderer() {} |
125 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); | |
126 if (context3d) | |
127 context3d->setContextLostCallback(NULL); | |
128 } | |
129 | 124 |
130 const RendererCapabilities& DelegatingRenderer::capabilities() const { | 125 const RendererCapabilities& DelegatingRenderer::capabilities() const { |
131 return capabilities_; | 126 return capabilities_; |
132 } | 127 } |
133 | 128 |
134 static ResourceProvider::ResourceId AppendToArray( | 129 static ResourceProvider::ResourceId AppendToArray( |
135 ResourceProvider::ResourceIdArray* array, | 130 ResourceProvider::ResourceIdArray* array, |
136 ResourceProvider::ResourceId id) { | 131 ResourceProvider::ResourceId id) { |
137 array->push_back(id); | 132 array->push_back(id); |
138 return id; | 133 return id; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 165 } |
171 | 166 |
172 void DelegatingRenderer::getFramebufferPixels(void *pixels, | 167 void DelegatingRenderer::getFramebufferPixels(void *pixels, |
173 const gfx::Rect& rect) { | 168 const gfx::Rect& rect) { |
174 NOTIMPLEMENTED(); | 169 NOTIMPLEMENTED(); |
175 } | 170 } |
176 | 171 |
177 void DelegatingRenderer::receiveCompositorFrameAck( | 172 void DelegatingRenderer::receiveCompositorFrameAck( |
178 const CompositorFrameAck& ack) { | 173 const CompositorFrameAck& ack) { |
179 resource_provider_->ReceiveFromParent(ack.resources); | 174 resource_provider_->ReceiveFromParent(ack.resources); |
180 if (m_client->hasImplThread()) | |
181 m_client->onSwapBuffersComplete(); | |
182 } | 175 } |
183 | 176 |
184 | |
185 bool DelegatingRenderer::isContextLost() { | 177 bool DelegatingRenderer::isContextLost() { |
186 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); | 178 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); |
187 if (!context3d) | 179 if (!context3d) |
188 return false; | 180 return false; |
189 return context3d->getGraphicsResetStatusARB() != GL_NO_ERROR; | 181 return context3d->getGraphicsResetStatusARB() != GL_NO_ERROR; |
190 } | 182 } |
191 | 183 |
192 void DelegatingRenderer::setVisible(bool visible) { | 184 void DelegatingRenderer::setVisible(bool visible) { |
193 visible_ = visible; | 185 visible_ = visible; |
194 } | 186 } |
195 | 187 |
196 void DelegatingRenderer::onContextLost() { | |
197 m_client->didLoseOutputSurface(); | |
198 } | |
199 | |
200 } // namespace cc | 188 } // namespace cc |
OLD | NEW |