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

Side by Side Diff: content/browser/compositor/reflector_impl.h

Issue 1123763003: Draw the offscreen texture to reflector's surface without extra copy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved texture code to ReflectorTexture Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_COMPOSITOR_REFLECTOR_IMPL_H_ 5 #ifndef CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_
6 #define CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_ 6 #define CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_
7 7
8 #include "base/callback.h"
8 #include "base/id_map.h" 9 #include "base/id_map.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
13 #include "content/browser/compositor/image_transport_factory.h" 14 #include "content/browser/compositor/image_transport_factory.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "gpu/command_buffer/common/mailbox_holder.h" 16 #include "gpu/command_buffer/common/mailbox_holder.h"
17 #include "ui/compositor/compositor_observer.h"
16 #include "ui/compositor/reflector.h" 18 #include "ui/compositor/reflector.h"
17 #include "ui/gfx/geometry/size.h" 19 #include "ui/gfx/geometry/size.h"
18 20
19 namespace base { class MessageLoopProxy; } 21 namespace base { class MessageLoopProxy; }
20 22
21 namespace gfx { class Rect; } 23 namespace gfx { class Rect; }
22 24
23 namespace ui { 25 namespace ui {
24 class Compositor; 26 class Compositor;
25 class Layer; 27 class Layer;
26 } 28 }
27 29
28 namespace content { 30 namespace content {
29 31
30 class OwnedMailbox; 32 class OwnedMailbox;
31 class BrowserCompositorOutputSurface; 33 class BrowserCompositorOutputSurface;
32 34
33 // A reflector implementation that copies the framebuffer content 35 // A reflector implementation that copies the framebuffer content
34 // to the texture, then draw it onto the mirroring compositor. 36 // to the texture, then draw it onto the mirroring compositor.
35 class CONTENT_EXPORT ReflectorImpl 37 class CONTENT_EXPORT ReflectorImpl
36 : public base::SupportsWeakPtr<ReflectorImpl>, 38 : public base::SupportsWeakPtr<ReflectorImpl>,
37 public ui::Reflector { 39 public ui::Reflector,
40 public ui::CompositorObserver {
38 public: 41 public:
39 ReflectorImpl(ui::Compositor* mirrored_compositor, 42 ReflectorImpl(ui::Compositor* mirrored_compositor,
40 ui::Layer* mirroring_layer); 43 ui::Layer* mirroring_layer);
41 ~ReflectorImpl() override; 44 ~ReflectorImpl() override;
42 45
43 ui::Compositor* mirrored_compositor() { return mirrored_compositor_; } 46 ui::Compositor* mirrored_compositor() { return mirrored_compositor_; }
44 47
45 void Shutdown(); 48 void Shutdown();
46 49
47 void DetachFromOutputSurface(); 50 void DetachFromOutputSurface();
48 51
49 // ui::Reflector implementation. 52 // ui::Reflector:
50 void OnMirroringCompositorResized() override; 53 void OnMirroringCompositorResized() override;
51 void AddMirroringLayer(ui::Layer* layer) override; 54 void AddMirroringLayer(ui::Layer* layer) override;
52 void RemoveMirroringLayer(ui::Layer* layer) override; 55 void RemoveMirroringLayer(ui::Layer* layer) override;
53 56
57 // ui::CompositorObserver:
58 void OnCompositingDidCommit(ui::Compositor* compositor) override {}
59 void OnCompositingStarted(ui::Compositor* compositor,
60 base::TimeTicks start_time) override;
61 void OnCompositingEnded(ui::Compositor* compositor) override {}
62 void OnCompositingAborted(ui::Compositor* compositor) override {}
63 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
64 void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
65
54 // Called in |BrowserCompositorOutputSurface::SwapBuffers| to copy 66 // Called in |BrowserCompositorOutputSurface::SwapBuffers| to copy
55 // the full screen image to the |mailbox_| texture. 67 // the full screen image to the |mailbox_| texture.
56 void OnSourceSwapBuffers(); 68 void OnSourceSwapBuffers();
57 69
58 // Called in |BrowserCompositorOutputSurface::PostSubBuffer| copy 70 // Called in |BrowserCompositorOutputSurface::PostSubBuffer| copy
59 // the sub image given by |rect| to the |mailbox_| texture. 71 // the sub image given by |rect| to the |mailbox_| texture.
60 void OnSourcePostSubBuffer(const gfx::Rect& rect); 72 void OnSourcePostSubBuffer(const gfx::Rect& rect);
61 73
62 // Called when the source surface is bound and available. 74 // Called when the source surface is bound and available.
63 void OnSourceSurfaceReady(BrowserCompositorOutputSurface* surface); 75 void OnSourceSurfaceReady(BrowserCompositorOutputSurface* surface);
64 76
77 // Called when the mailbox which has the source surface's texture
78 // is updated.
79 void OnSourceTextureMailboxUpdated(scoped_refptr<OwnedMailbox> mailbox);
80
65 private: 81 private:
66 struct LayerData; 82 struct LayerData;
67 83
68 ScopedVector<ReflectorImpl::LayerData>::iterator FindLayerData( 84 ScopedVector<ReflectorImpl::LayerData>::iterator FindLayerData(
69 ui::Layer* layer); 85 ui::Layer* layer);
70 void UpdateTexture(LayerData* layer_data, 86 void UpdateTexture(LayerData* layer_data,
71 const gfx::Size& size, 87 const gfx::Size& size,
72 const gfx::Rect& redraw_rect); 88 const gfx::Rect& redraw_rect);
73 89
74 ui::Compositor* mirrored_compositor_; 90 ui::Compositor* mirrored_compositor_;
75 ScopedVector<LayerData> mirroring_layers_; 91 ScopedVector<LayerData> mirroring_layers_;
92
76 scoped_refptr<OwnedMailbox> mailbox_; 93 scoped_refptr<OwnedMailbox> mailbox_;
77 scoped_ptr<GLHelper> mirrored_compositor_gl_helper_;
78 int mirrored_compositor_gl_helper_texture_id_;
79 bool flip_texture_; 94 bool flip_texture_;
95 int composition_count_;
80 BrowserCompositorOutputSurface* output_surface_; 96 BrowserCompositorOutputSurface* output_surface_;
97 base::Closure composition_started_callback_;
81 }; 98 };
82 99
83 } // namespace content 100 } // namespace content
84 101
85 #endif // CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_ 102 #endif // CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698