Skip to content

Commit

Permalink
Revert of view_manager: Add a stub impl for PlatformWindow, and remov…
Browse files Browse the repository at this point in the history
…e PlatformViewportHeadless. (patchset chromium#2 id:20001 of https://codereview.chromium.org/1214373004/)

Reason for revert:
Broke the mac/gn bot: http://build.chromium.org/p/chromium.mac/builders/Mac%20GN/builds/11926

ERROR at //ui/platform_window/BUILD.gn:35:3: Undefined variable for +=.
  deps += [ "//ui/platform_window/stub" ]
  ^---
I don't have something with this name in scope now.

Original issue's description:
> view_manager: Add a stub impl for PlatformWindow, and remove PlatformViewportHeadless.
>
> After this change, only a single implementation of PlatformViewport remains. A follow-up CL
> will remove PlatformViewport entirely, and directly use PlatformWindow from DisplayManager
> instead.
>
> BUG=487881
>
> Committed: https://crrev.com/c8d744ce9c9f96a63be9fcf2b67ff7202986ff3a
> Cr-Commit-Position: refs/heads/master@{#337068}

TBR=sky@chromium.org,sadrul@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=487881

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

Cr-Commit-Position: refs/heads/master@{#337153}
  • Loading branch information
nico authored and Commit bot committed Jul 2, 2015
1 parent 5648c85 commit 0e0809c
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 172 deletions.
7 changes: 7 additions & 0 deletions components/view_manager/native_viewport/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ source_set("native_viewport") {
"onscreen_context_provider.h",
"platform_viewport.h",
"platform_viewport_common.cc",
"platform_viewport_headless.cc",
"platform_viewport_headless.h",
"platform_viewport_stub.cc",
]

if (!is_ios) {
sources -= [ "platform_viewport_stub.cc" ]
}

deps = [
"//base",
"//components/view_manager/gles2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "components/view_manager/native_viewport/platform_viewport_headless.h"
#include "components/view_manager/public/interfaces/view_manager.mojom.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/input_events/input_events_type_converters.h"
Expand All @@ -16,7 +17,6 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
#include "ui/platform_window/stub/stub_window.h"

#if defined(OS_WIN)
#include "ui/platform_window/win/win_window.h"
Expand All @@ -42,8 +42,8 @@ float ConvertUIWheelValueToMojoValue(int offset) {
class PlatformViewportCommon : public PlatformViewport,
public ui::PlatformWindowDelegate {
public:
PlatformViewportCommon(Delegate* delegate, bool headless)
: delegate_(delegate), headless_(headless) {}
explicit PlatformViewportCommon(Delegate* delegate) : delegate_(delegate) {
}

~PlatformViewportCommon() override {
// Destroy the platform-window while |this| is still alive.
Expand All @@ -58,17 +58,13 @@ class PlatformViewportCommon : public PlatformViewport,
metrics_ = mojo::ViewportMetrics::New();
metrics_->size_in_pixels = mojo::Size::From(bounds.size());

if (headless_) {
platform_window_.reset(new ui::StubWindow(this));
} else {
#if defined(OS_WIN)
platform_window_.reset(new ui::WinWindow(this, bounds));
platform_window_.reset(new ui::WinWindow(this, bounds));
#elif defined(USE_X11)
platform_window_.reset(new ui::X11Window(this));
platform_window_.reset(new ui::X11Window(this));
#elif defined(OS_ANDROID)
platform_window_.reset(new ui::PlatformWindowAndroid(this));
platform_window_.reset(new ui::PlatformWindowAndroid(this));
#endif
}
platform_window_->SetBounds(bounds);
}

Expand Down Expand Up @@ -175,7 +171,6 @@ class PlatformViewportCommon : public PlatformViewport,

scoped_ptr<ui::PlatformWindow> platform_window_;
Delegate* delegate_;
bool headless_;
mojo::ViewportMetricsPtr metrics_;

DISALLOW_COPY_AND_ASSIGN(PlatformViewportCommon);
Expand All @@ -184,7 +179,9 @@ class PlatformViewportCommon : public PlatformViewport,
// static
scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate,
bool headless) {
return make_scoped_ptr(new PlatformViewportCommon(delegate, headless));
if (headless)
return PlatformViewportHeadless::Create(delegate);
return make_scoped_ptr(new PlatformViewportCommon(delegate));
}

} // namespace native_viewport
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2013 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 "components/view_manager/native_viewport/platform_viewport_headless.h"

#include "mojo/converters/geometry/geometry_type_converters.h"

namespace native_viewport {

PlatformViewportHeadless::PlatformViewportHeadless(Delegate* delegate)
: delegate_(delegate) {
}

PlatformViewportHeadless::~PlatformViewportHeadless() {
}

void PlatformViewportHeadless::Init(const gfx::Rect& bounds) {
metrics_ = mojo::ViewportMetrics::New();
metrics_->device_pixel_ratio = 1.f;
metrics_->size_in_pixels = mojo::Size::From(bounds.size());

// The delegate assumes an initial metrics of 0.
delegate_->OnMetricsChanged(bounds.size(), 1.f /* device_scale_factor */);
}

void PlatformViewportHeadless::Show() {
}

void PlatformViewportHeadless::Hide() {
}

void PlatformViewportHeadless::Close() {
delegate_->OnDestroyed();
}

gfx::Size PlatformViewportHeadless::GetSize() {
return metrics_->size_in_pixels.To<gfx::Size>();
}

void PlatformViewportHeadless::SetBounds(const gfx::Rect& bounds) {
delegate_->OnMetricsChanged(bounds.size(), 1.f /* device_scale_factor */);
}

// static
scoped_ptr<PlatformViewport> PlatformViewportHeadless::Create(
Delegate* delegate) {
return scoped_ptr<PlatformViewport>(
new PlatformViewportHeadless(delegate)).Pass();
}

} // namespace native_viewport
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2013 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 COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_HEADLESS_H_
#define COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_HEADLESS_H_

#include "base/macros.h"
#include "components/view_manager/native_viewport/platform_viewport.h"
#include "components/view_manager/public/interfaces/view_manager.mojom.h"
#include "ui/gfx/geometry/rect.h"

namespace native_viewport {

class PlatformViewportHeadless : public PlatformViewport {
public:
~PlatformViewportHeadless() override;

static scoped_ptr<PlatformViewport> Create(Delegate* delegate);

private:
explicit PlatformViewportHeadless(Delegate* delegate);

// Overridden from PlatformViewport:
void Init(const gfx::Rect& bounds) override;
void Show() override;
void Hide() override;
void Close() override;
gfx::Size GetSize() override;
void SetBounds(const gfx::Rect& bounds) override;

Delegate* delegate_;
mojo::ViewportMetricsPtr metrics_;

DISALLOW_COPY_AND_ASSIGN(PlatformViewportHeadless);
};

} // namespace native_viewport

#endif // COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_HEADLESS_H_
14 changes: 14 additions & 0 deletions components/view_manager/native_viewport/platform_viewport_stub.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.

#include "components/view_manager/native_viewport/platform_viewport_headless.h"

namespace mojo {

// static
scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) {
return PlatformViewportHeadless::Create(delegate);
}

} // namespace mojo
1 change: 0 additions & 1 deletion ui/platform_window/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ group("platform_impls") {
"//ui/platform_window/win",
]
}
deps += [ "//ui/platform_window/stub" ]
}
20 changes: 0 additions & 20 deletions ui/platform_window/stub/BUILD.gn

This file was deleted.

66 changes: 0 additions & 66 deletions ui/platform_window/stub/stub_window.cc

This file was deleted.

44 changes: 0 additions & 44 deletions ui/platform_window/stub/stub_window.h

This file was deleted.

29 changes: 0 additions & 29 deletions ui/platform_window/stub/stub_window_export.h

This file was deleted.

0 comments on commit 0e0809c

Please sign in to comment.