| OLD | NEW |
| 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/ShapeDetector.h" | 5 #include "modules/shapedetection/ShapeDetector.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/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/ImageBitmap.h" | 10 #include "core/frame/ImageBitmap.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 const mojo::ScopedSharedBufferMapping mappedBuffer = | 41 const mojo::ScopedSharedBufferMapping mappedBuffer = |
| 42 sharedBufferHandle->Map(size); | 42 sharedBufferHandle->Map(size); |
| 43 DCHECK(mappedBuffer.get()); | 43 DCHECK(mappedBuffer.get()); |
| 44 memcpy(mappedBuffer.get(), data, size); | 44 memcpy(mappedBuffer.get(), data, size); |
| 45 | 45 |
| 46 return sharedBufferHandle; | 46 return sharedBufferHandle; |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // anonymous namespace | 49 } // anonymous namespace |
| 50 | 50 |
| 51 ShapeDetector::ShapeDetector(LocalFrame& frame) { | |
| 52 DCHECK(frame.interfaceProvider()); | |
| 53 } | |
| 54 | |
| 55 ScriptPromise ShapeDetector::detect(ScriptState* scriptState, | 51 ScriptPromise ShapeDetector::detect(ScriptState* scriptState, |
| 56 const ImageBitmapSourceUnion& imageSource) { | 52 const ImageBitmapSourceUnion& imageSource) { |
| 57 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 53 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 58 ScriptPromise promise = resolver->promise(); | 54 ScriptPromise promise = resolver->promise(); |
| 59 | 55 |
| 60 // ImageDatas cannot be tainted by definition. | 56 // ImageDatas cannot be tainted by definition. |
| 61 if (imageSource.isImageData()) | 57 if (imageSource.isImageData()) |
| 62 return detectShapesOnImageData(resolver, imageSource.getAsImageData()); | 58 return detectShapesOnImageData(resolver, imageSource.getAsImageData()); |
| 63 | 59 |
| 64 CanvasImageSource* canvasImageSource; | 60 CanvasImageSource* canvasImageSource; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 InvalidStateError, | 230 InvalidStateError, |
| 235 "Failed to read pixels: Unable to decompress or unsupported format.")); | 231 "Failed to read pixels: Unable to decompress or unsupported format.")); |
| 236 return promise; | 232 return promise; |
| 237 } | 233 } |
| 238 | 234 |
| 239 return doDetect(resolver, std::move(sharedBufferHandle), img->naturalWidth(), | 235 return doDetect(resolver, std::move(sharedBufferHandle), img->naturalWidth(), |
| 240 img->naturalHeight()); | 236 img->naturalHeight()); |
| 241 } | 237 } |
| 242 | 238 |
| 243 } // namespace blink | 239 } // namespace blink |
| OLD | NEW |