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

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/resources/mock-textdetection.js

Issue 2755393002: Revert of RELAND: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: Created 3 years, 9 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 "use strict"; 1 "use strict";
2 2
3 let mockTextDetectionReady = define( 3 let mockTextDetectionReady = define(
4 'mockTextDetection', 4 'mockTextDetection',
5 ['services/shape_detection/public/interfaces/textdetection.mojom', 5 ['services/shape_detection/public/interfaces/textdetection.mojom',
6 'mojo/public/js/bindings', 6 'mojo/public/js/bindings',
7 'mojo/public/js/core', 7 'mojo/public/js/core',
8 'content/public/renderer/interfaces', 8 'content/public/renderer/interfaces',
9 ], (textDetection, bindings, mojo, interfaces) => { 9 ], (textDetection, bindings, mojo, interfaces) => {
10 10
11 class MockTextDetection { 11 class MockTextDetection {
12 constructor() { 12 constructor() {
13 this.bindingSet_ = new bindings.BindingSet(textDetection.TextDetection); 13 this.bindingSet_ = new bindings.BindingSet(textDetection.TextDetection);
14 14
15 interfaces.addInterfaceOverrideForTesting( 15 interfaces.addInterfaceOverrideForTesting(
16 textDetection.TextDetection.name, 16 textDetection.TextDetection.name,
17 handle => this.bindingSet_.addBinding(this, handle)); 17 handle => this.bindingSet_.addBinding(this, handle));
18 } 18 }
19 19
20 detect(bitmap_data) { 20 detect(frame_data, width, height) {
21 let receivedStruct = new Uint8Array(bitmap_data.pixel_data); 21 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
22 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); 22 this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
23 return Promise.resolve({ 23 return Promise.resolve({
24 results: [ 24 results: [
25 { 25 {
26 raw_value : "cats", 26 raw_value : "cats",
27 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 } 27 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 }
28 }, 28 },
29 { 29 {
30 raw_value : "dogs", 30 raw_value : "dogs",
31 bounding_box: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 } 31 bounding_box: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 }
32 }, 32 },
33 ], 33 ],
34 }); 34 });
35 mojo.unmapBuffer(receivedStruct.buffer);
35 } 36 }
36 37
37 getFrameData() { 38 getFrameData() {
38 return this.buffer_data_; 39 return this.buffer_data_;
39 } 40 }
40 } 41 }
41 return new MockTextDetection(); 42 return new MockTextDetection();
42 }); 43 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698