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

Side by Side Diff: third_party/WebKit/Source/modules/shapedetection/TextDetector.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
« no previous file with comments | « third_party/WebKit/Source/modules/shapedetection/TextDetector.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/TextDetector.h" 5 #include "modules/shapedetection/TextDetector.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/shapedetection/DetectedText.h" 10 #include "modules/shapedetection/DetectedText.h"
11 #include "public/platform/InterfaceProvider.h" 11 #include "public/platform/InterfaceProvider.h"
12 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 TextDetector* TextDetector::Create() { 16 TextDetector* TextDetector::Create() {
17 return new TextDetector(); 17 return new TextDetector();
18 } 18 }
19 19
20 TextDetector::TextDetector() : ShapeDetector() { 20 TextDetector::TextDetector() : ShapeDetector() {
21 Platform::Current()->GetInterfaceProvider()->GetInterface( 21 Platform::Current()->GetInterfaceProvider()->GetInterface(
22 mojo::MakeRequest(&text_service_)); 22 mojo::MakeRequest(&text_service_));
23 text_service_.set_connection_error_handler(ConvertToBaseCallback(WTF::Bind( 23 text_service_.set_connection_error_handler(ConvertToBaseCallback(WTF::Bind(
24 &TextDetector::OnTextServiceConnectionError, WrapWeakPersistent(this)))); 24 &TextDetector::OnTextServiceConnectionError, WrapWeakPersistent(this))));
25 } 25 }
26 26
27 ScriptPromise TextDetector::DoDetect( 27 ScriptPromise TextDetector::DoDetect(ScriptPromiseResolver* resolver,
28 ScriptPromiseResolver* resolver, 28 skia::mojom::blink::BitmapPtr bitmap) {
29 mojo::ScopedSharedBufferHandle shared_buffer_handle,
30 int image_width,
31 int image_height) {
32 ScriptPromise promise = resolver->Promise(); 29 ScriptPromise promise = resolver->Promise();
33 if (!text_service_) { 30 if (!text_service_) {
34 resolver->Reject(DOMException::Create( 31 resolver->Reject(DOMException::Create(
35 kNotSupportedError, "Text detection service unavailable.")); 32 kNotSupportedError, "Text detection service unavailable."));
36 return promise; 33 return promise;
37 } 34 }
38 text_service_requests_.insert(resolver); 35 text_service_requests_.insert(resolver);
39 text_service_->Detect(std::move(shared_buffer_handle), image_width, 36 text_service_->Detect(std::move(bitmap),
40 image_height,
41 ConvertToBaseCallback(WTF::Bind( 37 ConvertToBaseCallback(WTF::Bind(
42 &TextDetector::OnDetectText, WrapPersistent(this), 38 &TextDetector::OnDetectText, WrapPersistent(this),
43 WrapPersistent(resolver)))); 39 WrapPersistent(resolver))));
44 return promise; 40 return promise;
45 } 41 }
46 42
47 void TextDetector::OnDetectText( 43 void TextDetector::OnDetectText(
48 ScriptPromiseResolver* resolver, 44 ScriptPromiseResolver* resolver,
49 Vector<shape_detection::mojom::blink::TextDetectionResultPtr> 45 Vector<shape_detection::mojom::blink::TextDetectionResultPtr>
50 text_detection_results) { 46 text_detection_results) {
(...skipping 20 matching lines...) Expand all
71 text_service_requests_.clear(); 67 text_service_requests_.clear();
72 text_service_.reset(); 68 text_service_.reset();
73 } 69 }
74 70
75 DEFINE_TRACE(TextDetector) { 71 DEFINE_TRACE(TextDetector) {
76 ShapeDetector::Trace(visitor); 72 ShapeDetector::Trace(visitor);
77 visitor->Trace(text_service_requests_); 73 visitor->Trace(text_service_requests_);
78 } 74 }
79 75
80 } // namespace blink 76 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/shapedetection/TextDetector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698