| Index: ui/snapshot/snapshot_mac.mm
|
| diff --git a/ui/snapshot/snapshot_mac.mm b/ui/snapshot/snapshot_mac.mm
|
| index 9761cb7f5086136f36de50109e04e7e0e92222eb..41b67860dc5b45a8aa44f228e496f1e00aea07a2 100644
|
| --- a/ui/snapshot/snapshot_mac.mm
|
| +++ b/ui/snapshot/snapshot_mac.mm
|
| @@ -9,7 +9,6 @@
|
| #include "base/callback.h"
|
| #include "base/logging.h"
|
| #include "base/mac/scoped_cftyperef.h"
|
| -#include "base/mac/scoped_nsobject.h"
|
| #include "base/mac/sdk_forward_declarations.h"
|
| #include "base/task_runner.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| @@ -18,7 +17,7 @@
|
| namespace ui {
|
|
|
| bool GrabViewSnapshot(gfx::NativeView view,
|
| - std::vector<unsigned char>* png_representation,
|
| + gfx::Image* image,
|
| const gfx::Rect& snapshot_bounds) {
|
| NSWindow* window = [view window];
|
| NSScreen* screen = [[NSScreen screens] firstObject];
|
| @@ -43,8 +42,6 @@ bool GrabViewSnapshot(gfx::NativeView view,
|
| DCHECK_LE(screen_snapshot_bounds.right(), view_bounds.right());
|
| DCHECK_LE(screen_snapshot_bounds.bottom(), view_bounds.bottom());
|
|
|
| - png_representation->clear();
|
| -
|
| base::ScopedCFTypeRef<CGImageRef> windowSnapshot(
|
| CGWindowListCreateImage(screen_snapshot_bounds.ToCGRect(),
|
| kCGWindowListOptionIncludingWindow,
|
| @@ -53,27 +50,19 @@ bool GrabViewSnapshot(gfx::NativeView view,
|
| if (CGImageGetWidth(windowSnapshot) <= 0)
|
| return false;
|
|
|
| - base::scoped_nsobject<NSBitmapImageRep> rep(
|
| - [[NSBitmapImageRep alloc] initWithCGImage:windowSnapshot]);
|
| - NSData* data = [rep representationUsingType:NSPNGFileType properties:@{}];
|
| - const unsigned char* buf = static_cast<const unsigned char*>([data bytes]);
|
| - NSUInteger length = [data length];
|
| - if (buf == NULL || length == 0)
|
| - return false;
|
| -
|
| - png_representation->assign(buf, buf + length);
|
| - DCHECK(!png_representation->empty());
|
| -
|
| + NSImage* nsImage =
|
| + [[NSImage alloc] initWithCGImage:windowSnapshot size:NSZeroSize];
|
| + *image = gfx::Image(nsImage);
|
| return true;
|
| }
|
|
|
| bool GrabWindowSnapshot(gfx::NativeWindow window,
|
| - std::vector<unsigned char>* png_representation,
|
| + gfx::Image* image,
|
| const gfx::Rect& snapshot_bounds) {
|
| // Make sure to grab the "window frame" view so we get current tab +
|
| // tabstrip.
|
| - return GrabViewSnapshot([[window contentView] superview], png_representation,
|
| - snapshot_bounds);
|
| + return GrabViewSnapshot([[window contentView] superview], image,
|
| + snapshot_bounds);
|
| }
|
|
|
| void GrabWindowSnapshotAndScaleAsync(
|
| @@ -85,21 +74,17 @@ void GrabWindowSnapshotAndScaleAsync(
|
| callback.Run(gfx::Image());
|
| }
|
|
|
| -void GrabViewSnapshotAsync(
|
| - gfx::NativeView view,
|
| - const gfx::Rect& source_rect,
|
| - scoped_refptr<base::TaskRunner> background_task_runner,
|
| - const GrabWindowSnapshotAsyncPNGCallback& callback) {
|
| - callback.Run(scoped_refptr<base::RefCountedBytes>());
|
| +void GrabViewSnapshotAsync(gfx::NativeView view,
|
| + const gfx::Rect& source_rect,
|
| + const GrabWindowSnapshotAsyncCallback& callback) {
|
| + callback.Run(gfx::Image());
|
| }
|
|
|
| -void GrabWindowSnapshotAsync(
|
| - gfx::NativeWindow window,
|
| - const gfx::Rect& source_rect,
|
| - scoped_refptr<base::TaskRunner> background_task_runner,
|
| - const GrabWindowSnapshotAsyncPNGCallback& callback) {
|
| +void GrabWindowSnapshotAsync(gfx::NativeWindow window,
|
| + const gfx::Rect& source_rect,
|
| + const GrabWindowSnapshotAsyncCallback& callback) {
|
| return GrabViewSnapshotAsync([[window contentView] superview], source_rect,
|
| - background_task_runner, callback);
|
| + callback);
|
| }
|
|
|
| } // namespace ui
|
|
|