Commit dc0d744a authored by junweifu's avatar junweifu Committed by Commit Bot

ShapeDetection: Convert mojom::LandmarkType to String with TypeConvert

We can hopefully find these conversion locations in the future if we find a
better solution for Mojo-IDL intero although TypeConvert is deprecated.

Use LUCI for chromium tests on Windows 10 in PRSUBMITs.py.

BUG=841649

Cq-Include-Trybots: luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win10_chromium_x64_rel_ng
Change-Id: Ic235bcf98ecd53c5d873a8faf4ed72f1f60530b3
Reviewed-on: https://chromium-review.googlesource.com/1063291
Commit-Queue: Junwei Fu <junwei.fu@intel.com>
Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561343}
parent 734e5526
......@@ -20,6 +20,6 @@ def PostUploadHook(cl, change, output_api):
cl,
[
'luci.chromium.try:mac_optional_gpu_tests_rel',
'master.tryserver.chromium.win:win10_chromium_x64_rel_ng'
'luci.chromium.try:win10_chromium_x64_rel_ng'
],
'Automatically added optional Mac GPU and Windows 10 tests to run on CQ.')
......@@ -16,6 +16,7 @@ blink_modules_sources("shapedetection") {
"detected_text.h",
"face_detector.cc",
"face_detector.h",
"shape_detection_type_converter.h",
"shape_detector.cc",
"shape_detector.h",
"text_detector.cc",
......
......@@ -10,4 +10,5 @@ include_rules = [
"+third_party/skia/include/core/SkImage.h",
"+third_party/skia/include/core/SkImageInfo.h",
"+ui/gfx/geometry",
"+mojo/public/cpp/bindings/type_converter.h",
]
mcasas@chromium.org
reillyg@chromium.org
per-file *_type_converter*.*=set noparent
per-file *_type_converter*.*=file://ipc/SECURITY_OWNERS
# COMPONENT: Blink>ImageCapture
# TEAM: media-dev@chromium.org
......@@ -16,6 +16,8 @@
#include "third_party/blink/renderer/modules/shapedetection/detected_face.h"
#include "third_party/blink/renderer/modules/shapedetection/face_detector_options.h"
#include "third_party/blink/renderer/modules/shapedetection/landmark.h"
#include "third_party/blink/renderer/modules/shapedetection/shape_detection_type_converter.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
......@@ -81,17 +83,7 @@ void FaceDetector::OnDetectFaces(
Landmark web_landmark;
web_landmark.setLocations(locations);
// TODO(junwei.fu): Consider using TypeConverter to convert the type of
// landmark from Mojo to IDL (https://crbug.com/841649).
if (landmark->type == shape_detection::mojom::blink::LandmarkType::EYE) {
web_landmark.setType("eye");
} else if (landmark->type ==
shape_detection::mojom::blink::LandmarkType::MOUTH) {
web_landmark.setType("mouth");
} else if (landmark->type ==
shape_detection::mojom::blink::LandmarkType::NOSE) {
web_landmark.setType("nose");
}
web_landmark.setType(mojo::ConvertTo<String>(landmark->type));
landmarks.push_back(web_landmark);
}
......
// Copyright 2018 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 THIRD_PARTY_BLINK_RENDERER_MODULES_SHAPEDETECTION_SHAPE_DETECTION_TYPE_CONVERTER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_SHAPEDETECTION_SHAPE_DETECTION_TYPE_CONVERTER_H_
#include "mojo/public/cpp/bindings/type_converter.h"
#include "services/shape_detection/public/mojom/facedetection.mojom-blink.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace mojo {
// TypeConverter to translate from shape_detection::mojom::blink::LandmarkType
// to String.
template <>
struct TypeConverter<String, shape_detection::mojom::blink::LandmarkType> {
static String Convert(shape_detection::mojom::blink::LandmarkType input) {
switch (input) {
case shape_detection::mojom::blink::LandmarkType::EYE:
return "eye";
case shape_detection::mojom::blink::LandmarkType::MOUTH:
return "mouth";
case shape_detection::mojom::blink::LandmarkType::NOSE:
return "nose";
}
NOTREACHED();
return "";
}
};
} // namespace mojo
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_SHAPEDETECTION_SHAPE_DETECTION_TYPE_CONVERTER_H_
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