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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 8060045: Use shared D3D9 texture to transport the compositor's backing buffer to the browser... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 const gfx::Size& size, 500 const gfx::Size& size,
501 const DisallowedFeatures& disallowed_features, 501 const DisallowedFeatures& disallowed_features,
502 const char* allowed_extensions, 502 const char* allowed_extensions,
503 const std::vector<int32>& attribs); 503 const std::vector<int32>& attribs);
504 virtual void Destroy(); 504 virtual void Destroy();
505 virtual bool SetParent(GLES2Decoder* parent_decoder, 505 virtual bool SetParent(GLES2Decoder* parent_decoder,
506 uint32 parent_texture_id); 506 uint32 parent_texture_id);
507 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); 507 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size);
508 void UpdateParentTextureInfo(); 508 void UpdateParentTextureInfo();
509 virtual bool MakeCurrent(); 509 virtual bool MakeCurrent();
510 virtual void ReleaseCurrent();
510 virtual GLES2Util* GetGLES2Util() { return &util_; } 511 virtual GLES2Util* GetGLES2Util() { return &util_; }
511 virtual gfx::GLContext* GetGLContext() { return context_.get(); } 512 virtual gfx::GLContext* GetGLContext() { return context_.get(); }
512 virtual gfx::GLSurface* GetGLSurface() { return surface_.get(); } 513 virtual gfx::GLSurface* GetGLSurface() { return surface_.get(); }
513 virtual ContextGroup* GetContextGroup() { return group_.get(); } 514 virtual ContextGroup* GetContextGroup() { return group_.get(); }
514 515
515 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback); 516 virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback);
516 517
517 #if defined(OS_MACOSX)
518 virtual void SetSwapBuffersCallback(Callback0::Type* callback); 518 virtual void SetSwapBuffersCallback(Callback0::Type* callback);
519 #endif
520 519
521 virtual void SetStreamTextureManager(StreamTextureManager* manager); 520 virtual void SetStreamTextureManager(StreamTextureManager* manager);
522 virtual bool GetServiceTextureId(uint32 client_texture_id, 521 virtual bool GetServiceTextureId(uint32 client_texture_id,
523 uint32* service_texture_id); 522 uint32* service_texture_id);
524 523
525 // Restores the current state to the user's settings. 524 // Restores the current state to the user's settings.
526 void RestoreCurrentFramebufferBindings(); 525 void RestoreCurrentFramebufferBindings();
527 void RestoreCurrentRenderbufferBindings(); 526 void RestoreCurrentRenderbufferBindings();
528 void RestoreCurrentTexture2DBindings(); 527 void RestoreCurrentTexture2DBindings();
529 528
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; 1316 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_;
1318 scoped_ptr<Texture> offscreen_saved_color_texture_; 1317 scoped_ptr<Texture> offscreen_saved_color_texture_;
1319 1318
1320 // The copy that is used as the destination for multi-sample resolves. 1319 // The copy that is used as the destination for multi-sample resolves.
1321 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; 1320 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_;
1322 scoped_ptr<Texture> offscreen_resolved_color_texture_; 1321 scoped_ptr<Texture> offscreen_resolved_color_texture_;
1323 GLenum offscreen_saved_color_format_; 1322 GLenum offscreen_saved_color_format_;
1324 1323
1325 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_; 1324 scoped_ptr<Callback1<gfx::Size>::Type> resize_callback_;
1326 1325
1327 #if defined(OS_MACOSX)
1328 scoped_ptr<Callback0::Type> swap_buffers_callback_; 1326 scoped_ptr<Callback0::Type> swap_buffers_callback_;
1329 #endif
1330 1327
1331 StreamTextureManager* stream_texture_manager_; 1328 StreamTextureManager* stream_texture_manager_;
1332 1329
1333 // The format of the back buffer_ 1330 // The format of the back buffer_
1334 GLenum back_buffer_color_format_; 1331 GLenum back_buffer_color_format_;
1335 bool back_buffer_has_depth_; 1332 bool back_buffer_has_depth_;
1336 bool back_buffer_has_stencil_; 1333 bool back_buffer_has_stencil_;
1337 1334
1338 bool teximage2d_faster_than_texsubimage2d_; 1335 bool teximage2d_faster_than_texsubimage2d_;
1339 bool bufferdata_faster_than_buffersubdata_; 1336 bool bufferdata_faster_than_buffersubdata_;
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 bool GLES2DecoderImpl::MakeCurrent() { 2213 bool GLES2DecoderImpl::MakeCurrent() {
2217 bool result = context_.get() ? context_->MakeCurrent(surface_.get()) : false; 2214 bool result = context_.get() ? context_->MakeCurrent(surface_.get()) : false;
2218 if (result && WasContextLost()) { 2215 if (result && WasContextLost()) {
2219 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; 2216 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent.";
2220 result = false; 2217 result = false;
2221 } 2218 }
2222 2219
2223 return result; 2220 return result;
2224 } 2221 }
2225 2222
2223 void GLES2DecoderImpl::ReleaseCurrent() {
2224 if (context_.get())
2225 context_->ReleaseCurrent(surface_.get());
2226 }
2227
2226 void GLES2DecoderImpl::RestoreCurrentRenderbufferBindings() { 2228 void GLES2DecoderImpl::RestoreCurrentRenderbufferBindings() {
2227 glBindRenderbufferEXT( 2229 glBindRenderbufferEXT(
2228 GL_RENDERBUFFER, 2230 GL_RENDERBUFFER,
2229 bound_renderbuffer_ ? bound_renderbuffer_->service_id() : 0); 2231 bound_renderbuffer_ ? bound_renderbuffer_->service_id() : 0);
2230 } 2232 }
2231 2233
2232 static void RebindCurrentFramebuffer( 2234 static void RebindCurrentFramebuffer(
2233 GLenum target, 2235 GLenum target,
2234 FramebufferManager::FramebufferInfo* info, 2236 FramebufferManager::FramebufferInfo* info,
2235 FrameBuffer* offscreen_frame_buffer) { 2237 FrameBuffer* offscreen_frame_buffer) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 GL_TEXTURE_WRAP_T, 2366 GL_TEXTURE_WRAP_T,
2365 GL_CLAMP_TO_EDGE); 2367 GL_CLAMP_TO_EDGE);
2366 } 2368 }
2367 } 2369 }
2368 2370
2369 void GLES2DecoderImpl::SetResizeCallback( 2371 void GLES2DecoderImpl::SetResizeCallback(
2370 Callback1<gfx::Size>::Type* callback) { 2372 Callback1<gfx::Size>::Type* callback) {
2371 resize_callback_.reset(callback); 2373 resize_callback_.reset(callback);
2372 } 2374 }
2373 2375
2374 #if defined(OS_MACOSX)
2375 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) { 2376 void GLES2DecoderImpl::SetSwapBuffersCallback(Callback0::Type* callback) {
2376 swap_buffers_callback_.reset(callback); 2377 swap_buffers_callback_.reset(callback);
2377 } 2378 }
2378 #endif
2379 2379
2380 void GLES2DecoderImpl::SetStreamTextureManager(StreamTextureManager* manager) { 2380 void GLES2DecoderImpl::SetStreamTextureManager(StreamTextureManager* manager) {
2381 stream_texture_manager_ = manager; 2381 stream_texture_manager_ = manager;
2382 } 2382 }
2383 2383
2384 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, 2384 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id,
2385 uint32* service_texture_id) { 2385 uint32* service_texture_id) {
2386 TextureManager::TextureInfo* texture = 2386 TextureManager::TextureInfo* texture =
2387 texture_manager()->GetTextureInfo(client_texture_id); 2387 texture_manager()->GetTextureInfo(client_texture_id);
2388 if (texture) { 2388 if (texture) {
(...skipping 4455 matching lines...) Expand 10 before | Expand all | Expand 10 after
6844 6844
6845 UpdateParentTextureInfo(); 6845 UpdateParentTextureInfo();
6846 } 6846 }
6847 6847
6848 ScopedGLErrorSuppressor suppressor(this); 6848 ScopedGLErrorSuppressor suppressor(this);
6849 6849
6850 if (IsOffscreenBufferMultisampled()) { 6850 if (IsOffscreenBufferMultisampled()) {
6851 // For multisampled buffers, bind the resolved frame buffer so that 6851 // For multisampled buffers, bind the resolved frame buffer so that
6852 // callbacks can call ReadPixels or CopyTexImage2D. 6852 // callbacks can call ReadPixels or CopyTexImage2D.
6853 ScopedResolvedFrameBufferBinder binder(this, true, false); 6853 ScopedResolvedFrameBufferBinder binder(this, true, false);
6854 #if defined(OS_MACOSX)
6855 if (swap_buffers_callback_.get()) { 6854 if (swap_buffers_callback_.get()) {
6856 swap_buffers_callback_->Run(); 6855 swap_buffers_callback_->Run();
6857 } 6856 }
6858 #endif 6857
6859 return error::kNoError; 6858 return error::kNoError;
6860 } else { 6859 } else {
6861 ScopedFrameBufferBinder binder(this, 6860 ScopedFrameBufferBinder binder(this,
6862 offscreen_target_frame_buffer_->id()); 6861 offscreen_target_frame_buffer_->id());
6863 6862
6864 if (surface_->IsOffscreen()) { 6863 if (surface_->IsOffscreen()) {
6865 // Copy the target frame buffer to the saved offscreen texture. 6864 // Copy the target frame buffer to the saved offscreen texture.
6866 offscreen_saved_color_texture_->Copy( 6865 offscreen_saved_color_texture_->Copy(
6867 offscreen_saved_color_texture_->size(), 6866 offscreen_saved_color_texture_->size(),
6868 offscreen_saved_color_format_); 6867 offscreen_saved_color_format_);
6869 6868
6870 // Ensure the side effects of the copy are visible to the parent 6869 // Ensure the side effects of the copy are visible to the parent
6871 // context. There is no need to do this for ANGLE because it uses a 6870 // context. There is no need to do this for ANGLE because it uses a
6872 // single D3D device for all contexts. 6871 // single D3D device for all contexts.
6873 if (!IsAngle()) 6872 if (!IsAngle())
6874 glFlush(); 6873 glFlush();
6875 } 6874 }
6876 6875
6877 // Run the callback with |binder| in scope, so that the callback can call 6876 // Run the callback with |binder| in scope, so that the callback can call
6878 // ReadPixels or CopyTexImage2D. 6877 // ReadPixels or CopyTexImage2D.
6879 #if defined(OS_MACOSX)
6880 if (swap_buffers_callback_.get()) { 6878 if (swap_buffers_callback_.get()) {
6881 swap_buffers_callback_->Run(); 6879 swap_buffers_callback_->Run();
6882 } 6880 }
6883 #endif 6881
6884 return error::kNoError; 6882 return error::kNoError;
6885 } 6883 }
6886 } else { 6884 } else {
6887 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); 6885 TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number);
6888 if (!surface_->SwapBuffers()) { 6886 if (!surface_->SwapBuffers()) {
6889 LOG(ERROR) << "Context lost because SwapBuffers failed."; 6887 LOG(ERROR) << "Context lost because SwapBuffers failed.";
6890 return error::kLostContext; 6888 return error::kLostContext;
6891 } 6889 }
6892 } 6890 }
6893 6891
6894 #if defined(OS_MACOSX)
6895 if (swap_buffers_callback_.get()) { 6892 if (swap_buffers_callback_.get()) {
6896 swap_buffers_callback_->Run(); 6893 swap_buffers_callback_->Run();
6897 } 6894 }
6898 #endif
6899 6895
6900 return error::kNoError; 6896 return error::kNoError;
6901 } 6897 }
6902 6898
6903 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( 6899 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM(
6904 uint32 immediate_data_size, const gles2::EnableFeatureCHROMIUM& c) { 6900 uint32 immediate_data_size, const gles2::EnableFeatureCHROMIUM& c) {
6905 Bucket* bucket = GetBucket(c.bucket_id); 6901 Bucket* bucket = GetBucket(c.bucket_id);
6906 if (!bucket || bucket->size() == 0) { 6902 if (!bucket || bucket->size() == 0) {
6907 return error::kInvalidArguments; 6903 return error::kInvalidArguments;
6908 } 6904 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
7202 return error::kNoError; 7198 return error::kNoError;
7203 } 7199 }
7204 7200
7205 // Include the auto-generated part of this file. We split this because it means 7201 // Include the auto-generated part of this file. We split this because it means
7206 // we can easily edit the non-auto generated parts right here in this file 7202 // we can easily edit the non-auto generated parts right here in this file
7207 // instead of having to edit some template or the code generator. 7203 // instead of having to edit some template or the code generator.
7208 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 7204 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
7209 7205
7210 } // namespace gles2 7206 } // namespace gles2
7211 } // namespace gpu 7207 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698