| Index: third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
|
| diff --git a/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp b/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
|
| index 037586df0949ead12c479b2844301c681a0e6350..0ce1fcebbd2a767a8b8bd743fa7ae41be89ba01c 100644
|
| --- a/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
|
| +++ b/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
|
| @@ -14,6 +14,8 @@
|
| #include "core/html/HTMLImageElement.h"
|
| #include "core/html/HTMLVideoElement.h"
|
| #include "core/html/canvas/CanvasImageSource.h"
|
| +#include "modules/shapedetection/FaceDetectorImpl.h"
|
| +#include "platform/SharedBuffer.h"
|
| #include "platform/graphics/Image.h"
|
| #include "public/platform/InterfaceProvider.h"
|
| #include "third_party/skia/include/core/SkImage.h"
|
| @@ -67,12 +69,12 @@ ScriptPromise FaceDetector::detect(ScriptState* scriptState,
|
| return promise;
|
| }
|
|
|
| - if (imageSourceInternal->wouldTaintOrigin(
|
| - scriptState->getExecutionContext()->getSecurityOrigin())) {
|
| - resolver->reject(
|
| - DOMException::create(SecurityError, "Source would taint origin."));
|
| - return promise;
|
| - }
|
| + // if (imageSourceInternal->wouldTaintOrigin(
|
| + // scriptState->getExecutionContext()->getSecurityOrigin())) {
|
| + // resolver->reject(
|
| + // DOMException::create(SecurityError, "Source would taint origin."));
|
| + // return promise;
|
| + // }
|
|
|
| if (imageSource.isHTMLImageElement()) {
|
| return detectFacesOnImageElement(
|
| @@ -115,8 +117,6 @@ ScriptPromise FaceDetector::detectFacesOnImageElement(
|
| }
|
|
|
| const sk_sp<SkImage> image = blinkImage->imageForCurrentFrame();
|
| - DCHECK_EQ(img->naturalWidth(), image->width());
|
| - DCHECK_EQ(img->naturalHeight(), image->height());
|
|
|
| if (!image) {
|
| resolver->reject(DOMException::create(
|
| @@ -128,7 +128,6 @@ ScriptPromise FaceDetector::detectFacesOnImageElement(
|
| SkImageInfo::MakeN32(image->width(), image->height(), image->alphaType());
|
|
|
| const uint32_t allocationSize = skiaInfo.getSafeSize(skiaInfo.minRowBytes());
|
| -
|
| mojo::ScopedSharedBufferHandle sharedBufferHandle =
|
| mojo::SharedBufferHandle::Create(allocationSize);
|
| if (!sharedBufferHandle.is_valid()) {
|
| @@ -152,20 +151,12 @@ ScriptPromise FaceDetector::detectFacesOnImageElement(
|
| "Failed to read pixels: Unable to decompress or unsupported format."));
|
| return promise;
|
| }
|
| + DLOG(ERROR) << "pixmap.getSafeSize():" << pixmap.getSafeSize();
|
|
|
| - if (!m_service) {
|
| - resolver->reject(DOMException::create(
|
| - NotSupportedError, "Face detection service unavailable."));
|
| - return promise;
|
| - }
|
| -
|
| - m_serviceRequests.add(resolver);
|
| - DCHECK(m_service.is_bound());
|
| - m_service->DetectFace(std::move(sharedBufferHandle), img->naturalWidth(),
|
| - img->naturalHeight(),
|
| - convertToBaseCallback(WTF::bind(
|
| - &FaceDetector::onDetectFace, wrapPersistent(this),
|
| - wrapPersistent(resolver))));
|
| + FaceDetectorImpl* detector = FaceDetectorImpl::Create();
|
| + HeapVector<Member<DOMRect>> detectedFaces = detector->detectFace(
|
| + pixmap.writable_addr(), img->naturalWidth(), img->naturalHeight());
|
| + resolver->resolve(detectedFaces);
|
| return promise;
|
| }
|
|
|
|
|