| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_BROWSER_AURA_REFLECTOR_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_AURA_REFLECTOR_IMPL_H_ |
| 6 #define CONTENT_BROWSER_AURA_REFLECTOR_IMPL_H_ | 6 #define CONTENT_BROWSER_AURA_REFLECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "content/browser/aura/browser_compositor_output_surface_capturer.h" |
| 11 #include "content/browser/aura/image_transport_factory.h" | 12 #include "content/browser/aura/image_transport_factory.h" |
| 12 #include "ui/compositor/reflector.h" | 13 #include "ui/compositor/reflector.h" |
| 13 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 14 | 15 |
| 15 namespace base { class MessageLoopProxy; } | 16 namespace base { class MessageLoopProxy; } |
| 16 | 17 |
| 17 namespace gfx { class Rect; } | 18 namespace gfx { class Rect; } |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 class Compositor; | 21 class Compositor; |
| 21 class Layer; | 22 class Layer; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 class BrowserCompositorOutputSurface; | |
| 27 | |
| 28 // A reflector implementation that copies the framebuffer content | 27 // A reflector implementation that copies the framebuffer content |
| 29 // to the texture, then draw it onto the mirroring compositor. | 28 // to the texture, then draw it onto the mirroring compositor. |
| 30 class ReflectorImpl : public ImageTransportFactoryObserver, | 29 class ReflectorImpl : public ImageTransportFactoryObserver, |
| 31 public base::SupportsWeakPtr<ReflectorImpl>, | 30 public base::SupportsWeakPtr<ReflectorImpl>, |
| 32 public ui::Reflector { | 31 public ui::Reflector, |
| 32 public BrowserCompositorOutputSurface::Observer { |
| 33 public: | 33 public: |
| 34 ReflectorImpl( | 34 ReflectorImpl( |
| 35 ui::Compositor* mirrored_compositor, | 35 ui::Compositor* mirrored_compositor, |
| 36 ui::Layer* mirroring_layer, | 36 ui::Layer* mirroring_layer, |
| 37 IDMap<BrowserCompositorOutputSurface>* output_surface_map, | 37 IDMap<BrowserCompositorOutputSurface>* output_surface_map, |
| 38 int surface_id); | 38 int surface_id); |
| 39 | 39 |
| 40 ui::Compositor* mirrored_compositor() { | 40 ui::Compositor* mirrored_compositor() { |
| 41 return mirrored_compositor_; | 41 return mirrored_compositor_; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void InitOnImplThread(); | 44 void InitOnImplThread(); |
| 45 void Shutdown(); | 45 void Shutdown(); |
| 46 void ShutdownOnImplThread(); | 46 void ShutdownOnImplThread(); |
| 47 | 47 |
| 48 // This must be called on ImplThread, or before the surface is passed to | 48 // This must be called on ImplThread, or before the surface is passed to |
| 49 // ImplThread. | 49 // ImplThread. |
| 50 void AttachToOutputSurface(BrowserCompositorOutputSurface* surface); | 50 void AttachToOutputSurface(BrowserCompositorOutputSurface* surface); |
| 51 | 51 |
| 52 // ui::Reflector implementation. | 52 // ui::Reflector implementation. |
| 53 virtual void OnMirroringCompositorResized() OVERRIDE; | 53 virtual void OnMirroringCompositorResized() OVERRIDE; |
| 54 | 54 |
| 55 // ImageTransportFactoryObsever implementation. | 55 // ImageTransportFactoryObsever implementation. |
| 56 virtual void OnLostResources() OVERRIDE; | 56 virtual void OnLostResources() OVERRIDE; |
| 57 | 57 |
| 58 // Called when the output surface's size has changed. | 58 // BrowserCompositorOutputSurface::Observer implementation. |
| 59 // This must be called on ImplThread. | 59 virtual void OnReshape(const gfx::Size& size) OVERRIDE; |
| 60 void OnReshape(gfx::Size size); | 60 virtual void OnSwapBuffers() OVERRIDE; |
| 61 | 61 virtual void OnPostSubBuffer(const gfx::Rect& rect) OVERRIDE; |
| 62 // Called in |BrowserCompositorOutputSurface::SwapBuffers| to copy | 62 virtual void OnDelete() OVERRIDE; |
| 63 // the full screen image to the |texture_id_|. This must be called | |
| 64 // on ImplThread. | |
| 65 void OnSwapBuffers(); | |
| 66 | |
| 67 // Called in |BrowserCompositorOutputSurface::PostSubBuffer| copy | |
| 68 // the sub image given by |rect| to the texture.This must be called | |
| 69 // on ImplThread. | |
| 70 void OnPostSubBuffer(gfx::Rect rect); | |
| 71 | 63 |
| 72 // Create a shared texture that will be used to copy the content of | 64 // Create a shared texture that will be used to copy the content of |
| 73 // mirrored compositor to the mirroring compositor. This must be | 65 // mirrored compositor to the mirroring compositor. This must be |
| 74 // called before the reflector is attached to OutputSurface to avoid | 66 // called before the reflector is attached to OutputSurface to avoid |
| 75 // race with ImplThread accessing |texture_id_|. | 67 // race with ImplThread accessing |texture_id_|. |
| 76 void CreateSharedTexture(); | 68 void CreateSharedTexture(); |
| 77 | 69 |
| 78 | |
| 79 private: | 70 private: |
| 80 virtual ~ReflectorImpl(); | 71 virtual ~ReflectorImpl(); |
| 81 | 72 |
| 82 void UpdateTextureSizeOnMainThread(gfx::Size size); | 73 void UpdateTextureSizeOnMainThread(gfx::Size size); |
| 83 | 74 |
| 84 // Request full redraw on mirroring compositor. | 75 // Request full redraw on mirroring compositor. |
| 85 void FullRedrawOnMainThread(gfx::Size size); | 76 void FullRedrawOnMainThread(gfx::Size size); |
| 86 | 77 |
| 87 void UpdateSubBufferOnMainThread(gfx::Size size, gfx::Rect rect); | 78 void UpdateSubBufferOnMainThread(gfx::Size size, gfx::Rect rect); |
| 88 | 79 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 113 ui::Layer* mirroring_layer_; | 104 ui::Layer* mirroring_layer_; |
| 114 scoped_refptr<ui::Texture> shared_texture_; | 105 scoped_refptr<ui::Texture> shared_texture_; |
| 115 scoped_refptr<base::MessageLoopProxy> impl_message_loop_; | 106 scoped_refptr<base::MessageLoopProxy> impl_message_loop_; |
| 116 scoped_refptr<base::MessageLoopProxy> main_message_loop_; | 107 scoped_refptr<base::MessageLoopProxy> main_message_loop_; |
| 117 int surface_id_; | 108 int surface_id_; |
| 118 }; | 109 }; |
| 119 | 110 |
| 120 } // namespace content | 111 } // namespace content |
| 121 | 112 |
| 122 #endif // CONTENT_BROWSER_AURA_REFLECTOR_IMPL_H_ | 113 #endif // CONTENT_BROWSER_AURA_REFLECTOR_IMPL_H_ |
| OLD | NEW |