Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 6 #define CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #if defined(ENABLE_GPU) | 9 #if defined(ENABLE_GPU) |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/logging.h" | |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "content/renderer/gpu/renderer_gl_context.h" | 15 #include "content/renderer/gpu/renderer_gl_context.h" |
| 16 #include "googleurl/src/gurl.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 18 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 19 | 21 |
| 20 #if !defined(OS_MACOSX) | 22 #if !defined(OS_MACOSX) |
| 21 #define FLIP_FRAMEBUFFER_VERTICALLY | 23 #define FLIP_FRAMEBUFFER_VERTICALLY |
| 22 #endif | 24 #endif |
| 23 | 25 |
| 24 class GpuChannelHost; | 26 class GpuChannelHost; |
| 25 class CommandBufferProxy; | 27 class CommandBufferProxy; |
| 28 class MessageLoop; | |
| 26 | 29 |
| 27 namespace gpu { | 30 namespace gpu { |
| 28 namespace gles2 { | 31 namespace gles2 { |
| 29 class GLES2Implementation; | 32 class GLES2Implementation; |
| 30 } | 33 } |
| 31 } | 34 } |
| 32 | 35 |
| 33 using WebKit::WebGLId; | 36 using WebKit::WebGLId; |
| 34 | 37 |
| 35 using WebKit::WGC3Dchar; | 38 using WebKit::WGC3Dchar; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 50 | 53 |
| 51 WebGraphicsContext3DCommandBufferImpl(); | 54 WebGraphicsContext3DCommandBufferImpl(); |
| 52 virtual ~WebGraphicsContext3DCommandBufferImpl(); | 55 virtual ~WebGraphicsContext3DCommandBufferImpl(); |
| 53 | 56 |
| 54 //---------------------------------------------------------------------- | 57 //---------------------------------------------------------------------- |
| 55 // WebGraphicsContext3D methods | 58 // WebGraphicsContext3D methods |
| 56 virtual bool initialize(WebGraphicsContext3D::Attributes attributes, | 59 virtual bool initialize(WebGraphicsContext3D::Attributes attributes, |
| 57 WebKit::WebView*, | 60 WebKit::WebView*, |
| 58 bool renderDirectlyToWebView); | 61 bool renderDirectlyToWebView); |
| 59 | 62 |
| 63 // Must be called after initialize() and before any of the following methods. | |
| 64 // Binds this object to the current thread. We can't bind to multiple threads. | |
| 65 // TODO(husky): Document threading restrictions in WebGraphicsContext3D.h, | |
| 66 // enforce strictly in all implementations. | |
| 60 virtual bool makeContextCurrent(); | 67 virtual bool makeContextCurrent(); |
| 61 | 68 |
| 62 virtual int width(); | 69 virtual int width(); |
| 63 virtual int height(); | 70 virtual int height(); |
| 64 | 71 |
| 65 virtual bool isGLES2Compliant(); | 72 virtual bool isGLES2Compliant(); |
| 66 | 73 |
| 67 virtual bool setParentContext(WebGraphicsContext3D* parent_context); | 74 virtual bool setParentContext(WebGraphicsContext3D* parent_context); |
| 68 | 75 |
| 69 virtual void reshape(int width, int height); | 76 virtual void reshape(int width, int height); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 | 431 |
| 425 virtual void setContextLostCallback( | 432 virtual void setContextLostCallback( |
| 426 WebGraphicsContext3D::WebGraphicsContextLostCallback* callback); | 433 WebGraphicsContext3D::WebGraphicsContextLostCallback* callback); |
| 427 virtual WGC3Denum getGraphicsResetStatusARB(); | 434 virtual WGC3Denum getGraphicsResetStatusARB(); |
| 428 | 435 |
| 429 virtual void setSwapBuffersCompleteCallbackCHROMIUM( | 436 virtual void setSwapBuffersCompleteCallbackCHROMIUM( |
| 430 WebGraphicsContext3D:: | 437 WebGraphicsContext3D:: |
| 431 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback); | 438 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback); |
| 432 | 439 |
| 433 private: | 440 private: |
| 441 // Initialize the underlying GL context. May be called multiple times; second | |
| 442 // and subsequent calls are ignored. Must be called from the thread that is | |
| 443 // going to use this object to issue GL commands (which might not be the main | |
| 444 // thread). | |
| 445 bool MaybeInitializeGL(); | |
| 446 | |
| 434 // SwapBuffers callback. | 447 // SwapBuffers callback. |
| 435 void OnSwapBuffersComplete(); | 448 void OnSwapBuffersComplete(); |
| 436 virtual void OnContextLost(RendererGLContext::ContextLostReason reason); | 449 virtual void OnContextLost(RendererGLContext::ContextLostReason reason); |
| 437 | 450 |
| 438 // The context we use for OpenGL rendering. | 451 // The context we use for OpenGL rendering. |
| 439 RendererGLContext* context_; | 452 RendererGLContext* context_; |
| 440 // The GLES2Implementation we use for OpenGL rendering. | 453 // The GLES2Implementation we use for OpenGL rendering. |
| 441 gpu::gles2::GLES2Implementation* gl_; | 454 gpu::gles2::GLES2Implementation* gl_; |
| 455 #ifndef NDEBUG | |
| 456 // Used to assert that GL commands are issued from a single thread. | |
| 457 MessageLoop* gl_message_loop_; | |
|
nduca
2011/08/25 02:10:01
owning_message_loop_?
Can we get this more via a
lain Merrick
2011/08/25 19:55:16
Great idea, done.
| |
| 458 #endif | |
| 459 | |
| 460 // State needed by InitializeGLES2. | |
| 461 GpuChannelHost* host_; | |
| 462 GURL active_url_; | |
| 463 int32 render_view_routing_id_; | |
| 442 | 464 |
| 443 bool render_directly_to_web_view_; | 465 bool render_directly_to_web_view_; |
| 444 #ifndef WTF_USE_THREADED_COMPOSITING | 466 #ifndef WTF_USE_THREADED_COMPOSITING |
| 445 // If rendering directly to WebView, weak pointer to it. | 467 // If rendering directly to WebView, weak pointer to it. |
| 446 WebKit::WebView* web_view_; | 468 WebKit::WebView* web_view_; |
| 447 #endif | 469 #endif |
| 448 #if defined(OS_MACOSX) | 470 #if defined(OS_MACOSX) |
| 449 // "Fake" plugin window handle in browser process for the compositor's output. | 471 // "Fake" plugin window handle in browser process for the compositor's output. |
| 450 gfx::PluginWindowHandle plugin_handle_; | 472 gfx::PluginWindowHandle plugin_handle_; |
| 451 #endif | 473 #endif |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 467 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | 489 #ifdef FLIP_FRAMEBUFFER_VERTICALLY |
| 468 scoped_array<uint8> scanline_; | 490 scoped_array<uint8> scanline_; |
| 469 void FlipVertically(uint8* framebuffer, | 491 void FlipVertically(uint8* framebuffer, |
| 470 unsigned int width, | 492 unsigned int width, |
| 471 unsigned int height); | 493 unsigned int height); |
| 472 #endif | 494 #endif |
| 473 }; | 495 }; |
| 474 | 496 |
| 475 #endif // defined(ENABLE_GPU) | 497 #endif // defined(ENABLE_GPU) |
| 476 #endif // CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 498 #endif // CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
| OLD | NEW |