| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ShapeDetector_h |
| 6 #define ShapeDetector_h |
| 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "modules/ModulesExport.h" |
| 11 #include "modules/canvas2d/CanvasRenderingContext2D.h" |
| 12 #include "public/platform/modules/shapedetection/shapedetection.mojom-blink.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class LocalFrame; |
| 17 |
| 18 class MODULES_EXPORT ShapeDetector |
| 19 : public GarbageCollectedFinalized<ShapeDetector> { |
| 20 public: |
| 21 enum class DetectorType { |
| 22 Face, |
| 23 Barcode |
| 24 // TODO(mcasas): Implement TextDetector after |
| 25 // https://github.com/WICG/shape-detection-api/issues/6 |
| 26 }; |
| 27 explicit ShapeDetector(LocalFrame&); |
| 28 virtual ~ShapeDetector() = default; |
| 29 |
| 30 ScriptPromise detectShapes(ScriptState*, |
| 31 DetectorType, |
| 32 const CanvasImageSourceUnion&); |
| 33 DECLARE_VIRTUAL_TRACE(); |
| 34 |
| 35 private: |
| 36 ScriptPromise detectShapesOnImageElement(DetectorType, |
| 37 ScriptPromiseResolver*, |
| 38 const HTMLImageElement*); |
| 39 ScriptPromise detectShapesOnImageBitmap(DetectorType, |
| 40 ScriptPromiseResolver*, |
| 41 ImageBitmap*); |
| 42 ScriptPromise detectShapesOnVideoElement(DetectorType, |
| 43 ScriptPromiseResolver*, |
| 44 const HTMLVideoElement*); |
| 45 |
| 46 ScriptPromise detectShapesOnData(DetectorType, |
| 47 ScriptPromiseResolver*, |
| 48 uint8_t* data, |
| 49 int size, |
| 50 int width, |
| 51 int height); |
| 52 void onDetectFaces(ScriptPromiseResolver*, |
| 53 mojom::blink::FaceDetectionResultPtr); |
| 54 void onDetectBarcodes(ScriptPromiseResolver*, |
| 55 Vector<mojom::blink::BarcodeDetectionResultPtr>); |
| 56 |
| 57 mojom::blink::ShapeDetectionPtr m_service; |
| 58 |
| 59 HeapHashSet<Member<ScriptPromiseResolver>> m_serviceRequests; |
| 60 }; |
| 61 |
| 62 } // namespace blink |
| 63 |
| 64 #endif // ShapeDetector_h |
| OLD | NEW |