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