| OLD | NEW |
| 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 "services/shape_detection/barcode_detection_impl_mac.h" | 5 #include "services/shape_detection/barcode_detection_impl_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
| 9 #include "base/mac/sdk_forward_declarations.h" | 9 #include "base/mac/sdk_forward_declarations.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 void BarcodeDetectionImpl::Create( | 35 void BarcodeDetectionImpl::Create( |
| 36 shape_detection::mojom::BarcodeDetectionRequest request) { | 36 shape_detection::mojom::BarcodeDetectionRequest request) { |
| 37 // Barcode detection needs at least MAC OS X 10.10. | 37 // Barcode detection needs at least MAC OS X 10.10. |
| 38 if (!base::mac::IsAtLeastOS10_10()) | 38 if (!base::mac::IsAtLeastOS10_10()) |
| 39 return; | 39 return; |
| 40 mojo::MakeStrongBinding(base::MakeUnique<BarcodeDetectionImplMac>(), | 40 mojo::MakeStrongBinding(base::MakeUnique<BarcodeDetectionImplMac>(), |
| 41 std::move(request)); | 41 std::move(request)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 BarcodeDetectionImplMac::BarcodeDetectionImplMac() { | 44 BarcodeDetectionImplMac::BarcodeDetectionImplMac() { |
| 45 NSDictionary* const opts = @{CIDetectorAccuracy : CIDetectorAccuracyHigh}; | 45 NSDictionary* const options = @{CIDetectorAccuracy : CIDetectorAccuracyHigh}; |
| 46 detector_.reset([[CIDetector detectorOfType:CIDetectorTypeQRCode | 46 detector_.reset([[CIDetector detectorOfType:CIDetectorTypeQRCode |
| 47 context:nil | 47 context:nil |
| 48 options:opts] retain]); | 48 options:options] retain]); |
| 49 } | 49 } |
| 50 | 50 |
| 51 BarcodeDetectionImplMac::~BarcodeDetectionImplMac() {} | 51 BarcodeDetectionImplMac::~BarcodeDetectionImplMac() {} |
| 52 | 52 |
| 53 void BarcodeDetectionImplMac::Detect(mojo::ScopedSharedBufferHandle frame_data, | 53 void BarcodeDetectionImplMac::Detect(mojo::ScopedSharedBufferHandle frame_data, |
| 54 uint32_t width, | 54 uint32_t width, |
| 55 uint32_t height, | 55 uint32_t height, |
| 56 const DetectCallback& callback) { | 56 const DetectCallback& callback) { |
| 57 media::ScopedResultCallback<DetectCallback> scoped_callback( | 57 media::ScopedResultCallback<DetectCallback> scoped_callback( |
| 58 base::Bind(&RunCallbackWithBarcodes, callback), | 58 base::Bind(&RunCallbackWithBarcodes, callback), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 85 height - f.bottomRight.y); | 85 height - f.bottomRight.y); |
| 86 result->corner_points.emplace_back(f.bottomLeft.x, height - f.bottomLeft.y); | 86 result->corner_points.emplace_back(f.bottomLeft.x, height - f.bottomLeft.y); |
| 87 | 87 |
| 88 result->raw_value = base::SysNSStringToUTF8(f.messageString); | 88 result->raw_value = base::SysNSStringToUTF8(f.messageString); |
| 89 results.push_back(std::move(result)); | 89 results.push_back(std::move(result)); |
| 90 } | 90 } |
| 91 scoped_callback.Run(std::move(results)); | 91 scoped_callback.Run(std::move(results)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace shape_detection | 94 } // namespace shape_detection |
| OLD | NEW |