| 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" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 texture_manager->SetParameter( | 81 texture_manager->SetParameter( |
| 82 texture.info, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 82 texture.info, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 83 texture_manager->SetParameter( | 83 texture_manager->SetParameter( |
| 84 texture.info, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 84 texture.info, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 85 texture_manager->SetParameter( | 85 texture_manager->SetParameter( |
| 86 texture.info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 86 texture.info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 87 texture_manager->SetParameter( | 87 texture_manager->SetParameter( |
| 88 texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 88 texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 89 } | 89 } |
| 90 | 90 |
| 91 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1)); | 91 surface_ = manager->GetDefaultOffscreenSurface(); |
| 92 if (!surface_.get()) | 92 if (!surface_.get()) |
| 93 return false; | 93 return false; |
| 94 | 94 |
| 95 if (!helper_->Initialize()) | 95 if (!helper_->Initialize()) |
| 96 return false; | 96 return false; |
| 97 | 97 |
| 98 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 98 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 99 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) | 99 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) |
| 100 helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount()); | 100 helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount()); |
| 101 | 101 |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 void TextureImageTransportSurface::Destroy() { | 105 void TextureImageTransportSurface::Destroy() { |
| 106 if (parent_stub_) { | 106 if (parent_stub_) { |
| 107 parent_stub_->decoder()->MakeCurrent(); | 107 parent_stub_->decoder()->MakeCurrent(); |
| 108 ReleaseParentStub(); | 108 ReleaseParentStub(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (surface_.get()) { | 111 if (surface_.get()) |
| 112 surface_->Destroy(); | |
| 113 surface_ = NULL; | 112 surface_ = NULL; |
| 114 } | |
| 115 | 113 |
| 116 helper_->Destroy(); | 114 helper_->Destroy(); |
| 117 } | 115 } |
| 118 | 116 |
| 119 bool TextureImageTransportSurface::Resize(const gfx::Size&) { | 117 bool TextureImageTransportSurface::Resize(const gfx::Size&) { |
| 120 return true; | 118 return true; |
| 121 } | 119 } |
| 122 | 120 |
| 123 bool TextureImageTransportSurface::IsOffscreen() { | 121 bool TextureImageTransportSurface::IsOffscreen() { |
| 124 return true; | 122 return true; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 // OSMesa expects a non-zero size. | 339 // OSMesa expects a non-zero size. |
| 342 return gfx::Size(size.width() == 0 ? 1 : size.width(), | 340 return gfx::Size(size.width() == 0 ? 1 : size.width(), |
| 343 size.height() == 0 ? 1 : size.height()); | 341 size.height() == 0 ? 1 : size.height()); |
| 344 } | 342 } |
| 345 | 343 |
| 346 void* TextureImageTransportSurface::GetHandle() { | 344 void* TextureImageTransportSurface::GetHandle() { |
| 347 return surface_.get() ? surface_->GetHandle() : NULL; | 345 return surface_.get() ? surface_->GetHandle() : NULL; |
| 348 } | 346 } |
| 349 | 347 |
| 350 unsigned TextureImageTransportSurface::GetFormat() { | 348 unsigned TextureImageTransportSurface::GetFormat() { |
| 351 return surface_ ? surface_->GetFormat() : 0; | 349 return surface_.get() ? surface_->GetFormat() : 0; |
| 352 } | 350 } |
| 353 | 351 |
| 354 void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected( | 352 void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected( |
| 355 bool is_protected, uint32 protection_state_id) { | 353 bool is_protected, uint32 protection_state_id) { |
| 356 protection_state_id_ = protection_state_id; | 354 protection_state_id_ = protection_state_id; |
| 357 if (frontbuffer_is_protected_ == is_protected) | 355 if (frontbuffer_is_protected_ == is_protected) |
| 358 return; | 356 return; |
| 359 frontbuffer_is_protected_ = is_protected; | 357 frontbuffer_is_protected_ = is_protected; |
| 360 AdjustFrontBufferAllocation(); | 358 AdjustFrontBufferAllocation(); |
| 361 | 359 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 Texture& texture = textures_[i]; | 513 Texture& texture = textures_[i]; |
| 516 texture.info = NULL; | 514 texture.info = NULL; |
| 517 if (!texture.sent_to_client) | 515 if (!texture.sent_to_client) |
| 518 continue; | 516 continue; |
| 519 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 517 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
| 520 params.identifier = texture.client_id; | 518 params.identifier = texture.client_id; |
| 521 helper_->SendAcceleratedSurfaceRelease(params); | 519 helper_->SendAcceleratedSurfaceRelease(params); |
| 522 } | 520 } |
| 523 parent_stub_ = NULL; | 521 parent_stub_ = NULL; |
| 524 } | 522 } |
| OLD | NEW |