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

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

Issue 2629433003: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: ShapeDetection: use mojom::Bitmap for mojo interface. Created 3 years, 11 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/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/html/canvas/CanvasImageSource.h" 10 #include "core/html/canvas/CanvasImageSource.h"
(...skipping 18 matching lines...) Expand all
29 faceDetectorOptions->fast_mode = options.fastMode(); 29 faceDetectorOptions->fast_mode = options.fastMode();
30 shape_detection::mojom::blink::FaceDetectionProviderPtr provider; 30 shape_detection::mojom::blink::FaceDetectionProviderPtr provider;
31 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&provider)); 31 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&provider));
32 provider->CreateFaceDetection(mojo::MakeRequest(&m_faceService), 32 provider->CreateFaceDetection(mojo::MakeRequest(&m_faceService),
33 std::move(faceDetectorOptions)); 33 std::move(faceDetectorOptions));
34 34
35 m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind( 35 m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind(
36 &FaceDetector::onFaceServiceConnectionError, wrapWeakPersistent(this)))); 36 &FaceDetector::onFaceServiceConnectionError, wrapWeakPersistent(this))));
37 } 37 }
38 38
39 ScriptPromise FaceDetector::doDetect( 39 ScriptPromise FaceDetector::doDetect(ScriptPromiseResolver* resolver,
40 ScriptPromiseResolver* resolver, 40 skia::mojom::blink::BitmapPtr bitmap) {
41 mojo::ScopedSharedBufferHandle sharedBufferHandle,
42 int imageWidth,
43 int imageHeight) {
44 ScriptPromise promise = resolver->promise(); 41 ScriptPromise promise = resolver->promise();
45 if (!m_faceService) { 42 if (!m_faceService) {
46 resolver->reject(DOMException::create( 43 resolver->reject(DOMException::create(
47 NotSupportedError, "Face detection service unavailable.")); 44 NotSupportedError, "Face detection service unavailable."));
48 return promise; 45 return promise;
49 } 46 }
50 m_faceServiceRequests.add(resolver); 47 m_faceServiceRequests.add(resolver);
51 m_faceService->Detect(std::move(sharedBufferHandle), imageWidth, imageHeight, 48 m_faceService->Detect(std::move(bitmap),
52 convertToBaseCallback(WTF::bind( 49 convertToBaseCallback(WTF::bind(
53 &FaceDetector::onDetectFaces, wrapPersistent(this), 50 &FaceDetector::onDetectFaces, wrapPersistent(this),
54 wrapPersistent(resolver)))); 51 wrapPersistent(resolver))));
55 return promise; 52 return promise;
56 } 53 }
57 54
58 void FaceDetector::onDetectFaces( 55 void FaceDetector::onDetectFaces(
59 ScriptPromiseResolver* resolver, 56 ScriptPromiseResolver* resolver,
60 shape_detection::mojom::blink::FaceDetectionResultPtr faceDetectionResult) { 57 shape_detection::mojom::blink::FaceDetectionResultPtr faceDetectionResult) {
61 DCHECK(m_faceServiceRequests.contains(resolver)); 58 DCHECK(m_faceServiceRequests.contains(resolver));
(...skipping 17 matching lines...) Expand all
79 m_faceServiceRequests.clear(); 76 m_faceServiceRequests.clear();
80 m_faceService.reset(); 77 m_faceService.reset();
81 } 78 }
82 79
83 DEFINE_TRACE(FaceDetector) { 80 DEFINE_TRACE(FaceDetector) {
84 ShapeDetector::trace(visitor); 81 ShapeDetector::trace(visitor);
85 visitor->trace(m_faceServiceRequests); 82 visitor->trace(m_faceServiceRequests);
86 } 83 }
87 84
88 } // namespace blink 85 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698