[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / content / browser / compositor / reflector_impl.h
blob38a3387585acd1a8e0bc8d57c97711a0ffe76c1c
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_
6 #define CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_
8 #include "base/id_map.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/synchronization/lock.h"
12 #include "content/browser/compositor/image_transport_factory.h"
13 #include "content/common/content_export.h"
14 #include "gpu/command_buffer/common/mailbox_holder.h"
15 #include "ui/compositor/reflector.h"
16 #include "ui/gfx/geometry/size.h"
18 namespace base { class MessageLoopProxy; }
20 namespace gfx { class Rect; }
22 namespace ui {
23 class Compositor;
24 class Layer;
27 namespace content {
29 class OwnedMailbox;
30 class BrowserCompositorOutputSurface;
32 // A reflector implementation that copies the framebuffer content
33 // to the texture, then draw it onto the mirroring compositor.
34 class CONTENT_EXPORT ReflectorImpl
35 : public base::SupportsWeakPtr<ReflectorImpl>,
36 public ui::Reflector {
37 public:
38 ReflectorImpl(ui::Compositor* mirrored_compositor,
39 ui::Layer* mirroring_layer);
40 ~ReflectorImpl() override;
42 ui::Compositor* mirrored_compositor() { return mirrored_compositor_; }
44 void Shutdown();
46 void DetachFromOutputSurface();
48 // ui::Reflector implementation.
49 void OnMirroringCompositorResized() override;
51 // Called in |BrowserCompositorOutputSurface::SwapBuffers| to copy
52 // the full screen image to the |mailbox_| texture.
53 void OnSourceSwapBuffers();
55 // Called in |BrowserCompositorOutputSurface::PostSubBuffer| copy
56 // the sub image given by |rect| to the |mailbox_| texture.
57 void OnSourcePostSubBuffer(const gfx::Rect& rect);
59 // Called when the source surface is bound and available.
60 void OnSourceSurfaceReady(BrowserCompositorOutputSurface* surface);
62 private:
63 void UpdateTexture(const gfx::Size& size, const gfx::Rect& redraw_rect);
65 ui::Compositor* mirrored_compositor_;
66 ui::Layer* mirroring_layer_;
67 scoped_refptr<OwnedMailbox> mailbox_;
68 scoped_ptr<GLHelper> mirrored_compositor_gl_helper_;
69 int mirrored_compositor_gl_helper_texture_id_;
70 bool needs_set_mailbox_;
71 bool flip_texture_;
72 BrowserCompositorOutputSurface* output_surface_;
75 } // namespace content
77 #endif // CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_