Add ICU message format support
[chromium-blink-merge.git] / content / browser / compositor / reflector_impl.h
blobca1a89f8b4ef1342ff377aea4b87d7b6f495cf2b
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/callback.h"
9 #include "base/id_map.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/synchronization/lock.h"
14 #include "content/browser/compositor/image_transport_factory.h"
15 #include "content/common/content_export.h"
16 #include "gpu/command_buffer/common/mailbox_holder.h"
17 #include "ui/compositor/compositor_observer.h"
18 #include "ui/compositor/reflector.h"
19 #include "ui/gfx/geometry/size.h"
21 namespace gfx { class Rect; }
23 namespace ui {
24 class Compositor;
25 class Layer;
28 namespace content {
30 class OwnedMailbox;
31 class BrowserCompositorOutputSurface;
33 // A reflector implementation that copies the framebuffer content
34 // to the texture, then draw it onto the mirroring compositor.
35 class CONTENT_EXPORT ReflectorImpl
36 : public base::SupportsWeakPtr<ReflectorImpl>,
37 public ui::Reflector,
38 public ui::CompositorObserver {
39 public:
40 ReflectorImpl(ui::Compositor* mirrored_compositor,
41 ui::Layer* mirroring_layer);
42 ~ReflectorImpl() override;
44 ui::Compositor* mirrored_compositor() { return mirrored_compositor_; }
46 void Shutdown();
48 void DetachFromOutputSurface();
50 // ui::Reflector:
51 void OnMirroringCompositorResized() override;
52 void AddMirroringLayer(ui::Layer* layer) override;
53 void RemoveMirroringLayer(ui::Layer* layer) override;
55 // ui::CompositorObserver:
56 void OnCompositingDidCommit(ui::Compositor* compositor) override {}
57 void OnCompositingStarted(ui::Compositor* compositor,
58 base::TimeTicks start_time) override;
59 void OnCompositingEnded(ui::Compositor* compositor) override {}
60 void OnCompositingAborted(ui::Compositor* compositor) override {}
61 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
62 void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
64 // Called in |BrowserCompositorOutputSurface::SwapBuffers| to copy
65 // the full screen image to the |mailbox_| texture.
66 void OnSourceSwapBuffers();
68 // Called in |BrowserCompositorOutputSurface::PostSubBuffer| copy
69 // the sub image given by |rect| to the |mailbox_| texture.
70 void OnSourcePostSubBuffer(const gfx::Rect& rect);
72 // Called when the source surface is bound and available.
73 void OnSourceSurfaceReady(BrowserCompositorOutputSurface* surface);
75 // Called when the mailbox which has the source surface's texture
76 // is updated.
77 void OnSourceTextureMailboxUpdated(scoped_refptr<OwnedMailbox> mailbox);
79 private:
80 struct LayerData;
82 ScopedVector<ReflectorImpl::LayerData>::iterator FindLayerData(
83 ui::Layer* layer);
84 void UpdateTexture(LayerData* layer_data,
85 const gfx::Size& size,
86 const gfx::Rect& redraw_rect);
88 ui::Compositor* mirrored_compositor_;
89 ScopedVector<LayerData> mirroring_layers_;
91 scoped_refptr<OwnedMailbox> mailbox_;
92 bool flip_texture_;
93 int composition_count_;
94 BrowserCompositorOutputSurface* output_surface_;
95 base::Closure composition_started_callback_;
98 } // namespace content
100 #endif // CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_