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

Side by Side Diff: content/common/gpu/texture_image_transport_surface.cc

Issue 10984004: Use a singleton 1x1 offscreen surface for all TextureImageTransportSurface instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add the 1x1 surface into GpuChannelManager. Created 8 years, 2 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
OLDNEW
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
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->AllocMakeCurrentSurface();
92 if (!surface_.get()) 92 if (!surface_)
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_) {
112 surface_->Destroy(); 112 helper_->manager()->ReleaseMakeCurrentSurface();
113 surface_ = NULL; 113 surface_ = NULL;
114 } 114 }
115 115
116 helper_->Destroy(); 116 helper_->Destroy();
117 } 117 }
118 118
119 bool TextureImageTransportSurface::Resize(const gfx::Size&) { 119 bool TextureImageTransportSurface::Resize(const gfx::Size&) {
120 return true; 120 return true;
121 } 121 }
122 122
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 textures_[front()].sent_to_client = false; 195 textures_[front()].sent_to_client = false;
196 } 196 }
197 } 197 }
198 } 198 }
199 199
200 void* TextureImageTransportSurface::GetShareHandle() { 200 void* TextureImageTransportSurface::GetShareHandle() {
201 return GetHandle(); 201 return GetHandle();
202 } 202 }
203 203
204 void* TextureImageTransportSurface::GetDisplay() { 204 void* TextureImageTransportSurface::GetDisplay() {
205 return surface_.get() ? surface_->GetDisplay() : NULL; 205 return surface_ ? surface_->GetDisplay() : NULL;
206 } 206 }
207 207
208 void* TextureImageTransportSurface::GetConfig() { 208 void* TextureImageTransportSurface::GetConfig() {
209 return surface_.get() ? surface_->GetConfig() : NULL; 209 return surface_ ? surface_->GetConfig() : NULL;
210 } 210 }
211 211
212 void TextureImageTransportSurface::OnResize(gfx::Size size) { 212 void TextureImageTransportSurface::OnResize(gfx::Size size) {
213 CreateBackTexture(size); 213 CreateBackTexture(size);
214 } 214 }
215 215
216 void TextureImageTransportSurface::OnWillDestroyStub( 216 void TextureImageTransportSurface::OnWillDestroyStub(
217 GpuCommandBufferStub* stub) { 217 GpuCommandBufferStub* stub) {
218 if (stub == parent_stub_) { 218 if (stub == parent_stub_) {
219 ReleaseParentStub(); 219 ReleaseParentStub();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 gfx::Size TextureImageTransportSurface::GetSize() { 338 gfx::Size TextureImageTransportSurface::GetSize() {
339 gfx::Size size = textures_[back()].size; 339 gfx::Size size = textures_[back()].size;
340 340
341 // OSMesa expects a non-zero size. 341 // OSMesa expects a non-zero size.
342 return gfx::Size(size.width() == 0 ? 1 : size.width(), 342 return gfx::Size(size.width() == 0 ? 1 : size.width(),
343 size.height() == 0 ? 1 : size.height()); 343 size.height() == 0 ? 1 : size.height());
344 } 344 }
345 345
346 void* TextureImageTransportSurface::GetHandle() { 346 void* TextureImageTransportSurface::GetHandle() {
347 return surface_.get() ? surface_->GetHandle() : NULL; 347 return surface_ ? surface_->GetHandle() : NULL;
348 } 348 }
349 349
350 unsigned TextureImageTransportSurface::GetFormat() { 350 unsigned TextureImageTransportSurface::GetFormat() {
351 return surface_ ? surface_->GetFormat() : 0; 351 return surface_ ? surface_->GetFormat() : 0;
352 } 352 }
353 353
354 void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected( 354 void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected(
355 bool is_protected, uint32 protection_state_id) { 355 bool is_protected, uint32 protection_state_id) {
356 protection_state_id_ = protection_state_id; 356 protection_state_id_ = protection_state_id;
357 if (frontbuffer_is_protected_ == is_protected) 357 if (frontbuffer_is_protected_ == is_protected)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 Texture& texture = textures_[i]; 515 Texture& texture = textures_[i];
516 texture.info = NULL; 516 texture.info = NULL;
517 if (!texture.sent_to_client) 517 if (!texture.sent_to_client)
518 continue; 518 continue;
519 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 519 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
520 params.identifier = texture.client_id; 520 params.identifier = texture.client_id;
521 helper_->SendAcceleratedSurfaceRelease(params); 521 helper_->SendAcceleratedSurfaceRelease(params);
522 } 522 }
523 parent_stub_ = NULL; 523 parent_stub_ = NULL;
524 } 524 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698