blob: 7f3b9fc4fe5ef3b63593e8dc6845f3447325114e (
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
|
// 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/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/reflector.h"
#include "ui/gfx/geometry/size.h"
namespace base { class MessageLoopProxy; }
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:
ReflectorImpl(ui::Compositor* mirrored_compositor,
ui::Layer* mirroring_layer);
~ReflectorImpl() override;
ui::Compositor* mirrored_compositor() { return mirrored_compositor_; }
void Shutdown();
void DetachFromOutputSurface();
// ui::Reflector implementation.
void OnMirroringCompositorResized() override;
void AddMirroringLayer(ui::Layer* layer) override;
void RemoveMirroringLayer(ui::Layer* layer) 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);
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_;
scoped_ptr<GLHelper> mirrored_compositor_gl_helper_;
int mirrored_compositor_gl_helper_texture_id_;
bool flip_texture_;
BrowserCompositorOutputSurface* output_surface_;
};
} // namespace content
#endif // CONTENT_BROWSER_COMPOSITOR_REFLECTOR_IMPL_H_
|