Commit 6302d690 authored by oshima's avatar oshima Committed by Commit bot

This reverts two CLs

"compositor: Fix texture flipping for SW mirroring with surfaceless"
and
"Exclude reflector_impl_unittest.cc from GN non-Aura, non-Mac builds."

Reason for revert:
The original patch breaks software mirroring mode on at least veyron_jerry,
and quite possibly all non-freon systems.

>Original issue's descriptions:
>   Exclude reflector_impl_unittest.cc from GN non-Aura, non-Mac builds.
>    This fixes the GN build on Android after https://codereview.chromium.org/846063002.
>
>   (The GYP build didn't break because content/browser/compositor/ is completely excluded there; see https://code.google.com/p/chromium/codesearch#chromium/src/content/content_tests.gypi&sq=package:chromium&&type=cs&l=1099)
>
>   TBR=bauerb@chromium.org
>
>   Review URL: https://codereview.chromium.org/879543002
>
>    Cr-Commit-Position: refs/heads/master@{#313074}

> compositor: Fix texture flipping for SW mirroring with surfaceless
>
> Ozone-surfaceless renders the scene flipped, so the texture contents are
> inverted from what they should be. This fixes the mirroring logic to
> un-flip the texture when needed, and also to send the right sub-buffer
> update rect.
>
> BUG=434115
>
> Committed: https://crrev.com/c6a481fe79e0c4851a576495105edf2600bfe5be
> Cr-Commit-Position: refs/heads/master@{#312979}

TBR=danakj@chromium.org,achaulk@chromium.org,bauerb@chromium.org
BUG=434115,451804

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

Cr-Commit-Position: refs/heads/master@{#313610}
parent 1737fefb
...@@ -99,7 +99,6 @@ class CC_EXPORT TextureLayer : public Layer { ...@@ -99,7 +99,6 @@ class CC_EXPORT TextureLayer : public Layer {
// Sets whether this texture should be Y-flipped at draw time. Defaults to // Sets whether this texture should be Y-flipped at draw time. Defaults to
// true. // true.
void SetFlipped(bool flipped); void SetFlipped(bool flipped);
bool flipped() const { return flipped_; }
// Sets whether this texture should use nearest neighbor interpolation as // Sets whether this texture should use nearest neighbor interpolation as
// opposed to bilinear. Defaults to false. // opposed to bilinear. Defaults to false.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace content { namespace content {
BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
const scoped_refptr<cc::ContextProvider>& context_provider, const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
int surface_id, int surface_id,
IDMap<BrowserCompositorOutputSurface>* output_surface_map, IDMap<BrowserCompositorOutputSurface>* output_surface_map,
const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager)
......
...@@ -48,7 +48,7 @@ class CONTENT_EXPORT BrowserCompositorOutputSurface ...@@ -48,7 +48,7 @@ class CONTENT_EXPORT BrowserCompositorOutputSurface
protected: protected:
// Constructor used by the accelerated implementation. // Constructor used by the accelerated implementation.
BrowserCompositorOutputSurface( BrowserCompositorOutputSurface(
const scoped_refptr<cc::ContextProvider>& context, const scoped_refptr<ContextProviderCommandBuffer>& context,
int surface_id, int surface_id,
IDMap<BrowserCompositorOutputSurface>* output_surface_map, IDMap<BrowserCompositorOutputSurface>* output_surface_map,
const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager); const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager);
......
...@@ -38,9 +38,7 @@ ReflectorImpl::MainThreadData::MainThreadData( ...@@ -38,9 +38,7 @@ ReflectorImpl::MainThreadData::MainThreadData(
ui::Layer* mirroring_layer) ui::Layer* mirroring_layer)
: needs_set_mailbox(true), : needs_set_mailbox(true),
mirrored_compositor(mirrored_compositor), mirrored_compositor(mirrored_compositor),
mirroring_layer(mirroring_layer), mirroring_layer(mirroring_layer) {}
flip_texture(false) {
}
ReflectorImpl::MainThreadData::~MainThreadData() {} ReflectorImpl::MainThreadData::~MainThreadData() {}
...@@ -195,10 +193,10 @@ void ReflectorImpl::AttachToOutputSurfaceOnImplThread( ...@@ -195,10 +193,10 @@ void ReflectorImpl::AttachToOutputSurfaceOnImplThread(
impl.gl_helper->Flush(); impl.gl_helper->Flush();
output_surface->SetReflector(this); output_surface->SetReflector(this);
// The texture doesn't have the data, so invokes full redraw now. // The texture doesn't have the data, so invokes full redraw now.
bool flip_texture = !output_surface->capabilities().flipped_output_surface;
main_message_loop_->PostTask( main_message_loop_->PostTask(
FROM_HERE, base::Bind(&ReflectorImpl::FullRedrawContentOnMainThread, FROM_HERE,
scoped_refptr<ReflectorImpl>(this), flip_texture)); base::Bind(&ReflectorImpl::FullRedrawContentOnMainThread,
scoped_refptr<ReflectorImpl>(this)));
} }
void ReflectorImpl::UpdateTextureSizeOnMainThread(gfx::Size size) { void ReflectorImpl::UpdateTextureSizeOnMainThread(gfx::Size size) {
...@@ -217,7 +215,6 @@ void ReflectorImpl::UpdateTextureSizeOnMainThread(gfx::Size size) { ...@@ -217,7 +215,6 @@ void ReflectorImpl::UpdateTextureSizeOnMainThread(gfx::Size size) {
main.mirroring_layer->SetTextureSize(size); main.mirroring_layer->SetTextureSize(size);
} }
main.mirroring_layer->SetBounds(gfx::Rect(size)); main.mirroring_layer->SetBounds(gfx::Rect(size));
main.mirroring_layer->SetTextureFlipped(main.flip_texture);
} }
void ReflectorImpl::FullRedrawOnMainThread(gfx::Size size) { void ReflectorImpl::FullRedrawOnMainThread(gfx::Size size) {
...@@ -228,24 +225,20 @@ void ReflectorImpl::FullRedrawOnMainThread(gfx::Size size) { ...@@ -228,24 +225,20 @@ void ReflectorImpl::FullRedrawOnMainThread(gfx::Size size) {
main.mirroring_layer->SchedulePaint(main.mirroring_layer->bounds()); main.mirroring_layer->SchedulePaint(main.mirroring_layer->bounds());
} }
void ReflectorImpl::UpdateSubBufferOnMainThread(const gfx::Size& size, void ReflectorImpl::UpdateSubBufferOnMainThread(gfx::Size size,
const gfx::Rect& rect) { gfx::Rect rect) {
MainThreadData& main = GetMain(); MainThreadData& main = GetMain();
if (!main.mirroring_layer) if (!main.mirroring_layer)
return; return;
UpdateTextureSizeOnMainThread(size); UpdateTextureSizeOnMainThread(size);
int y = rect.y();
// Flip the coordinates to compositor's one. // Flip the coordinates to compositor's one.
if (main.flip_texture) int y = size.height() - rect.y() - rect.height();
y = size.height() - rect.y() - rect.height();
gfx::Rect new_rect(rect.x(), y, rect.width(), rect.height()); gfx::Rect new_rect(rect.x(), y, rect.width(), rect.height());
main.mirroring_layer->SchedulePaint(new_rect); main.mirroring_layer->SchedulePaint(new_rect);
} }
void ReflectorImpl::FullRedrawContentOnMainThread(bool flip_texture) { void ReflectorImpl::FullRedrawContentOnMainThread() {
MainThreadData& main = GetMain(); MainThreadData& main = GetMain();
main.flip_texture = flip_texture;
main.mirrored_compositor->ScheduleFullRedraw(); main.mirrored_compositor->ScheduleFullRedraw();
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#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"
#include "content/common/content_export.h"
#include "gpu/command_buffer/common/mailbox_holder.h" #include "gpu/command_buffer/common/mailbox_holder.h"
#include "ui/compositor/reflector.h" #include "ui/compositor/reflector.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
...@@ -31,8 +30,7 @@ class BrowserCompositorOutputSurface; ...@@ -31,8 +30,7 @@ class BrowserCompositorOutputSurface;
// A reflector implementation that copies the framebuffer content // A reflector implementation that copies the framebuffer content
// to the texture, then draw it onto the mirroring compositor. // to the texture, then draw it onto the mirroring compositor.
class CONTENT_EXPORT ReflectorImpl class ReflectorImpl : public base::SupportsWeakPtr<ReflectorImpl>,
: public base::SupportsWeakPtr<ReflectorImpl>,
public ui::Reflector { public ui::Reflector {
public: public:
ReflectorImpl( ReflectorImpl(
...@@ -80,8 +78,6 @@ class CONTENT_EXPORT ReflectorImpl ...@@ -80,8 +78,6 @@ class CONTENT_EXPORT ReflectorImpl
void DetachFromOutputSurface(); void DetachFromOutputSurface();
private: private:
friend class ReflectorImplTest;
struct MainThreadData { struct MainThreadData {
MainThreadData(ui::Compositor* mirrored_compositor, MainThreadData(ui::Compositor* mirrored_compositor,
ui::Layer* mirroring_layer); ui::Layer* mirroring_layer);
...@@ -90,7 +86,6 @@ class CONTENT_EXPORT ReflectorImpl ...@@ -90,7 +86,6 @@ class CONTENT_EXPORT ReflectorImpl
bool needs_set_mailbox; bool needs_set_mailbox;
ui::Compositor* mirrored_compositor; ui::Compositor* mirrored_compositor;
ui::Layer* mirroring_layer; ui::Layer* mirroring_layer;
bool flip_texture;
}; };
struct ImplThreadData { struct ImplThreadData {
...@@ -115,12 +110,11 @@ class CONTENT_EXPORT ReflectorImpl ...@@ -115,12 +110,11 @@ class CONTENT_EXPORT ReflectorImpl
// Request full redraw on mirroring compositor. // Request full redraw on mirroring compositor.
void FullRedrawOnMainThread(gfx::Size size); void FullRedrawOnMainThread(gfx::Size size);
void UpdateSubBufferOnMainThread(const gfx::Size& size, void UpdateSubBufferOnMainThread(gfx::Size size, gfx::Rect rect);
const gfx::Rect& rect);
// Request full redraw on mirrored compositor so that // Request full redraw on mirrored compositor so that
// the full content will be copied to mirroring compositor. // the full content will be copied to mirroring compositor.
void FullRedrawContentOnMainThread(bool flip_texture); void FullRedrawContentOnMainThread();
// This exists just to hold a reference to a ReflectorImpl in a post task, // This exists just to hold a reference to a ReflectorImpl in a post task,
// so the ReflectorImpl gets deleted when the function returns. // so the ReflectorImpl gets deleted when the function returns.
......
// 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 "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "cc/test/fake_output_surface_client.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "content/browser/compositor/browser_compositor_output_surface.h"
#include "content/browser/compositor/reflector_impl.h"
#include "content/browser/compositor/test/no_transport_image_transport_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/test/context_factories_for_test.h"
namespace content {
namespace {
class FakeTaskRunner : public base::SingleThreadTaskRunner {
public:
FakeTaskRunner() {}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) override {
return true;
}
bool PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) override {
return true;
}
bool RunsTasksOnCurrentThread() const override { return true; }
protected:
~FakeTaskRunner() override {}
};
class TestOutputSurface : public BrowserCompositorOutputSurface {
public:
TestOutputSurface(
const scoped_refptr<cc::ContextProvider>& context_provider,
int surface_id,
IDMap<BrowserCompositorOutputSurface>* output_surface_map,
const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager)
: BrowserCompositorOutputSurface(context_provider,
surface_id,
output_surface_map,
vsync_manager) {}
void SetFlip(bool flip) { capabilities_.flipped_output_surface = flip; }
void SwapBuffers(cc::CompositorFrame* frame) override {}
#if defined(OS_MACOSX)
void OnSurfaceDisplayed() override {}
void OnSurfaceRecycled() override {}
bool ShouldNotShowFramesAfterRecycle() const override { return false; }
#endif
gfx::Size SurfaceSize() const override { return gfx::Size(256, 256); }
};
const gfx::Rect kSubRect = gfx::Rect(0, 0, 64, 64);
const SkIRect kSkSubRect = SkIRect::MakeXYWH(0, 0, 64, 64);
} // namespace
class ReflectorImplTest : public testing::Test {
public:
void SetUp() override {
bool enable_pixel_output = false;
ui::ContextFactory* context_factory =
ui::InitializeContextFactoryForTests(enable_pixel_output);
ImageTransportFactory::InitializeForUnitTests(
scoped_ptr<ImageTransportFactory>(
new NoTransportImageTransportFactory));
message_loop_.reset(new base::MessageLoop());
proxy_ = message_loop_->message_loop_proxy();
compositor_task_runner_ = new FakeTaskRunner();
compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget,
context_factory,
compositor_task_runner_.get()));
context_provider_ = cc::TestContextProvider::Create(
cc::TestWebGraphicsContext3D::Create().Pass());
output_surface_ =
scoped_ptr<TestOutputSurface>(
new TestOutputSurface(context_provider_, 1, &surface_map_,
compositor_->vsync_manager())).Pass();
CHECK(output_surface_->BindToClient(&output_surface_client_));
mirroring_layer_.reset(new ui::Layer());
gfx::Size size = output_surface_->SurfaceSize();
mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height()));
int32 surface_id = 1;
reflector_ = new ReflectorImpl(compositor_.get(), mirroring_layer_.get(),
&surface_map_, proxy_.get(), surface_id);
}
void TearDown() override {
cc::TextureMailbox mailbox;
scoped_ptr<cc::SingleReleaseCallback> release;
if (mirroring_layer_->PrepareTextureMailbox(&mailbox, &release, false)) {
release->Run(0, false);
}
compositor_.reset();
ui::TerminateContextFactoryForTests();
ImageTransportFactory::Terminate();
}
void Init() { base::RunLoop().RunUntilIdle(); }
void UpdateTexture() {
reflector_->UpdateSubBufferOnMainThread(output_surface_->SurfaceSize(),
kSubRect);
}
protected:
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
IDMap<BrowserCompositorOutputSurface> surface_map_;
scoped_refptr<cc::ContextProvider> context_provider_;
cc::FakeOutputSurfaceClient output_surface_client_;
scoped_ptr<base::MessageLoop> message_loop_;
scoped_refptr<base::MessageLoopProxy> proxy_;
scoped_ptr<ui::Compositor> compositor_;
scoped_ptr<ui::Layer> mirroring_layer_;
scoped_refptr<ReflectorImpl> reflector_;
scoped_ptr<TestOutputSurface> output_surface_;
};
namespace {
TEST_F(ReflectorImplTest, CheckNormalOutputSurface) {
output_surface_->SetFlip(false);
Init();
UpdateTexture();
EXPECT_TRUE(mirroring_layer_->TextureFlipped());
EXPECT_EQ(SkRegion(SkIRect::MakeXYWH(
0, output_surface_->SurfaceSize().height() - kSubRect.height(),
kSubRect.width(), kSubRect.height())),
mirroring_layer_->damaged_region());
}
TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) {
output_surface_->SetFlip(true);
Init();
UpdateTexture();
EXPECT_FALSE(mirroring_layer_->TextureFlipped());
EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region());
}
} // namespace
} // namespace content
...@@ -337,7 +337,6 @@ ...@@ -337,7 +337,6 @@
'browser/child_process_security_policy_unittest.cc', 'browser/child_process_security_policy_unittest.cc',
'browser/cocoa/system_hotkey_map_unittest.mm', 'browser/cocoa/system_hotkey_map_unittest.mm',
'browser/compositor/buffer_queue_unittest.cc', 'browser/compositor/buffer_queue_unittest.cc',
'browser/compositor/reflector_impl_unittest.cc',
'browser/compositor/software_browser_compositor_output_surface_unittest.cc', 'browser/compositor/software_browser_compositor_output_surface_unittest.cc',
'browser/compositor/software_output_device_ozone_unittest.cc', 'browser/compositor/software_output_device_ozone_unittest.cc',
'browser/databases_table_unittest.cc', 'browser/databases_table_unittest.cc',
......
...@@ -595,7 +595,6 @@ if (!is_mac) { # TODO(GYP) enable on Mac once it links. ...@@ -595,7 +595,6 @@ if (!is_mac) { # TODO(GYP) enable on Mac once it links.
if (!use_aura && !is_mac) { if (!use_aura && !is_mac) {
sources -= [ sources -= [
"../browser/compositor/buffer_queue_unittest.cc", "../browser/compositor/buffer_queue_unittest.cc",
"../browser/compositor/reflector_impl_unittest.cc",
"../browser/compositor/software_browser_compositor_output_surface_unittest.cc", "../browser/compositor/software_browser_compositor_output_surface_unittest.cc",
] ]
} }
......
...@@ -43,7 +43,6 @@ component("compositor") { ...@@ -43,7 +43,6 @@ component("compositor") {
"layer_tree_owner.cc", "layer_tree_owner.cc",
"layer_tree_owner.h", "layer_tree_owner.h",
"layer_type.h", "layer_type.h",
"reflector.cc",
"reflector.h", "reflector.h",
"scoped_animation_duration_scale_mode.cc", "scoped_animation_duration_scale_mode.cc",
"scoped_animation_duration_scale_mode.h", "scoped_animation_duration_scale_mode.h",
......
...@@ -61,7 +61,6 @@ ...@@ -61,7 +61,6 @@
'layer_tree_owner.cc', 'layer_tree_owner.cc',
'layer_tree_owner.h', 'layer_tree_owner.h',
'layer_type.h', 'layer_type.h',
'reflector.cc',
'reflector.h', 'reflector.h',
'scoped_animation_duration_scale_mode.cc', 'scoped_animation_duration_scale_mode.cc',
'scoped_animation_duration_scale_mode.h', 'scoped_animation_duration_scale_mode.h',
......
...@@ -557,16 +557,6 @@ void Layer::SetTextureSize(gfx::Size texture_size_in_dip) { ...@@ -557,16 +557,6 @@ void Layer::SetTextureSize(gfx::Size texture_size_in_dip) {
texture_layer_->SetNeedsDisplay(); texture_layer_->SetNeedsDisplay();
} }
void Layer::SetTextureFlipped(bool flipped) {
DCHECK(texture_layer_.get());
texture_layer_->SetFlipped(flipped);
}
bool Layer::TextureFlipped() const {
DCHECK(texture_layer_.get());
return texture_layer_->flipped();
}
void Layer::SetShowDelegatedContent(cc::DelegatedFrameProvider* frame_provider, void Layer::SetShowDelegatedContent(cc::DelegatedFrameProvider* frame_provider,
gfx::Size frame_size_in_dip) { gfx::Size frame_size_in_dip) {
DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR); DCHECK(type_ == LAYER_TEXTURED || type_ == LAYER_SOLID_COLOR);
......
...@@ -274,8 +274,6 @@ class COMPOSITOR_EXPORT Layer ...@@ -274,8 +274,6 @@ class COMPOSITOR_EXPORT Layer
scoped_ptr<cc::SingleReleaseCallback> release_callback, scoped_ptr<cc::SingleReleaseCallback> release_callback,
gfx::Size texture_size_in_dip); gfx::Size texture_size_in_dip);
void SetTextureSize(gfx::Size texture_size_in_dip); void SetTextureSize(gfx::Size texture_size_in_dip);
void SetTextureFlipped(bool flipped);
bool TextureFlipped() const;
// Begins showing delegated frames from the |frame_provider|. // Begins showing delegated frames from the |frame_provider|.
void SetShowDelegatedContent(cc::DelegatedFrameProvider* frame_provider, void SetShowDelegatedContent(cc::DelegatedFrameProvider* frame_provider,
......
// 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 "ui/compositor/reflector.h"
namespace ui {
Reflector::Reflector() {
}
Reflector::~Reflector() {
}
void Reflector::OnMirroringCompositorResized() {
}
} // namespace ui
...@@ -6,20 +6,18 @@ ...@@ -6,20 +6,18 @@
#define UI_COMPOSITOR_REFLECTOR_H_ #define UI_COMPOSITOR_REFLECTOR_H_
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "ui/compositor/compositor_export.h"
namespace ui { namespace ui {
class COMPOSITOR_EXPORT Reflector class Reflector : public base::RefCountedThreadSafe<Reflector> {
: public base::RefCountedThreadSafe<Reflector> {
public: public:
Reflector(); Reflector() {}
virtual void OnMirroringCompositorResized(); virtual void OnMirroringCompositorResized() {}
protected: protected:
friend class base::RefCountedThreadSafe<Reflector>; friend class base::RefCountedThreadSafe<Reflector>;
virtual ~Reflector(); virtual ~Reflector() {}
DISALLOW_COPY_AND_ASSIGN(Reflector); DISALLOW_COPY_AND_ASSIGN(Reflector);
}; };
......
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