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

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

Issue 2875243002: RELAND: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: RELAND2: ShapeDetection: use mojom::Bitmap for mojo interface. Created 3 years, 6 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/geometry/DOMRect.h" 8 #include "core/geometry/DOMRect.h"
9 #include "core/html/canvas/CanvasImageSource.h" 9 #include "core/html/canvas/CanvasImageSource.h"
10 #include "modules/imagecapture/Point2D.h" 10 #include "modules/imagecapture/Point2D.h"
(...skipping 19 matching lines...) Expand all
30 shape_detection::mojom::blink::FaceDetectionProviderPtr provider; 30 shape_detection::mojom::blink::FaceDetectionProviderPtr provider;
31 Platform::Current()->GetInterfaceProvider()->GetInterface( 31 Platform::Current()->GetInterfaceProvider()->GetInterface(
32 mojo::MakeRequest(&provider)); 32 mojo::MakeRequest(&provider));
33 provider->CreateFaceDetection(mojo::MakeRequest(&face_service_), 33 provider->CreateFaceDetection(mojo::MakeRequest(&face_service_),
34 std::move(face_detector_options)); 34 std::move(face_detector_options));
35 35
36 face_service_.set_connection_error_handler(ConvertToBaseCallback(WTF::Bind( 36 face_service_.set_connection_error_handler(ConvertToBaseCallback(WTF::Bind(
37 &FaceDetector::OnFaceServiceConnectionError, WrapWeakPersistent(this)))); 37 &FaceDetector::OnFaceServiceConnectionError, WrapWeakPersistent(this))));
38 } 38 }
39 39
40 ScriptPromise FaceDetector::DoDetect( 40 ScriptPromise FaceDetector::DoDetect(ScriptPromiseResolver* resolver,
41 ScriptPromiseResolver* resolver, 41 skia::mojom::blink::BitmapPtr bitmap) {
42 mojo::ScopedSharedBufferHandle shared_buffer_handle,
43 int image_width,
44 int image_height) {
45 ScriptPromise promise = resolver->Promise(); 42 ScriptPromise promise = resolver->Promise();
46 if (!face_service_) { 43 if (!face_service_) {
47 resolver->Reject(DOMException::Create( 44 resolver->Reject(DOMException::Create(
48 kNotSupportedError, "Face detection service unavailable.")); 45 kNotSupportedError, "Face detection service unavailable."));
49 return promise; 46 return promise;
50 } 47 }
51 face_service_requests_.insert(resolver); 48 face_service_requests_.insert(resolver);
52 face_service_->Detect(std::move(shared_buffer_handle), image_width, 49 face_service_->Detect(std::move(bitmap),
53 image_height,
54 ConvertToBaseCallback(WTF::Bind( 50 ConvertToBaseCallback(WTF::Bind(
55 &FaceDetector::OnDetectFaces, WrapPersistent(this), 51 &FaceDetector::OnDetectFaces, WrapPersistent(this),
56 WrapPersistent(resolver)))); 52 WrapPersistent(resolver))));
57 return promise; 53 return promise;
58 } 54 }
59 55
60 void FaceDetector::OnDetectFaces( 56 void FaceDetector::OnDetectFaces(
61 ScriptPromiseResolver* resolver, 57 ScriptPromiseResolver* resolver,
62 Vector<shape_detection::mojom::blink::FaceDetectionResultPtr> 58 Vector<shape_detection::mojom::blink::FaceDetectionResultPtr>
63 face_detection_results) { 59 face_detection_results) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 face_service_requests_.clear(); 95 face_service_requests_.clear();
100 face_service_.reset(); 96 face_service_.reset();
101 } 97 }
102 98
103 DEFINE_TRACE(FaceDetector) { 99 DEFINE_TRACE(FaceDetector) {
104 ShapeDetector::Trace(visitor); 100 ShapeDetector::Trace(visitor);
105 visitor->Trace(face_service_requests_); 101 visitor->Trace(face_service_requests_);
106 } 102 }
107 103
108 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698