| 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/output/delegating_renderer.h" | 5 #include "cc/output/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 DCHECK(resource_provider_); | 51 DCHECK(resource_provider_); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool DelegatingRenderer::Initialize() { | 54 bool DelegatingRenderer::Initialize() { |
| 55 capabilities_.using_partial_swap = false; | 55 capabilities_.using_partial_swap = false; |
| 56 capabilities_.max_texture_size = resource_provider_->max_texture_size(); | 56 capabilities_.max_texture_size = resource_provider_->max_texture_size(); |
| 57 capabilities_.best_texture_format = resource_provider_->best_texture_format(); | 57 capabilities_.best_texture_format = resource_provider_->best_texture_format(); |
| 58 capabilities_.allow_partial_texture_updates = false; | 58 capabilities_.allow_partial_texture_updates = false; |
| 59 capabilities_.using_offscreen_context3d = false; | 59 capabilities_.using_offscreen_context3d = false; |
| 60 | 60 |
| 61 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); | 61 if (!output_surface_->context_provider()) { |
| 62 | 62 // TODO(danakj): Make software compositing work. |
| 63 if (!context3d) { | |
| 64 // Software compositing. | |
| 65 return true; | 63 return true; |
| 66 } | 64 } |
| 67 | 65 |
| 66 WebGraphicsContext3D* context3d = |
| 67 output_surface_->context_provider()->Context3d(); |
| 68 |
| 68 if (!context3d->makeContextCurrent()) | 69 if (!context3d->makeContextCurrent()) |
| 69 return false; | 70 return false; |
| 70 | 71 |
| 71 std::string unique_context_name = base::StringPrintf( | 72 std::string unique_context_name = base::StringPrintf( |
| 72 "%s-%p", | 73 "%s-%p", |
| 73 Settings().compositor_name.c_str(), | 74 Settings().compositor_name.c_str(), |
| 74 context3d); | 75 context3d); |
| 75 context3d->pushGroupMarkerEXT(unique_context_name.c_str()); | 76 context3d->pushGroupMarkerEXT(unique_context_name.c_str()); |
| 76 | 77 |
| 77 std::string extensions_string = | 78 std::string extensions_string = |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 void DelegatingRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { | 165 void DelegatingRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { |
| 165 NOTREACHED(); | 166 NOTREACHED(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void DelegatingRenderer::ReceiveSwapBuffersAck( | 169 void DelegatingRenderer::ReceiveSwapBuffersAck( |
| 169 const CompositorFrameAck& ack) { | 170 const CompositorFrameAck& ack) { |
| 170 resource_provider_->ReceiveFromParent(ack.resources); | 171 resource_provider_->ReceiveFromParent(ack.resources); |
| 171 } | 172 } |
| 172 | 173 |
| 173 bool DelegatingRenderer::IsContextLost() { | 174 bool DelegatingRenderer::IsContextLost() { |
| 174 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); | 175 ContextProvider* context_provider = output_surface_->context_provider(); |
| 175 if (!context3d) | 176 if (!context_provider) |
| 176 return false; | 177 return false; |
| 177 return context3d->getGraphicsResetStatusARB() != GL_NO_ERROR; | 178 return context_provider->Context3d()->getGraphicsResetStatusARB() != |
| 179 GL_NO_ERROR; |
| 178 } | 180 } |
| 179 | 181 |
| 180 void DelegatingRenderer::SetVisible(bool visible) { | 182 void DelegatingRenderer::SetVisible(bool visible) { |
| 181 if (visible == visible_) | 183 if (visible == visible_) |
| 182 return; | 184 return; |
| 183 | 185 |
| 184 visible_ = visible; | 186 visible_ = visible; |
| 185 WebGraphicsContext3D* context = resource_provider_->GraphicsContext3D(); | 187 ContextProvider* context_provider = output_surface_->context_provider(); |
| 186 if (!visible_) { | 188 if (!visible_) { |
| 187 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources"); | 189 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources"); |
| 188 resource_provider_->ReleaseCachedData(); | 190 resource_provider_->ReleaseCachedData(); |
| 189 if (context) | 191 if (context_provider) |
| 190 context->flush(); | 192 context_provider->Context3d()->flush(); |
| 191 } | 193 } |
| 192 if (capabilities_.using_set_visibility) { | 194 if (capabilities_.using_set_visibility) { |
| 193 // We loop visibility to the GPU process, since that's what manages memory. | 195 // We loop visibility to the GPU process, since that's what manages memory. |
| 194 // That will allow it to feed us with memory allocations that we can act | 196 // That will allow it to feed us with memory allocations that we can act |
| 195 // upon. | 197 // upon. |
| 196 DCHECK(context); | 198 DCHECK(context_provider); |
| 197 context->setVisibilityCHROMIUM(visible); | 199 context_provider->Context3d()->setVisibilityCHROMIUM(visible); |
| 198 } | 200 } |
| 199 } | 201 } |
| 200 | 202 |
| 201 void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, | 203 void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, |
| 202 size_t bytes_visible_and_nearby, | 204 size_t bytes_visible_and_nearby, |
| 203 size_t bytes_allocated) { | 205 size_t bytes_allocated) { |
| 204 WebGraphicsContext3D* context = resource_provider_->GraphicsContext3D(); | 206 ContextProvider* context_provider = output_surface_->context_provider(); |
| 205 if (!context) { | 207 if (!context_provider) { |
| 206 // TODO(piman): software path. | 208 // TODO(piman): software path. |
| 207 NOTIMPLEMENTED(); | 209 NOTIMPLEMENTED(); |
| 208 return; | 210 return; |
| 209 } | 211 } |
| 210 WebKit::WebGraphicsManagedMemoryStats stats; | 212 WebKit::WebGraphicsManagedMemoryStats stats; |
| 211 stats.bytesVisible = bytes_visible; | 213 stats.bytesVisible = bytes_visible; |
| 212 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; | 214 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; |
| 213 stats.bytesAllocated = bytes_allocated; | 215 stats.bytesAllocated = bytes_allocated; |
| 214 stats.backbufferRequested = false; | 216 stats.backbufferRequested = false; |
| 215 context->sendManagedMemoryStatsCHROMIUM(&stats); | 217 context_provider->Context3d()->sendManagedMemoryStatsCHROMIUM(&stats); |
| 216 } | 218 } |
| 217 | 219 |
| 218 void DelegatingRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { | 220 void DelegatingRenderer::SetDiscardBackBufferWhenNotVisible(bool discard) { |
| 219 // Nothing to do, we don't have a back buffer. | 221 // Nothing to do, we don't have a back buffer. |
| 220 } | 222 } |
| 221 | 223 |
| 222 } // namespace cc | 224 } // namespace cc |
| OLD | NEW |