Commit 6ef57878 authored by oshima's avatar oshima Committed by Commit bot

Introduce OffscreenBrowsreCompositorOutputSurface for offscreen desktop rendering

Allow reflector to copy textures for multiple displays.

BUG=365662

Review URL: https://codereview.chromium.org/1108713004

Cr-Commit-Position: refs/heads/master@{#327385}
parent d1d9e928
...@@ -145,8 +145,7 @@ void MirrorWindowController::UpdateWindow( ...@@ -145,8 +145,7 @@ void MirrorWindowController::UpdateWindow(
mirror_window->SetBounds(host->window()->bounds()); mirror_window->SetBounds(host->window()->bounds());
mirror_window->Show(); mirror_window->Show();
if (reflector_) { if (reflector_) {
// TODO(oshima): Enable this once reflector change is landed. reflector_->AddMirroringLayer(mirror_window->layer());
// reflector_->AddMirroringLayer(mirror_window->layer());
} else { } else {
reflector_ = reflector_ =
aura::Env::GetInstance()->context_factory()->CreateReflector( aura::Env::GetInstance()->context_factory()->CreateReflector(
...@@ -268,8 +267,7 @@ void MirrorWindowController::CloseAndDeleteHost(MirroringHostInfo* host_info) { ...@@ -268,8 +267,7 @@ void MirrorWindowController::CloseAndDeleteHost(MirroringHostInfo* host_info) {
host->RemoveObserver(Shell::GetInstance()->display_controller()); host->RemoveObserver(Shell::GetInstance()->display_controller());
host->RemoveObserver(this); host->RemoveObserver(this);
host_info->ash_host->PrepareForShutdown(); host_info->ash_host->PrepareForShutdown();
// TODO(oshima): Enable this once reflector change is landed. reflector_->RemoveMirroringLayer(host_info->mirror_window->layer());
// reflector_->RemovedMirroringLayer(mirror_window->layer());
delete host_info; delete host_info;
} }
......
...@@ -104,7 +104,6 @@ ui::EventSource* AshWindowTreeHostUnified::GetEventSource() { ...@@ -104,7 +104,6 @@ ui::EventSource* AshWindowTreeHostUnified::GetEventSource() {
} }
gfx::AcceleratedWidget AshWindowTreeHostUnified::GetAcceleratedWidget() { gfx::AcceleratedWidget AshWindowTreeHostUnified::GetAcceleratedWidget() {
// TODO(oshima): Enable offscreen compositor.
return gfx::kNullAcceleratedWidget; return gfx::kNullAcceleratedWidget;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h" #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h"
#include "content/browser/compositor/gpu_browser_compositor_output_surface.h" #include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
#include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h" #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h"
#include "content/browser/compositor/offscreen_browser_compositor_output_surface.h"
#include "content/browser/compositor/reflector_impl.h" #include "content/browser/compositor/reflector_impl.h"
#include "content/browser/compositor/software_browser_compositor_output_surface.h" #include "content/browser/compositor/software_browser_compositor_output_surface.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h" #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
...@@ -283,6 +284,11 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( ...@@ -283,6 +284,11 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
compositor->vsync_manager())); compositor->vsync_manager()));
} else { } else {
DCHECK(context_provider); DCHECK(context_provider);
if (!data->surface_id) {
surface = make_scoped_ptr(new OffscreenBrowserCompositorOutputSurface(
context_provider, compositor->vsync_manager(),
scoped_ptr<BrowserCompositorOverlayCandidateValidator>()));
} else
#if defined(USE_OZONE) #if defined(USE_OZONE)
if (ui::SurfaceFactoryOzone::GetInstance() if (ui::SurfaceFactoryOzone::GetInstance()
->CanShowPrimaryPlaneAsOverlay()) { ->CanShowPrimaryPlaneAsOverlay()) {
...@@ -366,7 +372,8 @@ void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) { ...@@ -366,7 +372,8 @@ void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) {
// output_surface_map_ here. // output_surface_map_ here.
if (data->surface) if (data->surface)
output_surface_map_.Remove(data->surface_id); output_surface_map_.Remove(data->surface_id);
GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); if (data->surface_id)
GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id);
delete data; delete data;
per_compositor_data_.erase(it); per_compositor_data_.erase(it);
if (per_compositor_data_.empty()) { if (per_compositor_data_.empty()) {
...@@ -526,10 +533,13 @@ GpuProcessTransportFactory::CreatePerCompositorData( ...@@ -526,10 +533,13 @@ GpuProcessTransportFactory::CreatePerCompositorData(
GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get(); GpuSurfaceTracker* tracker = GpuSurfaceTracker::Get();
PerCompositorData* data = new PerCompositorData; PerCompositorData* data = new PerCompositorData;
data->surface_id = tracker->AddSurfaceForNativeWidget(widget); if (compositor->widget() == gfx::kNullAcceleratedWidget) {
tracker->SetSurfaceHandle( data->surface_id = 0;
data->surface_id, } else {
gfx::GLSurfaceHandle(widget, gfx::NATIVE_DIRECT)); data->surface_id = tracker->AddSurfaceForNativeWidget(widget);
tracker->SetSurfaceHandle(data->surface_id,
gfx::GLSurfaceHandle(widget, gfx::NATIVE_DIRECT));
}
per_compositor_data_[compositor] = data; per_compositor_data_[compositor] = data;
......
// Copyright 2015 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.
#include "content/browser/compositor/offscreen_browser_compositor_output_surface.h"
#include "base/logging.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_ack.h"
#include "cc/output/gl_frame_data.h"
#include "cc/output/output_surface_client.h"
#include "cc/resources/resource_provider.h"
#include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h"
#include "content/browser/compositor/reflector_impl.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/public/browser/browser_thread.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
using cc::CompositorFrame;
using cc::GLFrameData;
using cc::ResourceProvider;
using gpu::gles2::GLES2Interface;
namespace content {
OffscreenBrowserCompositorOutputSurface::
OffscreenBrowserCompositorOutputSurface(
const scoped_refptr<ContextProviderCommandBuffer>& context,
const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
scoped_ptr<BrowserCompositorOverlayCandidateValidator>
overlay_candidate_validator)
: BrowserCompositorOutputSurface(context,
vsync_manager,
overlay_candidate_validator.Pass()),
fbo_(0),
is_backbuffer_discarded_(false),
backing_texture_id_(0),
weak_ptr_factory_(this) {
capabilities_.max_frames_pending = 1;
capabilities_.uses_default_gl_framebuffer = false;
}
OffscreenBrowserCompositorOutputSurface::
~OffscreenBrowserCompositorOutputSurface() {
DiscardBackbuffer();
}
void OffscreenBrowserCompositorOutputSurface::EnsureBackbuffer() {
is_backbuffer_discarded_ = false;
if (!backing_texture_id_) {
GLES2Interface* gl = context_provider_->ContextGL();
cc::ResourceFormat format = cc::RGBA_8888;
gl->GenTextures(1, &backing_texture_id_);
gl->BindTexture(GL_TEXTURE_2D, backing_texture_id_);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(format),
surface_size_.width(), surface_size_.height(), 0,
GLDataFormat(format), GLDataType(format), nullptr);
}
}
void OffscreenBrowserCompositorOutputSurface::DiscardBackbuffer() {
is_backbuffer_discarded_ = true;
GLES2Interface* gl = context_provider_->ContextGL();
if (backing_texture_id_) {
gl->DeleteTextures(1, &backing_texture_id_);
backing_texture_id_ = 0;
}
if (fbo_) {
gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
gl->DeleteFramebuffers(1, &fbo_);
fbo_ = 0;
}
}
void OffscreenBrowserCompositorOutputSurface::Reshape(const gfx::Size& size,
float scale_factor) {
if (size == surface_size_)
return;
surface_size_ = size;
device_scale_factor_ = scale_factor;
DiscardBackbuffer();
EnsureBackbuffer();
}
void OffscreenBrowserCompositorOutputSurface::BindFramebuffer() {
EnsureBackbuffer();
DCHECK(backing_texture_id_);
GLES2Interface* gl = context_provider_->ContextGL();
if (!fbo_)
gl->GenFramebuffers(1, &fbo_);
gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
backing_texture_id_, 0);
}
void OffscreenBrowserCompositorOutputSurface::SwapBuffers(
cc::CompositorFrame* frame) {
// TODO(oshima): Pass the texture to the reflector so that the
// reflector can simply use and draw it on their surface instead of
// copying the texture.
if (reflector_) {
if (frame->gl_frame_data->sub_buffer_rect ==
gfx::Rect(frame->gl_frame_data->size))
reflector_->OnSourceSwapBuffers();
else
reflector_->OnSourcePostSubBuffer(frame->gl_frame_data->sub_buffer_rect);
}
client_->DidSwapBuffers();
// TODO(oshima): sync with the reflector's SwapBuffersComplete.
uint32_t sync_point =
context_provider_->ContextGL()->InsertSyncPointCHROMIUM();
context_provider_->ContextSupport()->SignalSyncPoint(
sync_point, base::Bind(&OutputSurface::OnSwapBuffersComplete,
weak_ptr_factory_.GetWeakPtr()));
}
#if defined(OS_MACOSX)
bool OffscreenBrowserCompositorOutputSurface::
SurfaceShouldNotShowFramesAfterSuspendForRecycle() const {
return true;
}
#endif
} // namespace content
// Copyright 2015 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_OFFSCREEN_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
#define CONTENT_BROWSER_COMPOSITOR_OFFSCREEN_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
#include "base/cancelable_callback.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/compositor/browser_compositor_output_surface.h"
namespace ui {
class CompositorVSyncManager;
}
namespace content {
class CommandBufferProxyImpl;
class OffscreenBrowserCompositorOutputSurface
: public BrowserCompositorOutputSurface {
public:
OffscreenBrowserCompositorOutputSurface(
const scoped_refptr<ContextProviderCommandBuffer>& context,
const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
scoped_ptr<BrowserCompositorOverlayCandidateValidator>
overlay_candidate_validator);
~OffscreenBrowserCompositorOutputSurface() override;
protected:
// cc::OutputSurface:
void EnsureBackbuffer() override;
void DiscardBackbuffer() override;
void Reshape(const gfx::Size& size, float scale_factor) override;
void BindFramebuffer() override;
void SwapBuffers(cc::CompositorFrame* frame) override;
#if defined(OS_MACOSX)
void OnSurfaceDisplayed() override {};
void SetSurfaceSuspendedForRecycle(bool suspended) override {};
bool SurfaceShouldNotShowFramesAfterSuspendForRecycle() const override;
#endif
uint32 fbo_;
bool is_backbuffer_discarded_;
uint32 backing_texture_id_;
base::WeakPtrFactory<OffscreenBrowserCompositorOutputSurface>
weak_ptr_factory_;
private:
DISALLOW_COPY_AND_ASSIGN(OffscreenBrowserCompositorOutputSurface);
};
} // namespace content
#endif // CONTENT_BROWSER_COMPOSITOR_OFFSCREEN_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_
...@@ -13,14 +13,21 @@ ...@@ -13,14 +13,21 @@
namespace content { namespace content {
struct ReflectorImpl::LayerData {
LayerData(ui::Layer* layer) : layer(layer) {}
ui::Layer* layer;
bool needs_set_mailbox = false;
};
ReflectorImpl::ReflectorImpl(ui::Compositor* mirrored_compositor, ReflectorImpl::ReflectorImpl(ui::Compositor* mirrored_compositor,
ui::Layer* mirroring_layer) ui::Layer* mirroring_layer)
: mirrored_compositor_(mirrored_compositor), : mirrored_compositor_(mirrored_compositor),
mirroring_layer_(mirroring_layer),
mirrored_compositor_gl_helper_texture_id_(0), mirrored_compositor_gl_helper_texture_id_(0),
needs_set_mailbox_(false),
flip_texture_(false), flip_texture_(false),
output_surface_(nullptr) { output_surface_(nullptr) {
if (mirroring_layer)
mirroring_layers_.push_back(new LayerData(mirroring_layer));
} }
ReflectorImpl::~ReflectorImpl() { ReflectorImpl::~ReflectorImpl() {
...@@ -30,7 +37,7 @@ void ReflectorImpl::Shutdown() { ...@@ -30,7 +37,7 @@ void ReflectorImpl::Shutdown() {
if (output_surface_) if (output_surface_)
DetachFromOutputSurface(); DetachFromOutputSurface();
// Prevent the ReflectorImpl from picking up a new output surface. // Prevent the ReflectorImpl from picking up a new output surface.
mirroring_layer_ = nullptr; mirroring_layers_.clear();
} }
void ReflectorImpl::DetachFromOutputSurface() { void ReflectorImpl::DetachFromOutputSurface() {
...@@ -43,12 +50,13 @@ void ReflectorImpl::DetachFromOutputSurface() { ...@@ -43,12 +50,13 @@ void ReflectorImpl::DetachFromOutputSurface() {
mirrored_compositor_gl_helper_texture_id_); mirrored_compositor_gl_helper_texture_id_);
mirrored_compositor_gl_helper_texture_id_ = 0; mirrored_compositor_gl_helper_texture_id_ = 0;
mirrored_compositor_gl_helper_ = nullptr; mirrored_compositor_gl_helper_ = nullptr;
mirroring_layer_->SetShowSolidColorContent(); for (LayerData* layer_data : mirroring_layers_)
layer_data->layer->SetShowSolidColorContent();
} }
void ReflectorImpl::OnSourceSurfaceReady( void ReflectorImpl::OnSourceSurfaceReady(
BrowserCompositorOutputSurface* output_surface) { BrowserCompositorOutputSurface* output_surface) {
if (!mirroring_layer_) if (mirroring_layers_.empty())
return; // Was already Shutdown(). return; // Was already Shutdown().
if (output_surface == output_surface_) if (output_surface == output_surface_)
return; // Is already attached. return; // Is already attached.
...@@ -60,7 +68,8 @@ void ReflectorImpl::OnSourceSurfaceReady( ...@@ -60,7 +68,8 @@ void ReflectorImpl::OnSourceSurfaceReady(
// of the mailbox. // of the mailbox.
GLHelper* shared_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); GLHelper* shared_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
mailbox_ = new OwnedMailbox(shared_helper); mailbox_ = new OwnedMailbox(shared_helper);
needs_set_mailbox_ = true; for (LayerData* layer_data : mirroring_layers_)
layer_data->needs_set_mailbox = true;
// Create a GLHelper attached to the mirrored compositor's output surface for // Create a GLHelper attached to the mirrored compositor's output surface for
// copying the output of the mirrored compositor. // copying the output of the mirrored compositor.
...@@ -86,11 +95,31 @@ void ReflectorImpl::OnSourceSurfaceReady( ...@@ -86,11 +95,31 @@ void ReflectorImpl::OnSourceSurfaceReady(
} }
void ReflectorImpl::OnMirroringCompositorResized() { void ReflectorImpl::OnMirroringCompositorResized() {
mirroring_layer_->SchedulePaint(mirroring_layer_->bounds()); for (LayerData* layer_data : mirroring_layers_)
layer_data->layer->SchedulePaint(layer_data->layer->bounds());
}
void ReflectorImpl::AddMirroringLayer(ui::Layer* layer) {
DCHECK(mirroring_layers_.end() == FindLayerData(layer));
LayerData* layer_data = new LayerData(layer);
if (mailbox_)
layer_data->needs_set_mailbox = true;
mirroring_layers_.push_back(layer_data);
mirrored_compositor_->ScheduleFullRedraw();
}
void ReflectorImpl::RemoveMirroringLayer(ui::Layer* layer) {
ScopedVector<LayerData>::iterator iter = FindLayerData(layer);
DCHECK(iter != mirroring_layers_.end());
(*iter)->layer->SetShowSolidColorContent();
mirroring_layers_.erase(iter);
if (mirroring_layers_.empty() && output_surface_)
DetachFromOutputSurface();
} }
void ReflectorImpl::OnSourceSwapBuffers() { void ReflectorImpl::OnSourceSwapBuffers() {
if (!mirroring_layer_) if (mirroring_layers_.empty())
return; return;
// Should be attached to the source output surface already. // Should be attached to the source output surface already.
DCHECK(mailbox_.get()); DCHECK(mailbox_.get());
...@@ -105,11 +134,12 @@ void ReflectorImpl::OnSourceSwapBuffers() { ...@@ -105,11 +134,12 @@ void ReflectorImpl::OnSourceSwapBuffers() {
mirrored_compositor_gl_helper_->InsertOrderingBarrier(); mirrored_compositor_gl_helper_->InsertOrderingBarrier();
// Request full redraw on mirroring compositor. // Request full redraw on mirroring compositor.
UpdateTexture(size, mirroring_layer_->bounds()); for (LayerData* layer_data : mirroring_layers_)
UpdateTexture(layer_data, size, layer_data->layer->bounds());
} }
void ReflectorImpl::OnSourcePostSubBuffer(const gfx::Rect& rect) { void ReflectorImpl::OnSourcePostSubBuffer(const gfx::Rect& rect) {
if (!mirroring_layer_) if (mirroring_layers_.empty())
return; return;
// Should be attached to the source output surface already. // Should be attached to the source output surface already.
DCHECK(mailbox_.get()); DCHECK(mailbox_.get());
...@@ -130,7 +160,8 @@ void ReflectorImpl::OnSourcePostSubBuffer(const gfx::Rect& rect) { ...@@ -130,7 +160,8 @@ void ReflectorImpl::OnSourcePostSubBuffer(const gfx::Rect& rect) {
gfx::Rect mirroring_rect(rect.x(), y, rect.width(), rect.height()); gfx::Rect mirroring_rect(rect.x(), y, rect.width(), rect.height());
// Request redraw of the dirty portion in mirroring compositor. // Request redraw of the dirty portion in mirroring compositor.
UpdateTexture(size, mirroring_rect); for (LayerData* layer_data : mirroring_layers_)
UpdateTexture(layer_data, size, mirroring_rect);
} }
static void ReleaseMailbox(scoped_refptr<OwnedMailbox> mailbox, static void ReleaseMailbox(scoped_refptr<OwnedMailbox> mailbox,
...@@ -139,20 +170,29 @@ static void ReleaseMailbox(scoped_refptr<OwnedMailbox> mailbox, ...@@ -139,20 +170,29 @@ static void ReleaseMailbox(scoped_refptr<OwnedMailbox> mailbox,
mailbox->UpdateSyncPoint(sync_point); mailbox->UpdateSyncPoint(sync_point);
} }
void ReflectorImpl::UpdateTexture(const gfx::Size& source_size, ScopedVector<ReflectorImpl::LayerData>::iterator ReflectorImpl::FindLayerData(
ui::Layer* layer) {
return std::find_if(mirroring_layers_.begin(), mirroring_layers_.end(),
[layer](const LayerData* layer_data) {
return layer_data->layer == layer;
});
}
void ReflectorImpl::UpdateTexture(ReflectorImpl::LayerData* layer_data,
const gfx::Size& source_size,
const gfx::Rect& redraw_rect) { const gfx::Rect& redraw_rect) {
if (needs_set_mailbox_) { if (layer_data->needs_set_mailbox) {
mirroring_layer_->SetTextureMailbox( layer_data->layer->SetTextureMailbox(
cc::TextureMailbox(mailbox_->holder()), cc::TextureMailbox(mailbox_->holder()),
cc::SingleReleaseCallback::Create(base::Bind(ReleaseMailbox, mailbox_)), cc::SingleReleaseCallback::Create(base::Bind(ReleaseMailbox, mailbox_)),
source_size); source_size);
needs_set_mailbox_ = false; layer_data->needs_set_mailbox = false;
} else { } else {
mirroring_layer_->SetTextureSize(source_size); layer_data->layer->SetTextureSize(source_size);
} }
mirroring_layer_->SetBounds(gfx::Rect(source_size)); layer_data->layer->SetBounds(gfx::Rect(source_size));
mirroring_layer_->SetTextureFlipped(flip_texture_); layer_data->layer->SetTextureFlipped(flip_texture_);
mirroring_layer_->SchedulePaint(redraw_rect); layer_data->layer->SchedulePaint(redraw_rect);
} }
} // namespace content } // namespace content
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/id_map.h" #include "base/id_map.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "content/browser/compositor/image_transport_factory.h" #include "content/browser/compositor/image_transport_factory.h"
...@@ -47,6 +48,8 @@ class CONTENT_EXPORT ReflectorImpl ...@@ -47,6 +48,8 @@ class CONTENT_EXPORT ReflectorImpl
// ui::Reflector implementation. // ui::Reflector implementation.
void OnMirroringCompositorResized() override; void OnMirroringCompositorResized() override;
void AddMirroringLayer(ui::Layer* layer) override;
void RemoveMirroringLayer(ui::Layer* layer) override;
// Called in |BrowserCompositorOutputSurface::SwapBuffers| to copy // Called in |BrowserCompositorOutputSurface::SwapBuffers| to copy
// the full screen image to the |mailbox_| texture. // the full screen image to the |mailbox_| texture.
...@@ -60,14 +63,19 @@ class CONTENT_EXPORT ReflectorImpl ...@@ -60,14 +63,19 @@ class CONTENT_EXPORT ReflectorImpl
void OnSourceSurfaceReady(BrowserCompositorOutputSurface* surface); void OnSourceSurfaceReady(BrowserCompositorOutputSurface* surface);
private: private:
void UpdateTexture(const gfx::Size& size, const gfx::Rect& redraw_rect); 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_; ui::Compositor* mirrored_compositor_;
ui::Layer* mirroring_layer_; ScopedVector<LayerData> mirroring_layers_;
scoped_refptr<OwnedMailbox> mailbox_; scoped_refptr<OwnedMailbox> mailbox_;
scoped_ptr<GLHelper> mirrored_compositor_gl_helper_; scoped_ptr<GLHelper> mirrored_compositor_gl_helper_;
int mirrored_compositor_gl_helper_texture_id_; int mirrored_compositor_gl_helper_texture_id_;
bool needs_set_mailbox_;
bool flip_texture_; bool flip_texture_;
BrowserCompositorOutputSurface* output_surface_; BrowserCompositorOutputSurface* output_surface_;
}; };
......
...@@ -1572,6 +1572,8 @@ ...@@ -1572,6 +1572,8 @@
'browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h', 'browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h',
'browser/compositor/image_transport_factory.cc', 'browser/compositor/image_transport_factory.cc',
'browser/compositor/image_transport_factory.h', 'browser/compositor/image_transport_factory.h',
'browser/compositor/offscreen_browser_compositor_output_surface.cc',
'browser/compositor/offscreen_browser_compositor_output_surface.h',
'browser/compositor/owned_mailbox.cc', 'browser/compositor/owned_mailbox.cc',
'browser/compositor/owned_mailbox.h', 'browser/compositor/owned_mailbox.h',
'browser/compositor/reflector_impl.cc', 'browser/compositor/reflector_impl.cc',
......
...@@ -8,11 +8,14 @@ ...@@ -8,11 +8,14 @@
#include "ui/compositor/compositor_export.h" #include "ui/compositor/compositor_export.h"
namespace ui { namespace ui {
class Layer;
class COMPOSITOR_EXPORT Reflector { class COMPOSITOR_EXPORT Reflector {
public: public:
virtual ~Reflector(); virtual ~Reflector();
virtual void OnMirroringCompositorResized() = 0; virtual void OnMirroringCompositorResized() = 0;
virtual void AddMirroringLayer(Layer* layer) = 0;
virtual void RemoveMirroringLayer(Layer* layer) = 0;
}; };
} // namespace ui } // namespace ui
......
...@@ -32,6 +32,8 @@ class FakeReflector : public Reflector { ...@@ -32,6 +32,8 @@ class FakeReflector : public Reflector {
FakeReflector() {} FakeReflector() {}
~FakeReflector() override {} ~FakeReflector() override {}
void OnMirroringCompositorResized() override {} void OnMirroringCompositorResized() override {}
void AddMirroringLayer(Layer* layer) override {}
void RemoveMirroringLayer(Layer* layer) override {}
}; };
// An OutputSurface implementation that directly draws and swaps to an actual // An OutputSurface implementation that directly draws and swaps to an actual
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment