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

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: Created 8 years, 3 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
« no previous file with comments | « content/common/gpu/texture_image_transport_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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 20
21 using gpu::gles2::ContextGroup; 21 using gpu::gles2::ContextGroup;
22 using gpu::gles2::TextureManager; 22 using gpu::gles2::TextureManager;
23 typedef TextureManager::TextureInfo TextureInfo; 23 typedef TextureManager::TextureInfo TextureInfo;
24 24
25 scoped_refptr<gfx::GLSurface> TextureImageTransportSurface::surface_;
piman 2012/09/24 21:18:36 We don't allow non-POD globals.
hshi1 2012/09/24 21:38:40 In Patch Set #2 I've moved the global singleton to
26
25 TextureImageTransportSurface::Texture::Texture() 27 TextureImageTransportSurface::Texture::Texture()
26 : client_id(0), 28 : client_id(0),
27 sent_to_client(false) { 29 sent_to_client(false) {
28 } 30 }
29 31
30 TextureImageTransportSurface::Texture::~Texture() { 32 TextureImageTransportSurface::Texture::~Texture() {
31 } 33 }
32 34
33 TextureImageTransportSurface::TextureImageTransportSurface( 35 TextureImageTransportSurface::TextureImageTransportSurface(
34 GpuChannelManager* manager, 36 GpuChannelManager* manager,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 texture_manager->SetParameter( 83 texture_manager->SetParameter(
82 texture.info, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 84 texture.info, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
83 texture_manager->SetParameter( 85 texture_manager->SetParameter(
84 texture.info, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 86 texture.info, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
85 texture_manager->SetParameter( 87 texture_manager->SetParameter(
86 texture.info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 88 texture.info, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
87 texture_manager->SetParameter( 89 texture_manager->SetParameter(
88 texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 90 texture.info, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
89 } 91 }
90 92
91 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1)); 93 if (!surface_.get())
94 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1));
95 else
96 surface_->AddRef();
97
92 if (!surface_.get()) 98 if (!surface_.get())
93 return false; 99 return false;
94 100
95 if (!helper_->Initialize()) 101 if (!helper_->Initialize())
96 return false; 102 return false;
97 103
98 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 104 const CommandLine* command_line = CommandLine::ForCurrentProcess();
99 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) 105 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess))
100 helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount()); 106 helper_->SetPreemptByCounter(parent_channel->MessagesPendingCount());
101 107
102 return true; 108 return true;
103 } 109 }
104 110
105 void TextureImageTransportSurface::Destroy() { 111 void TextureImageTransportSurface::Destroy() {
106 if (parent_stub_) { 112 if (parent_stub_) {
107 parent_stub_->decoder()->MakeCurrent(); 113 parent_stub_->decoder()->MakeCurrent();
108 ReleaseParentStub(); 114 ReleaseParentStub();
109 } 115 }
110 116
111 if (surface_.get()) { 117 if (surface_.get()) {
112 surface_->Destroy(); 118 if (surface_->HasOneRef()) {
113 surface_ = NULL; 119 surface_->Destroy();
120 surface_ = NULL;
121 } else {
122 surface_->Release();
123 }
114 } 124 }
115 125
116 helper_->Destroy(); 126 helper_->Destroy();
117 } 127 }
118 128
119 bool TextureImageTransportSurface::Resize(const gfx::Size&) { 129 bool TextureImageTransportSurface::Resize(const gfx::Size&) {
120 return true; 130 return true;
121 } 131 }
122 132
123 bool TextureImageTransportSurface::IsOffscreen() { 133 bool TextureImageTransportSurface::IsOffscreen() {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 Texture& texture = textures_[i]; 525 Texture& texture = textures_[i];
516 texture.info = NULL; 526 texture.info = NULL;
517 if (!texture.sent_to_client) 527 if (!texture.sent_to_client)
518 continue; 528 continue;
519 GpuHostMsg_AcceleratedSurfaceRelease_Params params; 529 GpuHostMsg_AcceleratedSurfaceRelease_Params params;
520 params.identifier = texture.client_id; 530 params.identifier = texture.client_id;
521 helper_->SendAcceleratedSurfaceRelease(params); 531 helper_->SendAcceleratedSurfaceRelease(params);
522 } 532 }
523 parent_stub_ = NULL; 533 parent_stub_ = NULL;
524 } 534 }
OLDNEW
« no previous file with comments | « content/common/gpu/texture_image_transport_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698