Skip to content

Commit

Permalink
mojo struct_traits for ozone OverlaySurfaceCandidate
Browse files Browse the repository at this point in the history
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: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Daniel Nicoara <dnicoara@chromium.org>
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487315}
  • Loading branch information
rjkroege authored and Commit Bot committed Jul 18, 2017
1 parent 5289ff3 commit 211fb8b
Show file tree
Hide file tree
Showing 27 changed files with 442 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ _typemap_imports = [
"//ui/events/mojo/typemaps.gni",
"//ui/gfx/typemaps.gni",
"//ui/latency/mojo/typemaps.gni",
"//ui/ozone/public/interfaces/typemaps.gni",
"//ui/message_center/mojo/typemaps.gni",
"//url/mojo/typemaps.gni",
]
Expand Down
1 change: 1 addition & 0 deletions ui/gfx/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ source_set("memory_buffer_sources") {
"native_pixmap.h",
"native_pixmap_handle.cc",
"native_pixmap_handle.h",
"overlay_transform.h",
]

if (!is_ios) {
Expand Down
1 change: 1 addition & 0 deletions ui/gfx/mojo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mojom("mojo") {
"buffer_types.mojom",
"color_space.mojom",
"icc_profile.mojom",
"overlay_transform.mojom",
"selection_bound.mojom",
"transform.mojom",
]
Expand Down
17 changes: 17 additions & 0 deletions ui/gfx/mojo/overlay_transform.mojom
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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
};
11 changes: 11 additions & 0 deletions ui/gfx/mojo/overlay_transform.typemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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" ]
68 changes: 68 additions & 0 deletions ui/gfx/mojo/overlay_transform_struct_traits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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_
1 change: 1 addition & 0 deletions ui/gfx/typemaps.gni
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ typemaps = [
"//ui/gfx/mojo/buffer_types.typemap",
"//ui/gfx/mojo/color_space.typemap",
"//ui/gfx/mojo/icc_profile.typemap",
"//ui/gfx/mojo/overlay_transform.typemap",
"//ui/gfx/mojo/selection_bound.typemap",
"//ui/gfx/mojo/transform.typemap",
"//ui/gfx/range/mojo/range.typemap",
Expand Down
14 changes: 8 additions & 6 deletions ui/ozone/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ component("ozone_base") {
"public/overlay_candidates_ozone.cc",
"public/overlay_candidates_ozone.h",
"public/overlay_manager_ozone.h",
"public/overlay_surface_candidate.cc",
"public/overlay_surface_candidate.h",
"public/ozone_switches.cc",
"public/ozone_switches.h",
"public/surface_factory_ozone.cc",
Expand Down Expand Up @@ -97,8 +99,9 @@ component("ozone_base") {
# things that would otherwise create a cycle.
"//ui/base",
"//ui/events/ozone/*",
"//ui/ozone/platform/*",
"//ui/ozone/common/*",
"//ui/ozone/public/interfaces",
"//ui/ozone/platform/*",
]
}

Expand Down Expand Up @@ -145,7 +148,6 @@ source_set("platform") {
deps = [
":generate_constructor_list",
":generate_ozone_platform_list",
"//ui/ozone/public/interfaces",
]

deps += ozone_platform_deps
Expand All @@ -162,6 +164,7 @@ component("ozone") {
visibility = [ "*" ]
public_deps = [
":platform",
"//ui/ozone/public/interfaces",
]
}

Expand Down Expand Up @@ -211,15 +214,14 @@ action("generate_constructor_list") {
}

test("ozone_unittests") {
sources = [
"run_all_unittests.cc",
]

deps = [
"//base/test:test_support",
"//mojo/edk/test:run_all_unittests",
"//mojo/public/cpp/bindings",
"//testing/gtest",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
"//ui/ozone/public/interfaces:struct_trait_unit_test",
]

# Add tests of platform internals.
Expand Down
5 changes: 5 additions & 0 deletions ui/ozone/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ include_rules = [
"+ui/gl",
"+ui/platform_window",
]
specific_include_rules = {
"run_all_unittests\.cc": [
"+mojo/edk/embedder/embedder.h",
],
}
12 changes: 5 additions & 7 deletions ui/ozone/common/gpu/ozone_gpu_message_params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/ipc/gfx_param_traits.h"
#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
#include "ui/ozone/public/overlay_surface_candidate.h"

namespace ui {

DisplayMode_Params::DisplayMode_Params() {
}
DisplayMode_Params::DisplayMode_Params() {}

DisplayMode_Params::~DisplayMode_Params() {}

DisplaySnapshot_Params::DisplaySnapshot_Params() {
}
DisplaySnapshot_Params::DisplaySnapshot_Params() {}

DisplaySnapshot_Params::DisplaySnapshot_Params(
const DisplaySnapshot_Params& other) = default;
Expand All @@ -26,7 +25,7 @@ DisplaySnapshot_Params::~DisplaySnapshot_Params() {}
OverlayCheck_Params::OverlayCheck_Params() {}

OverlayCheck_Params::OverlayCheck_Params(
const OverlayCandidatesOzone::OverlaySurfaceCandidate& candidate)
const ui::OverlaySurfaceCandidate& candidate)
: buffer_size(candidate.buffer_size),
transform(candidate.transform),
format(candidate.format),
Expand All @@ -37,8 +36,7 @@ OverlayCheck_Params::OverlayCheck_Params(
OverlayCheck_Params::OverlayCheck_Params(const OverlayCheck_Params& other) =
default;

OverlayCheck_Params::~OverlayCheck_Params() {
}
OverlayCheck_Params::~OverlayCheck_Params() {}

bool OverlayCheck_Params::operator<(const OverlayCheck_Params& param) const {
int lwidth = buffer_size.width();
Expand Down
4 changes: 2 additions & 2 deletions ui/ozone/common/gpu/ozone_gpu_message_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ui/ozone/public/overlay_candidates_ozone.h"

namespace ui {
class OverlaySurfaceCandidate;

struct DisplayMode_Params {
DisplayMode_Params();
Expand Down Expand Up @@ -56,8 +57,7 @@ struct DisplaySnapshot_Params {

struct OverlayCheck_Params {
OverlayCheck_Params();
OverlayCheck_Params(
const OverlayCandidatesOzone::OverlaySurfaceCandidate& candidate);
OverlayCheck_Params(const OverlaySurfaceCandidate& candidate);
OverlayCheck_Params(const OverlayCheck_Params& other);
~OverlayCheck_Params();

Expand Down
2 changes: 1 addition & 1 deletion ui/ozone/demo/surfaceless_gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void SurfacelessGlRenderer::OverlayChecker(int z_order,
gfx::RectF display_rect(bounds_rect.x(), bounds_rect.y(), bounds_rect.width(),
bounds_rect.height());

OverlayCandidatesOzone::OverlaySurfaceCandidate overlay_candidate;
OverlaySurfaceCandidate overlay_candidate;

// The bounds rectangle of the candidate overlay buffer.
overlay_candidate.buffer_size = bounds_rect.size();
Expand Down
6 changes: 3 additions & 3 deletions ui/ozone/platform/drm/host/drm_overlay_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
#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_manager.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
#include "ui/ozone/public/ozone_switches.h"

namespace ui {

typedef OverlayCandidatesOzone::OverlaySurfaceCandidateList
OverlaySurfaceCandidateList;
typedef OverlayCandidatesOzone::OverlaySurfaceCandidate OverlaySurfaceCandidate;
using OverlaySurfaceCandidateList =
OverlayCandidatesOzone::OverlaySurfaceCandidateList;

namespace {
const size_t kMaxCacheSize = 200;
Expand Down
6 changes: 3 additions & 3 deletions ui/ozone/platform/drm/host/drm_overlay_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace ui {
class DrmWindowHostManager;
class OverlaySurfaceCandidate;

class DrmOverlayManager : public OverlayManagerOzone {
public:
Expand Down Expand Up @@ -48,9 +49,8 @@ class DrmOverlayManager : public OverlayManagerOzone {
void SendOverlayValidationRequest(
const std::vector<OverlayCheck_Params>& new_params,
gfx::AcceleratedWidget widget) const;
bool CanHandleCandidate(
const OverlayCandidatesOzone::OverlaySurfaceCandidate& candidate,
gfx::AcceleratedWidget widget) const;
bool CanHandleCandidate(const OverlaySurfaceCandidate& candidate,
gfx::AcceleratedWidget widget) const;

GpuThreadAdapter* proxy_; // Not owned.
DrmWindowHostManager* window_manager_; // Not owned.
Expand Down
35 changes: 30 additions & 5 deletions ui/ozone/public/interfaces/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
sources = [
"device_cursor.mojom",
]

import_dirs = [
get_path_info("../../../..", "abspath"),
"//mojo/services",
"overlay_surface_candidate.mojom",
]

public_deps = [
Expand All @@ -20,3 +16,32 @@ mojom("interfaces") {
"//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",
]
}
3 changes: 3 additions & 0 deletions ui/ozone/public/interfaces/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include_rules = [
"+mojo/public",
]
4 changes: 4 additions & 0 deletions ui/ozone/public/interfaces/OWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
per-file *.mojom=set noparent
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
37 changes: 37 additions & 0 deletions ui/ozone/public/interfaces/overlay_surface_candidate.mojom
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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;
};
Loading

0 comments on commit 211fb8b

Please sign in to comment.