Commit 211fb8b5 authored by Robert Kroeger's avatar Robert Kroeger Committed by Commit Bot

mojo struct_traits for ozone OverlaySurfaceCandidate

Add struct_traits for OverlaySurfaceCandidate to enable mojo IPC in
ozone.

BUG=620927

Change-Id: I16a6058f6ef411ab7acfeedc8ba35d080baed674
Reviewed-on: https://chromium-review.googlesource.com/571980
Commit-Queue: Robert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarYuzhu Shen <yzshen@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487315}
parent 5289ff36
...@@ -43,6 +43,7 @@ _typemap_imports = [ ...@@ -43,6 +43,7 @@ _typemap_imports = [
"//ui/events/mojo/typemaps.gni", "//ui/events/mojo/typemaps.gni",
"//ui/gfx/typemaps.gni", "//ui/gfx/typemaps.gni",
"//ui/latency/mojo/typemaps.gni", "//ui/latency/mojo/typemaps.gni",
"//ui/ozone/public/interfaces/typemaps.gni",
"//ui/message_center/mojo/typemaps.gni", "//ui/message_center/mojo/typemaps.gni",
"//url/mojo/typemaps.gni", "//url/mojo/typemaps.gni",
] ]
......
...@@ -522,6 +522,7 @@ source_set("memory_buffer_sources") { ...@@ -522,6 +522,7 @@ source_set("memory_buffer_sources") {
"native_pixmap.h", "native_pixmap.h",
"native_pixmap_handle.cc", "native_pixmap_handle.cc",
"native_pixmap_handle.h", "native_pixmap_handle.h",
"overlay_transform.h",
] ]
if (!is_ios) { if (!is_ios) {
......
...@@ -10,6 +10,7 @@ mojom("mojo") { ...@@ -10,6 +10,7 @@ mojom("mojo") {
"buffer_types.mojom", "buffer_types.mojom",
"color_space.mojom", "color_space.mojom",
"icc_profile.mojom", "icc_profile.mojom",
"overlay_transform.mojom",
"selection_bound.mojom", "selection_bound.mojom",
"transform.mojom", "transform.mojom",
] ]
......
// Copyright 2017 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.
module gfx.mojom;
// gfx::OverlayTransform
enum OverlayTransform {
OVERLAY_TRANSFORM_INVALID,
OVERLAY_TRANSFORM_NONE,
OVERLAY_TRANSFORM_FLIP_HORIZONTAL,
OVERLAY_TRANSFORM_FLIP_VERTICAL,
OVERLAY_TRANSFORM_ROTATE_90,
OVERLAY_TRANSFORM_ROTATE_180,
OVERLAY_TRANSFORM_ROTATE_270,
OVERLAY_TRANSFORM_LAST = OVERLAY_TRANSFORM_ROTATE_270
};
# Copyright 2017 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.
mojom = "//ui/gfx/mojo/overlay_transform.mojom"
public_headers = [ "//ui/gfx/overlay_transform.h" ]
traits_headers = [ "//ui/gfx/mojo/overlay_transform_struct_traits.h" ]
public_deps = [
"//ui/gfx",
]
type_mappings = [ "gfx.mojom.OverlayTransform=gfx::OverlayTransform" ]
// Copyright 2017 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 UI_GFX_MOJO_OVERLAY_TRANSFORM_STRUCT_TRAITS_H_
#define UI_GFX_MOJO_OVERLAY_TRANSFORM_STRUCT_TRAITS_H_
#include "ui/gfx/mojo/overlay_transform.mojom.h"
#include "ui/gfx/overlay_transform.h"
namespace mojo {
template <>
struct EnumTraits<gfx::mojom::OverlayTransform, gfx::OverlayTransform> {
static gfx::mojom::OverlayTransform ToMojom(gfx::OverlayTransform format) {
switch (format) {
case gfx::OverlayTransform::OVERLAY_TRANSFORM_INVALID:
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_INVALID;
case gfx::OverlayTransform::OVERLAY_TRANSFORM_NONE:
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_NONE;
case gfx::OverlayTransform::OVERLAY_TRANSFORM_FLIP_HORIZONTAL:
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_FLIP_HORIZONTAL;
case gfx::OverlayTransform::OVERLAY_TRANSFORM_FLIP_VERTICAL:
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_FLIP_VERTICAL;
case gfx::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_90:
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_90;
case gfx::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_180:
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_180;
case gfx::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_270:
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_270;
}
NOTREACHED();
return gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_INVALID;
}
static bool FromMojom(gfx::mojom::OverlayTransform input,
gfx::OverlayTransform* out) {
switch (input) {
case gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_INVALID:
*out = gfx::OverlayTransform::OVERLAY_TRANSFORM_INVALID;
return true;
case gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_NONE:
*out = gfx::OverlayTransform::OVERLAY_TRANSFORM_NONE;
return true;
case gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_FLIP_HORIZONTAL:
*out = gfx::OverlayTransform::OVERLAY_TRANSFORM_FLIP_HORIZONTAL;
return true;
case gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_FLIP_VERTICAL:
*out = gfx::OverlayTransform::OVERLAY_TRANSFORM_FLIP_VERTICAL;
return true;
case gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_90:
*out = gfx::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_90;
return true;
case gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_180:
*out = gfx::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_180;
return true;
case gfx::mojom::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_270:
*out = gfx::OverlayTransform::OVERLAY_TRANSFORM_ROTATE_270;
return true;
}
NOTREACHED();
return false;
}
};
} // namespace mojo
#endif // UI_GFX_MOJO_OVERLAY_TRANSFORM_STRUCT_TRAITS_H_
...@@ -9,6 +9,7 @@ typemaps = [ ...@@ -9,6 +9,7 @@ typemaps = [
"//ui/gfx/mojo/buffer_types.typemap", "//ui/gfx/mojo/buffer_types.typemap",
"//ui/gfx/mojo/color_space.typemap", "//ui/gfx/mojo/color_space.typemap",
"//ui/gfx/mojo/icc_profile.typemap", "//ui/gfx/mojo/icc_profile.typemap",
"//ui/gfx/mojo/overlay_transform.typemap",
"//ui/gfx/mojo/selection_bound.typemap", "//ui/gfx/mojo/selection_bound.typemap",
"//ui/gfx/mojo/transform.typemap", "//ui/gfx/mojo/transform.typemap",
"//ui/gfx/range/mojo/range.typemap", "//ui/gfx/range/mojo/range.typemap",
......
...@@ -65,6 +65,8 @@ component("ozone_base") { ...@@ -65,6 +65,8 @@ component("ozone_base") {
"public/overlay_candidates_ozone.cc", "public/overlay_candidates_ozone.cc",
"public/overlay_candidates_ozone.h", "public/overlay_candidates_ozone.h",
"public/overlay_manager_ozone.h", "public/overlay_manager_ozone.h",
"public/overlay_surface_candidate.cc",
"public/overlay_surface_candidate.h",
"public/ozone_switches.cc", "public/ozone_switches.cc",
"public/ozone_switches.h", "public/ozone_switches.h",
"public/surface_factory_ozone.cc", "public/surface_factory_ozone.cc",
...@@ -97,8 +99,9 @@ component("ozone_base") { ...@@ -97,8 +99,9 @@ component("ozone_base") {
# things that would otherwise create a cycle. # things that would otherwise create a cycle.
"//ui/base", "//ui/base",
"//ui/events/ozone/*", "//ui/events/ozone/*",
"//ui/ozone/platform/*",
"//ui/ozone/common/*", "//ui/ozone/common/*",
"//ui/ozone/public/interfaces",
"//ui/ozone/platform/*",
] ]
} }
...@@ -145,7 +148,6 @@ source_set("platform") { ...@@ -145,7 +148,6 @@ source_set("platform") {
deps = [ deps = [
":generate_constructor_list", ":generate_constructor_list",
":generate_ozone_platform_list", ":generate_ozone_platform_list",
"//ui/ozone/public/interfaces",
] ]
deps += ozone_platform_deps deps += ozone_platform_deps
...@@ -162,6 +164,7 @@ component("ozone") { ...@@ -162,6 +164,7 @@ component("ozone") {
visibility = [ "*" ] visibility = [ "*" ]
public_deps = [ public_deps = [
":platform", ":platform",
"//ui/ozone/public/interfaces",
] ]
} }
...@@ -211,15 +214,14 @@ action("generate_constructor_list") { ...@@ -211,15 +214,14 @@ action("generate_constructor_list") {
} }
test("ozone_unittests") { test("ozone_unittests") {
sources = [
"run_all_unittests.cc",
]
deps = [ deps = [
"//base/test:test_support", "//base/test:test_support",
"//mojo/edk/test:run_all_unittests",
"//mojo/public/cpp/bindings",
"//testing/gtest", "//testing/gtest",
"//ui/gfx:test_support", "//ui/gfx:test_support",
"//ui/gfx/geometry", "//ui/gfx/geometry",
"//ui/ozone/public/interfaces:struct_trait_unit_test",
] ]
# Add tests of platform internals. # Add tests of platform internals.
......
...@@ -10,3 +10,8 @@ include_rules = [ ...@@ -10,3 +10,8 @@ include_rules = [
"+ui/gl", "+ui/gl",
"+ui/platform_window", "+ui/platform_window",
] ]
specific_include_rules = {
"run_all_unittests\.cc": [
"+mojo/edk/embedder/embedder.h",
],
}
...@@ -7,16 +7,15 @@ ...@@ -7,16 +7,15 @@
#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/ipc/gfx_param_traits.h" #include "ui/gfx/ipc/gfx_param_traits.h"
#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h" #include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
namespace ui { namespace ui {
DisplayMode_Params::DisplayMode_Params() { DisplayMode_Params::DisplayMode_Params() {}
}
DisplayMode_Params::~DisplayMode_Params() {} DisplayMode_Params::~DisplayMode_Params() {}
DisplaySnapshot_Params::DisplaySnapshot_Params() { DisplaySnapshot_Params::DisplaySnapshot_Params() {}
}
DisplaySnapshot_Params::DisplaySnapshot_Params( DisplaySnapshot_Params::DisplaySnapshot_Params(
const DisplaySnapshot_Params& other) = default; const DisplaySnapshot_Params& other) = default;
...@@ -26,7 +25,7 @@ DisplaySnapshot_Params::~DisplaySnapshot_Params() {} ...@@ -26,7 +25,7 @@ DisplaySnapshot_Params::~DisplaySnapshot_Params() {}
OverlayCheck_Params::OverlayCheck_Params() {} OverlayCheck_Params::OverlayCheck_Params() {}
OverlayCheck_Params::OverlayCheck_Params( OverlayCheck_Params::OverlayCheck_Params(
const OverlayCandidatesOzone::OverlaySurfaceCandidate& candidate) const ui::OverlaySurfaceCandidate& candidate)
: buffer_size(candidate.buffer_size), : buffer_size(candidate.buffer_size),
transform(candidate.transform), transform(candidate.transform),
format(candidate.format), format(candidate.format),
...@@ -37,8 +36,7 @@ OverlayCheck_Params::OverlayCheck_Params( ...@@ -37,8 +36,7 @@ OverlayCheck_Params::OverlayCheck_Params(
OverlayCheck_Params::OverlayCheck_Params(const OverlayCheck_Params& other) = OverlayCheck_Params::OverlayCheck_Params(const OverlayCheck_Params& other) =
default; default;
OverlayCheck_Params::~OverlayCheck_Params() { OverlayCheck_Params::~OverlayCheck_Params() {}
}
bool OverlayCheck_Params::operator<(const OverlayCheck_Params& param) const { bool OverlayCheck_Params::operator<(const OverlayCheck_Params& param) const {
int lwidth = buffer_size.width(); int lwidth = buffer_size.width();
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ui/ozone/public/overlay_candidates_ozone.h" #include "ui/ozone/public/overlay_candidates_ozone.h"
namespace ui { namespace ui {
class OverlaySurfaceCandidate;
struct DisplayMode_Params { struct DisplayMode_Params {
DisplayMode_Params(); DisplayMode_Params();
...@@ -56,8 +57,7 @@ struct DisplaySnapshot_Params { ...@@ -56,8 +57,7 @@ struct DisplaySnapshot_Params {
struct OverlayCheck_Params { struct OverlayCheck_Params {
OverlayCheck_Params(); OverlayCheck_Params();
OverlayCheck_Params( OverlayCheck_Params(const OverlaySurfaceCandidate& candidate);
const OverlayCandidatesOzone::OverlaySurfaceCandidate& candidate);
OverlayCheck_Params(const OverlayCheck_Params& other); OverlayCheck_Params(const OverlayCheck_Params& other);
~OverlayCheck_Params(); ~OverlayCheck_Params();
......
...@@ -131,7 +131,7 @@ void SurfacelessGlRenderer::OverlayChecker(int z_order, ...@@ -131,7 +131,7 @@ void SurfacelessGlRenderer::OverlayChecker(int z_order,
gfx::RectF display_rect(bounds_rect.x(), bounds_rect.y(), bounds_rect.width(), gfx::RectF display_rect(bounds_rect.x(), bounds_rect.y(), bounds_rect.width(),
bounds_rect.height()); bounds_rect.height());
OverlayCandidatesOzone::OverlaySurfaceCandidate overlay_candidate; OverlaySurfaceCandidate overlay_candidate;
// The bounds rectangle of the candidate overlay buffer. // The bounds rectangle of the candidate overlay buffer.
overlay_candidate.buffer_size = bounds_rect.size(); overlay_candidate.buffer_size = bounds_rect.size();
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
#include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h" #include "ui/ozone/platform/drm/host/drm_overlay_candidates_host.h"
#include "ui/ozone/platform/drm/host/drm_window_host.h" #include "ui/ozone/platform/drm/host/drm_window_host.h"
#include "ui/ozone/platform/drm/host/drm_window_host_manager.h" #include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
#include "ui/ozone/public/ozone_switches.h" #include "ui/ozone/public/ozone_switches.h"
namespace ui { namespace ui {
typedef OverlayCandidatesOzone::OverlaySurfaceCandidateList using OverlaySurfaceCandidateList =
OverlaySurfaceCandidateList; OverlayCandidatesOzone::OverlaySurfaceCandidateList;
typedef OverlayCandidatesOzone::OverlaySurfaceCandidate OverlaySurfaceCandidate;
namespace { namespace {
const size_t kMaxCacheSize = 200; const size_t kMaxCacheSize = 200;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
namespace ui { namespace ui {
class DrmWindowHostManager; class DrmWindowHostManager;
class OverlaySurfaceCandidate;
class DrmOverlayManager : public OverlayManagerOzone { class DrmOverlayManager : public OverlayManagerOzone {
public: public:
...@@ -48,9 +49,8 @@ class DrmOverlayManager : public OverlayManagerOzone { ...@@ -48,9 +49,8 @@ class DrmOverlayManager : public OverlayManagerOzone {
void SendOverlayValidationRequest( void SendOverlayValidationRequest(
const std::vector<OverlayCheck_Params>& new_params, const std::vector<OverlayCheck_Params>& new_params,
gfx::AcceleratedWidget widget) const; gfx::AcceleratedWidget widget) const;
bool CanHandleCandidate( bool CanHandleCandidate(const OverlaySurfaceCandidate& candidate,
const OverlayCandidatesOzone::OverlaySurfaceCandidate& candidate, gfx::AcceleratedWidget widget) const;
gfx::AcceleratedWidget widget) const;
GpuThreadAdapter* proxy_; // Not owned. GpuThreadAdapter* proxy_; // Not owned.
DrmWindowHostManager* window_manager_; // Not owned. DrmWindowHostManager* window_manager_; // Not owned.
......
...@@ -7,11 +7,7 @@ import("//mojo/public/tools/bindings/mojom.gni") ...@@ -7,11 +7,7 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") { mojom("interfaces") {
sources = [ sources = [
"device_cursor.mojom", "device_cursor.mojom",
] "overlay_surface_candidate.mojom",
import_dirs = [
get_path_info("../../../..", "abspath"),
"//mojo/services",
] ]
public_deps = [ public_deps = [
...@@ -20,3 +16,32 @@ mojom("interfaces") { ...@@ -20,3 +16,32 @@ mojom("interfaces") {
"//ui/gfx/mojo", "//ui/gfx/mojo",
] ]
} }
source_set("struct_traits") {
sources = [
"overlay_surface_candidate_struct_traits.h",
]
deps = [
"//ui/gfx/geometry/mojo:mojo",
"//ui/gfx/mojo:mojo",
]
public_deps = [
":interfaces",
":interfaces_shared_cpp_sources",
"//mojo/public/cpp/bindings",
]
}
source_set("struct_trait_unit_test") {
testonly = true
sources = [
"overlay_surface_candidate_struct_traits_unittest.cc",
]
deps = [
":interfaces",
"//testing/gtest",
"//ui/gfx/geometry",
]
}
include_rules = [
"+mojo/public",
]
per-file *.mojom=set noparent per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_struct_traits*.*=set noparent
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.typemap=set noparent
per-file *.typemap=file://ipc/SECURITY_OWNERS
// Copyright 2017 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.
module ui.ozone.mojom;
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/gfx/mojo/buffer_types.mojom";
import "ui/gfx/mojo/overlay_transform.mojom";
struct OverlaySurfaceCandidate {
// Transformation to apply to layer during composition.
gfx.mojom.OverlayTransform transform;
// Format of the buffer to composite.
gfx.mojom.BufferFormat format;
// Size of the buffer, in pixels.
gfx.mojom.Size buffer_size;
// Rect on the display to position the overlay to. Input rectangle may
// not have integer coordinates, but when accepting for overlay, must
// be modified by CheckOverlaySupport to output integer values.
gfx.mojom.RectF display_rect;
// Crop within the buffer to be placed inside |display_rect|.
gfx.mojom.RectF crop_rect;
// Quad geometry rect after applying the quad_transform().
gfx.mojom.Rect quad_rect_in_target_space;
// Clip rect in the target content space after composition.
gfx.mojom.Rect clip_rect;
// If the quad is clipped after composition.
bool is_clipped;
// Stacking order of the overlay plane relative to the main surface,
// which is 0. Signed to allow for "underlays".
int32 plane_z_order = 0;
// To be modified by the implementer if this candidate can go into
// an overlay.
bool overlay_handled;
};
# Copyright 2017 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.
mojom = "//ui/ozone/public/interfaces/overlay_surface_candidate.mojom"
public_headers = [ "//ui/ozone/public/overlay_surface_candidate.h" ]
public_deps = [
"//ui/ozone:ozone_base",
]
traits_headers =
[ "//ui/ozone/public/interfaces/overlay_surface_candidate_struct_traits.h" ]
type_mappings =
[ "ui.ozone.mojom.OverlaySurfaceCandidate=ui::OverlaySurfaceCandidate" ]
// Copyright 2017 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 UI_OZONE_PUBLIC_INTERFACES_OVERLAY_SURFACE_CANDIDATE_STRUCT_TRAITS_H_
#define UI_OZONE_PUBLIC_INTERFACES_OVERLAY_SURFACE_CANDIDATE_STRUCT_TRAITS_H_
#include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
#include "ui/gfx/mojo/buffer_types_struct_traits.h"
#include "ui/gfx/mojo/overlay_transform_struct_traits.h"
#include "ui/ozone/public/interfaces/overlay_surface_candidate.mojom.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
namespace mojo {
template <>
struct StructTraits<ui::ozone::mojom::OverlaySurfaceCandidateDataView,
ui::OverlaySurfaceCandidate> {
static const gfx::OverlayTransform& transform(
const ui::OverlaySurfaceCandidate& osc) {
return osc.transform;
}
static const gfx::BufferFormat& format(
const ui::OverlaySurfaceCandidate& osc) {
return osc.format;
}
static const gfx::Size& buffer_size(const ui::OverlaySurfaceCandidate& osc) {
return osc.buffer_size;
}
static const gfx::RectF& display_rect(
const ui::OverlaySurfaceCandidate& osc) {
return osc.display_rect;
}
static const gfx::RectF& crop_rect(const ui::OverlaySurfaceCandidate& osc) {
return osc.crop_rect;
}
static const gfx::Rect& quad_rect_in_target_space(
const ui::OverlaySurfaceCandidate& osc) {
return osc.quad_rect_in_target_space;
}
static const gfx::Rect& clip_rect(const ui::OverlaySurfaceCandidate& osc) {
return osc.clip_rect;
}
static bool is_clipped(const ui::OverlaySurfaceCandidate& osc) {
return osc.is_clipped;
}
static int plane_z_order(const ui::OverlaySurfaceCandidate& osc) {
return osc.plane_z_order;
}
static bool overlay_handled(const ui::OverlaySurfaceCandidate& osc) {
return osc.overlay_handled;
}
static bool Read(ui::ozone::mojom::OverlaySurfaceCandidateDataView data,
ui::OverlaySurfaceCandidate* out) {
out->is_clipped = data.is_clipped();
out->plane_z_order = data.plane_z_order();
out->overlay_handled = data.overlay_handled();
return data.ReadTransform(&out->transform) &&
data.ReadFormat(&out->format) &&
data.ReadBufferSize(&out->buffer_size) &&
data.ReadDisplayRect(&out->display_rect) &&
data.ReadCropRect(&out->crop_rect) &&
data.ReadQuadRectInTargetSpace(&out->quad_rect_in_target_space) &&
data.ReadClipRect(&out->clip_rect);
}
};
} // namespace mojo
#endif // UI_OZONE_PUBLIC_INTERFACES_OVERLAY_SURFACE_CANDIDATE_STRUCT_TRAITS_H_
// Copyright 2017 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 <utility>
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/point.h"
#include "ui/ozone/public/interfaces/overlay_surface_candidate.mojom.h"
#include "ui/ozone/public/interfaces/overlay_surface_candidate_struct_traits.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
namespace ui {
namespace {
class OverlaySurfaceCandidateStructTraitsTest : public testing::Test {
public:
OverlaySurfaceCandidateStructTraitsTest() {}
};
} // namespace
TEST_F(OverlaySurfaceCandidateStructTraitsTest, FieldsEqual) {
ui::OverlaySurfaceCandidate input;
input.transform = gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL;
input.format = gfx::BufferFormat::YUV_420_BIPLANAR;
input.buffer_size = gfx::Size(6, 7);
input.display_rect = gfx::RectF(1., 2., 3., 4.);
input.crop_rect = gfx::RectF(10., 20., 30., 40.);
input.quad_rect_in_target_space = gfx::Rect(101, 201, 301, 401);
input.clip_rect = gfx::Rect(11, 21, 31, 41);
input.is_clipped = true;
input.plane_z_order = 42;
input.overlay_handled = true;
ui::OverlaySurfaceCandidate output;
bool success = ui::ozone::mojom::OverlaySurfaceCandidate::Deserialize(
ui::ozone::mojom::OverlaySurfaceCandidate::Serialize(&input), &output);
EXPECT_TRUE(success);
EXPECT_EQ(input.transform, output.transform);
EXPECT_EQ(input.format, output.format);
EXPECT_EQ(input.buffer_size, output.buffer_size);
EXPECT_EQ(input.display_rect, output.display_rect);
EXPECT_EQ(input.crop_rect, output.crop_rect);
EXPECT_EQ(input.quad_rect_in_target_space, output.quad_rect_in_target_space);
EXPECT_EQ(input.clip_rect, output.clip_rect);
EXPECT_EQ(input.is_clipped, output.is_clipped);
EXPECT_EQ(input.plane_z_order, output.plane_z_order);
EXPECT_EQ(input.overlay_handled, output.overlay_handled);
}
TEST_F(OverlaySurfaceCandidateStructTraitsTest, FalseBools) {
ui::OverlaySurfaceCandidate input;
input.is_clipped = false;
input.overlay_handled = false;
ui::OverlaySurfaceCandidate output;
bool success = ui::ozone::mojom::OverlaySurfaceCandidate::Deserialize(
ui::ozone::mojom::OverlaySurfaceCandidate::Serialize(&input), &output);
EXPECT_TRUE(success);
EXPECT_EQ(input.is_clipped, output.is_clipped);
EXPECT_EQ(input.overlay_handled, output.overlay_handled);
}
} // namespace ui
# Copyright 2017 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.
typemaps = [ "//ui/ozone/public/interfaces/overlay_surface_candidate.typemap" ]
...@@ -8,21 +8,11 @@ ...@@ -8,21 +8,11 @@
namespace ui { namespace ui {
OverlayCandidatesOzone::OverlaySurfaceCandidate::OverlaySurfaceCandidate()
: is_clipped(false) {}
OverlayCandidatesOzone::OverlaySurfaceCandidate::OverlaySurfaceCandidate(
const OverlaySurfaceCandidate& other) = default;
OverlayCandidatesOzone::OverlaySurfaceCandidate::~OverlaySurfaceCandidate() {
}
void OverlayCandidatesOzone::CheckOverlaySupport( void OverlayCandidatesOzone::CheckOverlaySupport(
OverlaySurfaceCandidateList* surfaces) { OverlaySurfaceCandidateList* surfaces) {
NOTREACHED(); NOTREACHED();
} }
OverlayCandidatesOzone::~OverlayCandidatesOzone() { OverlayCandidatesOzone::~OverlayCandidatesOzone() {}
}
} // namespace ui } // namespace ui
...@@ -7,12 +7,8 @@ ...@@ -7,12 +7,8 @@
#include <vector> #include <vector>
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/overlay_transform.h"
#include "ui/ozone/ozone_base_export.h" #include "ui/ozone/ozone_base_export.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
namespace ui { namespace ui {
...@@ -21,38 +17,6 @@ namespace ui { ...@@ -21,38 +17,6 @@ namespace ui {
// class from SurfaceFactoryOzone given an AcceleratedWidget. // class from SurfaceFactoryOzone given an AcceleratedWidget.
class OZONE_BASE_EXPORT OverlayCandidatesOzone { class OZONE_BASE_EXPORT OverlayCandidatesOzone {
public: public:
struct OverlaySurfaceCandidate {
OverlaySurfaceCandidate();
OverlaySurfaceCandidate(const OverlaySurfaceCandidate& other);
~OverlaySurfaceCandidate();
// Transformation to apply to layer during composition.
gfx::OverlayTransform transform = gfx::OVERLAY_TRANSFORM_NONE;
// Format of the buffer to composite.
gfx::BufferFormat format = gfx::BufferFormat::BGRA_8888;
// Size of the buffer, in pixels.
gfx::Size buffer_size;
// Rect on the display to position the overlay to. Input rectangle may
// not have integer coordinates, but when accepting for overlay, must
// be modified by CheckOverlaySupport to output integer values.
gfx::RectF display_rect;
// Crop within the buffer to be placed inside |display_rect|.
gfx::RectF crop_rect;
// Quad geometry rect after applying the quad_transform().
gfx::Rect quad_rect_in_target_space;
// Clip rect in the target content space after composition.
gfx::Rect clip_rect;
// If the quad is clipped after composition.
bool is_clipped;
// Stacking order of the overlay plane relative to the main surface,
// which is 0. Signed to allow for "underlays".
int plane_z_order = 0;
// To be modified by the implementer if this candidate can go into
// an overlay.
bool overlay_handled = false;
};
typedef std::vector<OverlaySurfaceCandidate> OverlaySurfaceCandidateList; typedef std::vector<OverlaySurfaceCandidate> OverlaySurfaceCandidateList;
// A list of possible overlay candidates is presented to this function. // A list of possible overlay candidates is presented to this function.
......
// Copyright 2017 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/ozone/public/overlay_surface_candidate.h"
namespace ui {
OverlaySurfaceCandidate::OverlaySurfaceCandidate() : is_clipped(false) {}
OverlaySurfaceCandidate::OverlaySurfaceCandidate(
const OverlaySurfaceCandidate& other) = default;
OverlaySurfaceCandidate::~OverlaySurfaceCandidate() {}
} // namespace ui
// Copyright 2017 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 UI_OZONE_PUBLIC_OVERLAY_SURFACE_CANDIDATE_H_
#define UI_OZONE_PUBLIC_OVERLAY_SURFACE_CANDIDATE_H_
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/overlay_transform.h"
#include "ui/ozone/ozone_base_export.h"
namespace ui {
class OZONE_BASE_EXPORT OverlaySurfaceCandidate {
public:
OverlaySurfaceCandidate();
OverlaySurfaceCandidate(const OverlaySurfaceCandidate& other);
~OverlaySurfaceCandidate();
// Transformation to apply to layer during composition.
gfx::OverlayTransform transform = gfx::OVERLAY_TRANSFORM_NONE;
// Format of the buffer to composite.
gfx::BufferFormat format = gfx::BufferFormat::BGRA_8888;
// Size of the buffer, in pixels.
gfx::Size buffer_size;
// Rect on the display to position the overlay to. Input rectangle may
// not have integer coordinates, but when accepting for overlay, must
// be modified by CheckOverlaySupport to output integer values.
gfx::RectF display_rect;
// Crop within the buffer to be placed inside |display_rect|.
gfx::RectF crop_rect;
// Quad geometry rect after applying the quad_transform().
gfx::Rect quad_rect_in_target_space;
// Clip rect in the target content space after composition.
gfx::Rect clip_rect;
// If the quad is clipped after composition.
bool is_clipped;
// Stacking order of the overlay plane relative to the main surface,
// which is 0. Signed to allow for "underlays".
int plane_z_order = 0;
// To be modified by the implementer if this candidate can go into
// an overlay.
bool overlay_handled = false;
};
} // namespace ui
#endif // UI_OZONE_PUBLIC_OVERLAY_SURFACE_CANDIDATE_H_
\ No newline at end of file
// 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 "base/bind.h"
#include "base/macros.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
namespace {
class OzoneTestSuite : public base::TestSuite {
public:
OzoneTestSuite(int argc, char** argv);
protected:
// base::TestSuite:
void Initialize() override;
void Shutdown() override;
private:
DISALLOW_COPY_AND_ASSIGN(OzoneTestSuite);
};
OzoneTestSuite::OzoneTestSuite(int argc, char** argv)
: base::TestSuite(argc, argv) {}
void OzoneTestSuite::Initialize() {
base::TestSuite::Initialize();
}
void OzoneTestSuite::Shutdown() {
base::TestSuite::Shutdown();
}
} // namespace
int main(int argc, char** argv) {
OzoneTestSuite test_suite(argc, argv);
return base::LaunchUnitTests(argc,
argv,
base::Bind(&OzoneTestSuite::Run,
base::Unretained(&test_suite)));
}
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