| 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 #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) | |
| 10 | |
| 11 #include <string> | 9 #include <string> |
| 12 #include <vector> | 10 #include <vector> |
| 13 | 11 |
| 14 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 16 #include "content/renderer/gpu/renderer_gl_context.h" | 14 #include "content/renderer/gpu/renderer_gl_context.h" |
| 17 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 40 using WebKit::WGC3Dboolean; | 38 using WebKit::WGC3Dboolean; |
| 41 using WebKit::WGC3Dbitfield; | 39 using WebKit::WGC3Dbitfield; |
| 42 using WebKit::WGC3Dint; | 40 using WebKit::WGC3Dint; |
| 43 using WebKit::WGC3Dsizei; | 41 using WebKit::WGC3Dsizei; |
| 44 using WebKit::WGC3Duint; | 42 using WebKit::WGC3Duint; |
| 45 using WebKit::WGC3Dfloat; | 43 using WebKit::WGC3Dfloat; |
| 46 using WebKit::WGC3Dclampf; | 44 using WebKit::WGC3Dclampf; |
| 47 using WebKit::WGC3Dintptr; | 45 using WebKit::WGC3Dintptr; |
| 48 using WebKit::WGC3Dsizeiptr; | 46 using WebKit::WGC3Dsizeiptr; |
| 49 | 47 |
| 48 // TODO(piman): move this logic to the compositor and remove it from the |
| 49 // context... |
| 50 class WebGraphicsContext3DSwapBuffersClient { |
| 51 public: |
| 52 virtual ~WebGraphicsContext3DSwapBuffersClient() { } |
| 53 virtual void OnViewContextSwapBuffersPosted() = 0; |
| 54 virtual void OnViewContextSwapBuffersComplete() = 0; |
| 55 virtual void OnViewContextSwapBuffersAborted() = 0; |
| 56 }; |
| 57 |
| 50 class WebGraphicsContext3DCommandBufferImpl | 58 class WebGraphicsContext3DCommandBufferImpl |
| 51 : public WebKit::WebGraphicsContext3D { | 59 : public WebKit::WebGraphicsContext3D { |
| 52 public: | 60 public: |
| 53 WebGraphicsContext3DCommandBufferImpl(); | 61 WebGraphicsContext3DCommandBufferImpl( |
| 62 int surface_id, |
| 63 const GURL& active_url, |
| 64 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client); |
| 54 virtual ~WebGraphicsContext3DCommandBufferImpl(); | 65 virtual ~WebGraphicsContext3DCommandBufferImpl(); |
| 55 | 66 |
| 67 bool Initialize(const Attributes& attributes); |
| 68 |
| 56 //---------------------------------------------------------------------- | 69 //---------------------------------------------------------------------- |
| 57 // WebGraphicsContext3D methods | 70 // WebGraphicsContext3D methods |
| 58 virtual bool initialize(WebGraphicsContext3D::Attributes attributes, | |
| 59 WebKit::WebView*, | |
| 60 bool renderDirectlyToWebView); | |
| 61 | 71 |
| 62 // Must be called after initialize() and before any of the following methods. | 72 // Must be called after initialize() and before any of the following methods. |
| 63 // Permanently binds to the first calling thread. Returns false if the | 73 // Permanently binds to the first calling thread. Returns false if the |
| 64 // graphics context fails to create. Do not call from more than one thread. | 74 // graphics context fails to create. Do not call from more than one thread. |
| 65 virtual bool makeContextCurrent(); | 75 virtual bool makeContextCurrent(); |
| 66 | 76 |
| 67 virtual int width(); | 77 virtual int width(); |
| 68 virtual int height(); | 78 virtual int height(); |
| 69 | 79 |
| 70 virtual bool isGLES2Compliant(); | 80 virtual bool isGLES2Compliant(); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 493 |
| 484 bool initialize_failed_; | 494 bool initialize_failed_; |
| 485 | 495 |
| 486 // The context we use for OpenGL rendering. | 496 // The context we use for OpenGL rendering. |
| 487 RendererGLContext* context_; | 497 RendererGLContext* context_; |
| 488 // The GLES2Implementation we use for OpenGL rendering. | 498 // The GLES2Implementation we use for OpenGL rendering. |
| 489 gpu::gles2::GLES2Implementation* gl_; | 499 gpu::gles2::GLES2Implementation* gl_; |
| 490 | 500 |
| 491 // State needed by MaybeInitializeGL. | 501 // State needed by MaybeInitializeGL. |
| 492 GpuChannelHost* host_; | 502 GpuChannelHost* host_; |
| 503 int32 surface_id_; |
| 493 GURL active_url_; | 504 GURL active_url_; |
| 494 int32 surface_id_; | 505 base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client_; |
| 495 | 506 |
| 496 bool render_directly_to_web_view_; | |
| 497 | |
| 498 // If rendering directly to WebView, weak pointer to it. | |
| 499 // This is only set when the context is bound to the main thread. | |
| 500 WebKit::WebView* web_view_; | |
| 501 | |
| 502 #if defined(OS_MACOSX) | |
| 503 // "Fake" plugin window handle in browser process for the compositor's output. | |
| 504 gfx::PluginWindowHandle plugin_handle_; | |
| 505 #endif | |
| 506 WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_; | 507 WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_; |
| 507 WGC3Denum context_lost_reason_; | 508 WGC3Denum context_lost_reason_; |
| 508 | 509 |
| 509 WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* | 510 WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* |
| 510 swapbuffers_complete_callback_; | 511 swapbuffers_complete_callback_; |
| 511 | 512 |
| 512 WebKit::WebGraphicsContext3D::Attributes attributes_; | 513 WebKit::WebGraphicsContext3D::Attributes attributes_; |
| 513 gfx::GpuPreference gpu_preference_; | 514 gfx::GpuPreference gpu_preference_; |
| 514 int cached_width_, cached_height_; | 515 int cached_width_, cached_height_; |
| 515 | 516 |
| 516 // For tracking which FBO is bound. | 517 // For tracking which FBO is bound. |
| 517 WebGLId bound_fbo_; | 518 WebGLId bound_fbo_; |
| 518 | 519 |
| 519 // Errors raised by synthesizeGLError(). | 520 // Errors raised by synthesizeGLError(). |
| 520 std::vector<WGC3Denum> synthetic_errors_; | 521 std::vector<WGC3Denum> synthetic_errors_; |
| 521 | 522 |
| 522 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; | 523 base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; |
| 523 | 524 |
| 524 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | 525 #ifdef FLIP_FRAMEBUFFER_VERTICALLY |
| 525 scoped_array<uint8> scanline_; | 526 scoped_array<uint8> scanline_; |
| 526 void FlipVertically(uint8* framebuffer, | 527 void FlipVertically(uint8* framebuffer, |
| 527 unsigned int width, | 528 unsigned int width, |
| 528 unsigned int height); | 529 unsigned int height); |
| 529 #endif | 530 #endif |
| 530 }; | 531 }; |
| 531 | 532 |
| 532 #endif // defined(ENABLE_GPU) | |
| 533 #endif // CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ | 533 #endif // CONTENT_RENDERER_GPU_WEBGRAPHICSCONTEXT3D_COMMAND_BUFFER_IMPL_H_ |
| OLD | NEW |