Commit a94dd8da authored by Robert Sesek's avatar Robert Sesek Committed by Chromium LUCI CQ

mac: Remove code to support OS X 10.10 in //services/shape_detection

Bug: 1153883
Change-Id: Ic1e2dc39b96c2c5ed1e80c4732e1a2dcee02b675
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2571801Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833422}
parent 08e07eab
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace shape_detection { namespace shape_detection {
class API_AVAILABLE(macosx(10.10)) BarcodeDetectionImplMac class BarcodeDetectionImplMac
: public shape_detection::mojom::BarcodeDetection { : public shape_detection::mojom::BarcodeDetection {
public: public:
BarcodeDetectionImplMac(); BarcodeDetectionImplMac();
......
...@@ -120,11 +120,6 @@ TEST_P(BarcodeDetectionImplMacTest, ScanOneBarcode) { ...@@ -120,11 +120,6 @@ TEST_P(BarcodeDetectionImplMacTest, ScanOneBarcode) {
} }
impl_ = GetParam().factory.Run(mojom::BarcodeDetectorOptions::New()); impl_ = GetParam().factory.Run(mojom::BarcodeDetectorOptions::New());
if (!impl_) {
LOG(WARNING) << "Barcode Detection is not supported before Mac OSX 10.10."
<< "Skipping test.";
return;
}
// Generate a barcode image as a CIImage by using |qr_code_generator|. // Generate a barcode image as a CIImage by using |qr_code_generator|.
NSData* const qr_code_data = NSData* const qr_code_data =
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "services/shape_detection/text_detection_impl_mac.h" #include "services/shape_detection/text_detection_impl_mac.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
...@@ -17,11 +16,8 @@ namespace shape_detection { ...@@ -17,11 +16,8 @@ namespace shape_detection {
// static // static
void TextDetectionImpl::Create( void TextDetectionImpl::Create(
mojo::PendingReceiver<mojom::TextDetection> receiver) { mojo::PendingReceiver<mojom::TextDetection> receiver) {
// Text detection needs at least MAC OS X 10.11. mojo::MakeSelfOwnedReceiver(std::make_unique<TextDetectionImplMac>(),
if (@available(macOS 10.11, *)) { std::move(receiver));
mojo::MakeSelfOwnedReceiver(std::make_unique<TextDetectionImplMac>(),
std::move(receiver));
}
} }
TextDetectionImplMac::TextDetectionImplMac() { TextDetectionImplMac::TextDetectionImplMac() {
...@@ -35,8 +31,6 @@ TextDetectionImplMac::~TextDetectionImplMac() {} ...@@ -35,8 +31,6 @@ TextDetectionImplMac::~TextDetectionImplMac() {}
void TextDetectionImplMac::Detect(const SkBitmap& bitmap, void TextDetectionImplMac::Detect(const SkBitmap& bitmap,
DetectCallback callback) { DetectCallback callback) {
DCHECK(base::mac::IsAtLeastOS10_11());
base::scoped_nsobject<CIImage> ci_image = CreateCIImageFromSkBitmap(bitmap); base::scoped_nsobject<CIImage> ci_image = CreateCIImageFromSkBitmap(bitmap);
if (!ci_image) { if (!ci_image) {
std::move(callback).Run({}); std::move(callback).Run({});
......
...@@ -41,64 +41,61 @@ TEST_F(TextDetectionImplMacTest, CreateAndDestroy) {} ...@@ -41,64 +41,61 @@ TEST_F(TextDetectionImplMacTest, CreateAndDestroy) {}
// This test generates an image with a single text line and scans it back. // This test generates an image with a single text line and scans it back.
TEST_F(TextDetectionImplMacTest, ScanOnce) { TEST_F(TextDetectionImplMacTest, ScanOnce) {
// Text detection needs at least MAC OS X 10.11, and GPU infrastructure. // Text detection needs GPU infrastructure.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch( if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseGpuInTests) || switches::kUseGpuInTests)) {
!base::mac::IsAtLeastOS10_11()) {
return; return;
} }
if (@available(macOS 10.11, *)) { impl_.reset(new TextDetectionImplMac);
impl_.reset(new TextDetectionImplMac); base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace(
base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace( CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
const int width = 200;
const int width = 200; const int height = 50;
const int height = 50; base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate(
base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate( nullptr, width, height, 8 /* bitsPerComponent */,
nullptr, width, height, 8 /* bitsPerComponent */, width * 4 /* rowBytes */, rgb_colorspace,
width * 4 /* rowBytes */, rgb_colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
// Draw a white background.
// Draw a white background. CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); CGContextFillRect(context, CGRectMake(0.0, 0.0, width, height));
CGContextFillRect(context, CGRectMake(0.0, 0.0, width, height));
// Create a line of Helvetica 16 text, and draw it in the |context|.
// Create a line of Helvetica 16 text, and draw it in the |context|. base::scoped_nsobject<NSFont> helvetica([NSFont fontWithName:@"Helvetica"
base::scoped_nsobject<NSFont> helvetica( size:16]);
[NSFont fontWithName:@"Helvetica" size:16]); NSDictionary* attributes = [NSDictionary
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:helvetica, kCTFontAttributeName, nil];
dictionaryWithObjectsAndKeys:helvetica, kCTFontAttributeName, nil];
base::scoped_nsobject<NSAttributedString> info([[NSAttributedString alloc]
base::scoped_nsobject<NSAttributedString> info([[NSAttributedString alloc] initWithString:@"https://www.chromium.org"
initWithString:@"https://www.chromium.org" attributes:attributes]);
attributes:attributes]);
base::ScopedCFTypeRef<CTLineRef> line(
base::ScopedCFTypeRef<CTLineRef> line( CTLineCreateWithAttributedString((CFAttributedStringRef)info.get()));
CTLineCreateWithAttributedString((CFAttributedStringRef)info.get()));
CGContextSetTextPosition(context, 10.0, height / 2.0);
CGContextSetTextPosition(context, 10.0, height / 2.0); CTLineDraw(line, context);
CTLineDraw(line, context);
// Extract a CGImage and its raw pixels from |context|.
// Extract a CGImage and its raw pixels from |context|. base::ScopedCFTypeRef<CGImageRef> cg_image(
base::ScopedCFTypeRef<CGImageRef> cg_image( CGBitmapContextCreateImage(context));
CGBitmapContextCreateImage(context)); EXPECT_EQ(static_cast<size_t>(width), CGImageGetWidth(cg_image));
EXPECT_EQ(static_cast<size_t>(width), CGImageGetWidth(cg_image)); EXPECT_EQ(static_cast<size_t>(height), CGImageGetHeight(cg_image));
EXPECT_EQ(static_cast<size_t>(height), CGImageGetHeight(cg_image));
SkBitmap bitmap;
SkBitmap bitmap; ASSERT_TRUE(SkCreateBitmapFromCGImage(&bitmap, cg_image));
ASSERT_TRUE(SkCreateBitmapFromCGImage(&bitmap, cg_image));
base::RunLoop run_loop;
base::RunLoop run_loop; // Send the image to Detect() and expect the response in callback.
// Send the image to Detect() and expect the response in callback. EXPECT_CALL(*this, Detection(1))
EXPECT_CALL(*this, Detection(1)) .WillOnce(RunOnceClosure(run_loop.QuitClosure()));
.WillOnce(RunOnceClosure(run_loop.QuitClosure())); impl_->Detect(bitmap,
impl_->Detect(bitmap, base::BindOnce(&TextDetectionImplMacTest::DetectCallback,
base::BindOnce(&TextDetectionImplMacTest::DetectCallback, base::Unretained(this)));
base::Unretained(this)));
run_loop.Run();
run_loop.Run();
}
} }
} // shape_detection namespace } // shape_detection namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment