Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/common/gpu/texture_image_transport_surface.h" | 5 #include "content/common/gpu/texture_image_transport_surface.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "content/common/gpu/gl_scoped_binders.h" | 11 #include "content/common/gpu/gl_scoped_binders.h" |
| 12 #include "content/common/gpu/gpu_channel.h" | 12 #include "content/common/gpu/gpu_channel.h" |
| 13 #include "content/common/gpu/gpu_channel_manager.h" | 13 #include "content/common/gpu/gpu_channel_manager.h" |
| 14 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
| 15 #include "content/common/gpu/sync_point_manager.h" | 15 #include "content/common/gpu/sync_point_manager.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 #include "gpu/command_buffer/service/context_group.h" | 17 #include "gpu/command_buffer/service/context_group.h" |
| 18 #include "gpu/command_buffer/service/gpu_scheduler.h" | 18 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 19 #include "gpu/command_buffer/service/texture_manager.h" | 19 #include "gpu/command_buffer/service/texture_manager.h" |
| 20 #include "ui/gl/gl_surface_egl.h" | |
| 20 | 21 |
| 21 using gpu::gles2::ContextGroup; | 22 using gpu::gles2::ContextGroup; |
| 22 using gpu::gles2::TextureManager; | 23 using gpu::gles2::TextureManager; |
| 23 typedef TextureManager::TextureInfo TextureInfo; | 24 typedef TextureManager::TextureInfo TextureInfo; |
| 24 | 25 |
| 25 TextureImageTransportSurface::Texture::Texture() | 26 TextureImageTransportSurface::Texture::Texture() |
| 26 : client_id(0), | 27 : client_id(0), |
| 27 sent_to_client(false) { | 28 sent_to_client(false) { |
| 28 } | 29 } |
| 29 | 30 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 texture_manager->SetParameter( | 82 texture_manager->SetParameter( |
| 82 texture.info, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 83 texture.info, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 83 texture_manager->SetParameter( | 84 texture_manager->SetParameter( |
| 84 texture.info, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 85 texture.info, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 85 texture_manager->SetParameter( | 86 texture_manager->SetParameter( |
| 86 texture.info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 87 texture.info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 87 texture_manager->SetParameter( | 88 texture_manager->SetParameter( |
| 88 texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 89 texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 89 } | 90 } |
| 90 | 91 |
| 91 if (!helper_->Initialize()) | 92 surface_ = new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1)); |
|
piman
2012/09/18 00:19:42
This'll break because we don't have EGL on all pla
no sievers
2012/09/18 00:41:27
Done.
| |
| 93 if (!helper_->Initialize() || | |
| 94 !surface_->Initialize()) | |
| 92 return false; | 95 return false; |
| 93 | 96 |
| 94 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 97 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 95 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) | 98 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) |
| 96 helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount()); | 99 helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount()); |
| 97 | 100 |
| 98 return true; | 101 return true; |
| 99 } | 102 } |
| 100 | 103 |
| 101 void TextureImageTransportSurface::Destroy() { | 104 void TextureImageTransportSurface::Destroy() { |
| 102 if (parent_stub_) { | 105 if (parent_stub_) { |
| 103 parent_stub_->decoder()->MakeCurrent(); | 106 parent_stub_->decoder()->MakeCurrent(); |
| 104 ReleaseParentStub(); | 107 ReleaseParentStub(); |
| 105 } | 108 } |
| 106 | 109 |
| 110 if (surface_.get()) { | |
| 111 surface_->Destroy(); | |
| 112 surface_ = NULL; | |
| 113 } | |
| 114 | |
| 107 helper_->Destroy(); | 115 helper_->Destroy(); |
| 108 } | 116 } |
| 109 | 117 |
| 110 bool TextureImageTransportSurface::Resize(const gfx::Size&) { | 118 bool TextureImageTransportSurface::Resize(const gfx::Size&) { |
| 111 return true; | 119 return true; |
| 112 } | 120 } |
| 113 | 121 |
| 114 bool TextureImageTransportSurface::IsOffscreen() { | 122 bool TextureImageTransportSurface::IsOffscreen() { |
| 115 return parent_stub_ ? parent_stub_->surface()->IsOffscreen() : true; | 123 return true; |
| 116 } | 124 } |
| 117 | 125 |
| 118 bool TextureImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 126 bool TextureImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
| 119 if (stub_destroyed_) { | 127 if (stub_destroyed_) { |
| 120 // Early-exit so that we don't recreate the fbo. We still want to return | 128 // Early-exit so that we don't recreate the fbo. We still want to return |
| 121 // true, so that the context is made current and the GLES2DecoderImpl can | 129 // true, so that the context is made current and the GLES2DecoderImpl can |
| 122 // release its own resources. | 130 // release its own resources. |
| 123 return true; | 131 return true; |
| 124 } | 132 } |
| 125 | 133 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 if (textures_[front()].sent_to_client) { | 190 if (textures_[front()].sent_to_client) { |
| 183 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 191 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
| 184 params.identifier = textures_[front()].client_id; | 192 params.identifier = textures_[front()].client_id; |
| 185 helper_->SendAcceleratedSurfaceRelease(params); | 193 helper_->SendAcceleratedSurfaceRelease(params); |
| 186 textures_[front()].sent_to_client = false; | 194 textures_[front()].sent_to_client = false; |
| 187 } | 195 } |
| 188 } | 196 } |
| 189 } | 197 } |
| 190 | 198 |
| 191 void* TextureImageTransportSurface::GetShareHandle() { | 199 void* TextureImageTransportSurface::GetShareHandle() { |
| 192 return GetHandle(); | 200 return GetHandle(); |
|
no sievers
2012/09/18 00:17:01
Is this only used on Windows?
Should this do NOTRE
| |
| 193 } | 201 } |
| 194 | 202 |
| 195 void* TextureImageTransportSurface::GetDisplay() { | 203 void* TextureImageTransportSurface::GetDisplay() { |
| 196 return parent_stub_ ? parent_stub_->surface()->GetDisplay() : NULL; | 204 return surface_.get() ? surface_->GetDisplay() : NULL; |
| 197 } | 205 } |
| 198 | 206 |
| 199 void* TextureImageTransportSurface::GetConfig() { | 207 void* TextureImageTransportSurface::GetConfig() { |
| 200 return parent_stub_ ? parent_stub_->surface()->GetConfig() : NULL; | 208 return surface_.get() ? surface_->GetConfig() : NULL; |
| 201 } | 209 } |
| 202 | 210 |
| 203 void TextureImageTransportSurface::OnResize(gfx::Size size) { | 211 void TextureImageTransportSurface::OnResize(gfx::Size size) { |
| 204 CreateBackTexture(size); | 212 CreateBackTexture(size); |
| 205 } | 213 } |
| 206 | 214 |
| 207 void TextureImageTransportSurface::OnWillDestroyStub( | 215 void TextureImageTransportSurface::OnWillDestroyStub( |
| 208 GpuCommandBufferStub* stub) { | 216 GpuCommandBufferStub* stub) { |
| 209 if (stub == parent_stub_) { | 217 if (stub == parent_stub_) { |
| 210 ReleaseParentStub(); | 218 ReleaseParentStub(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 | 336 |
| 329 gfx::Size TextureImageTransportSurface::GetSize() { | 337 gfx::Size TextureImageTransportSurface::GetSize() { |
| 330 gfx::Size size = textures_[back()].size; | 338 gfx::Size size = textures_[back()].size; |
| 331 | 339 |
| 332 // OSMesa expects a non-zero size. | 340 // OSMesa expects a non-zero size. |
| 333 return gfx::Size(size.width() == 0 ? 1 : size.width(), | 341 return gfx::Size(size.width() == 0 ? 1 : size.width(), |
| 334 size.height() == 0 ? 1 : size.height()); | 342 size.height() == 0 ? 1 : size.height()); |
| 335 } | 343 } |
| 336 | 344 |
| 337 void* TextureImageTransportSurface::GetHandle() { | 345 void* TextureImageTransportSurface::GetHandle() { |
| 338 return parent_stub_ ? parent_stub_->surface()->GetHandle() : NULL; | 346 return surface_.get() ? surface_->GetHandle() : NULL; |
| 339 } | 347 } |
| 340 | 348 |
| 341 unsigned TextureImageTransportSurface::GetFormat() { | 349 unsigned TextureImageTransportSurface::GetFormat() { |
| 342 return parent_stub_ ? parent_stub_->surface()->GetFormat() : 0; | 350 return surface_ ? surface_->GetFormat() : 0; |
| 343 } | 351 } |
| 344 | 352 |
| 345 void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected( | 353 void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected( |
| 346 bool is_protected, uint32 protection_state_id) { | 354 bool is_protected, uint32 protection_state_id) { |
| 347 protection_state_id_ = protection_state_id; | 355 protection_state_id_ = protection_state_id; |
| 348 if (frontbuffer_is_protected_ == is_protected) | 356 if (frontbuffer_is_protected_ == is_protected) |
| 349 return; | 357 return; |
| 350 frontbuffer_is_protected_ = is_protected; | 358 frontbuffer_is_protected_ = is_protected; |
| 351 AdjustFrontBufferAllocation(); | 359 AdjustFrontBufferAllocation(); |
| 352 | 360 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 Texture& texture = textures_[i]; | 514 Texture& texture = textures_[i]; |
| 507 texture.info = NULL; | 515 texture.info = NULL; |
| 508 if (!texture.sent_to_client) | 516 if (!texture.sent_to_client) |
| 509 continue; | 517 continue; |
| 510 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 518 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
| 511 params.identifier = texture.client_id; | 519 params.identifier = texture.client_id; |
| 512 helper_->SendAcceleratedSurfaceRelease(params); | 520 helper_->SendAcceleratedSurfaceRelease(params); |
| 513 } | 521 } |
| 514 parent_stub_ = NULL; | 522 parent_stub_ = NULL; |
| 515 } | 523 } |
| OLD | NEW |