| OLD | NEW |
| 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/LocalFrame.h" | |
| 10 #include "core/html/canvas/CanvasImageSource.h" | 9 #include "core/html/canvas/CanvasImageSource.h" |
| 11 #include "modules/shapedetection/DetectedFace.h" | 10 #include "modules/shapedetection/DetectedFace.h" |
| 12 #include "modules/shapedetection/FaceDetectorOptions.h" | 11 #include "modules/shapedetection/FaceDetectorOptions.h" |
| 13 #include "public/platform/InterfaceProvider.h" | 12 #include "public/platform/InterfaceProvider.h" |
| 13 #include "public/platform/Platform.h" |
| 14 #include "services/shape_detection/public/interfaces/facedetection_provider.mojo
m-blink.h" | 14 #include "services/shape_detection/public/interfaces/facedetection_provider.mojo
m-blink.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 FaceDetector* FaceDetector::create(Document& document, | 18 FaceDetector* FaceDetector::create(const FaceDetectorOptions& options) { |
| 19 const FaceDetectorOptions& options) { | 19 return new FaceDetector(options); |
| 20 return new FaceDetector(*document.frame(), options); | |
| 21 } | 20 } |
| 22 | 21 |
| 23 FaceDetector::FaceDetector(LocalFrame& frame, | 22 FaceDetector::FaceDetector(const FaceDetectorOptions& options) |
| 24 const FaceDetectorOptions& options) | 23 : ShapeDetector() { |
| 25 : ShapeDetector(frame) { | |
| 26 shape_detection::mojom::blink::FaceDetectorOptionsPtr faceDetectorOptions = | 24 shape_detection::mojom::blink::FaceDetectorOptionsPtr faceDetectorOptions = |
| 27 shape_detection::mojom::blink::FaceDetectorOptions::New(); | 25 shape_detection::mojom::blink::FaceDetectorOptions::New(); |
| 28 faceDetectorOptions->max_detected_faces = options.maxDetectedFaces(); | 26 faceDetectorOptions->max_detected_faces = options.maxDetectedFaces(); |
| 29 faceDetectorOptions->fast_mode = options.fastMode(); | 27 faceDetectorOptions->fast_mode = options.fastMode(); |
| 30 shape_detection::mojom::blink::FaceDetectionProviderPtr provider; | 28 shape_detection::mojom::blink::FaceDetectionProviderPtr provider; |
| 31 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&provider)); | 29 Platform::current()->interfaceProvider()->getInterface( |
| 30 mojo::MakeRequest(&provider)); |
| 32 provider->CreateFaceDetection(mojo::MakeRequest(&m_faceService), | 31 provider->CreateFaceDetection(mojo::MakeRequest(&m_faceService), |
| 33 std::move(faceDetectorOptions)); | 32 std::move(faceDetectorOptions)); |
| 34 | 33 |
| 35 m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind( | 34 m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind( |
| 36 &FaceDetector::onFaceServiceConnectionError, wrapWeakPersistent(this)))); | 35 &FaceDetector::onFaceServiceConnectionError, wrapWeakPersistent(this)))); |
| 37 } | 36 } |
| 38 | 37 |
| 39 ScriptPromise FaceDetector::doDetect( | 38 ScriptPromise FaceDetector::doDetect( |
| 40 ScriptPromiseResolver* resolver, | 39 ScriptPromiseResolver* resolver, |
| 41 mojo::ScopedSharedBufferHandle sharedBufferHandle, | 40 mojo::ScopedSharedBufferHandle sharedBufferHandle, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 m_faceServiceRequests.clear(); | 78 m_faceServiceRequests.clear(); |
| 80 m_faceService.reset(); | 79 m_faceService.reset(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 DEFINE_TRACE(FaceDetector) { | 82 DEFINE_TRACE(FaceDetector) { |
| 84 ShapeDetector::trace(visitor); | 83 ShapeDetector::trace(visitor); |
| 85 visitor->trace(m_faceServiceRequests); | 84 visitor->trace(m_faceServiceRequests); |
| 86 } | 85 } |
| 87 | 86 |
| 88 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |