Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp

Issue 2528743002: Shape Detection: Implement FaceDetection on Mac as out-of-process service (Closed)
Patch Set: avi@ comments, rebase Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/shapedetection/FaceDetector.h" 5 #include "modules/shapedetection/FaceDetector.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/DOMRect.h" 8 #include "core/dom/DOMRect.h"
9 #include "core/frame/LocalDOMWindow.h" 9 #include "core/frame/LocalDOMWindow.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
11 #include "core/html/canvas/CanvasImageSource.h" 11 #include "core/html/canvas/CanvasImageSource.h"
12 #include "modules/shapedetection/DetectedFace.h" 12 #include "modules/shapedetection/DetectedFace.h"
13 #include "modules/shapedetection/FaceDetectorOptions.h" 13 #include "modules/shapedetection/FaceDetectorOptions.h"
14 #include "platform/ServiceConnector.h"
14 #include "public/platform/InterfaceProvider.h" 15 #include "public/platform/InterfaceProvider.h"
15 #include "public/platform/modules/shapedetection/facedetection_provider.mojom-bl ink.h" 16 #include "public/platform/modules/shapedetection/facedetection_provider.mojom-bl ink.h"
17 #include "services/shape_detection/public/interfaces/constants.mojom-blink.h"
16 18
17 namespace blink { 19 namespace blink {
18 20
19 FaceDetector* FaceDetector::create(Document& document, 21 FaceDetector* FaceDetector::create(Document& document,
20 const FaceDetectorOptions& options) { 22 const FaceDetectorOptions& options) {
21 return new FaceDetector(*document.frame(), options); 23 return new FaceDetector(*document.frame(), options);
22 } 24 }
23 25
24 FaceDetector::FaceDetector(LocalFrame& frame, 26 FaceDetector::FaceDetector(LocalFrame& frame,
25 const FaceDetectorOptions& options) 27 const FaceDetectorOptions& options)
26 : ShapeDetector(frame) { 28 : ShapeDetector(frame) {
27 mojom::blink::FaceDetectorOptionsPtr faceDetectorOptions = 29 mojom::blink::FaceDetectorOptionsPtr faceDetectorOptions =
28 mojom::blink::FaceDetectorOptions::New(); 30 mojom::blink::FaceDetectorOptions::New();
29 faceDetectorOptions->max_detected_faces = options.maxDetectedFaces(); 31 faceDetectorOptions->max_detected_faces = options.maxDetectedFaces();
30 faceDetectorOptions->fast_mode = options.fastMode(); 32 faceDetectorOptions->fast_mode = options.fastMode();
31 mojom::blink::FaceDetectionProviderPtr provider; 33 mojom::blink::FaceDetectionProviderPtr provider;
34 #if OS(MACOSX)
35 ServiceConnector::instance().connectToInterface(
36 shape_detection::mojom::blink::kServiceName,
37 mojo::MakeRequest(&provider));
38 #else
39 // TODO(xianglu): Move Android implementation to service/ as well.
32 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&provider)); 40 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&provider));
41 #endif
33 provider->CreateFaceDetection(mojo::MakeRequest(&m_faceService), 42 provider->CreateFaceDetection(mojo::MakeRequest(&m_faceService),
34 std::move(faceDetectorOptions)); 43 std::move(faceDetectorOptions));
35
36 m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind( 44 m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind(
37 &FaceDetector::onFaceServiceConnectionError, wrapWeakPersistent(this)))); 45 &FaceDetector::onFaceServiceConnectionError, wrapWeakPersistent(this))));
38 } 46 }
39 47
40 ScriptPromise FaceDetector::doDetect( 48 ScriptPromise FaceDetector::doDetect(
41 ScriptPromiseResolver* resolver, 49 ScriptPromiseResolver* resolver,
42 mojo::ScopedSharedBufferHandle sharedBufferHandle, 50 mojo::ScopedSharedBufferHandle sharedBufferHandle,
43 int imageWidth, 51 int imageWidth,
44 int imageHeight) { 52 int imageHeight) {
45 ScriptPromise promise = resolver->promise(); 53 ScriptPromise promise = resolver->promise();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 m_faceServiceRequests.clear(); 88 m_faceServiceRequests.clear();
81 m_faceService.reset(); 89 m_faceService.reset();
82 } 90 }
83 91
84 DEFINE_TRACE(FaceDetector) { 92 DEFINE_TRACE(FaceDetector) {
85 ShapeDetector::trace(visitor); 93 ShapeDetector::trace(visitor);
86 visitor->trace(m_faceServiceRequests); 94 visitor->trace(m_faceServiceRequests);
87 } 95 }
88 96
89 } // namespace blink 97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698