Remove GrabViewSnapshot
It's sync, and all callers were removed in the previous CLs in the
series.
Fixed: 1517390
Cq-Include-Trybots: luci.chromium.try:ios-blink-dbg-fyi
Change-Id: I6bdbf2c4d6f677976907bd2a45748def22dad218
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5189269
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1248329}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d0c7e0f55e
commit
074ade751f
@ -24,11 +24,6 @@ class Size;
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
// DEPRECATED! Use the async calls below. https://crbug.com/1517390
|
|
||||||
SNAPSHOT_EXPORT bool GrabViewSnapshot(gfx::NativeView view,
|
|
||||||
const gfx::Rect& snapshot_bounds,
|
|
||||||
gfx::Image* image);
|
|
||||||
|
|
||||||
using GrabSnapshotImageCallback = base::OnceCallback<void(gfx::Image snapshot)>;
|
using GrabSnapshotImageCallback = base::OnceCallback<void(gfx::Image snapshot)>;
|
||||||
using GrabSnapshotDataCallback =
|
using GrabSnapshotDataCallback =
|
||||||
base::OnceCallback<void(scoped_refptr<base::RefCountedMemory> data)>;
|
base::OnceCallback<void(scoped_refptr<base::RefCountedMemory> data)>;
|
||||||
|
@ -20,14 +20,6 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
// Sync versions are not supported in Android. Callers should fall back
|
|
||||||
// to the async version.
|
|
||||||
bool GrabViewSnapshot(gfx::NativeView view,
|
|
||||||
const gfx::Rect& snapshot_bounds,
|
|
||||||
gfx::Image* image) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::unique_ptr<viz::CopyOutputRequest> CreateCopyRequest(
|
static std::unique_ptr<viz::CopyOutputRequest> CreateCopyRequest(
|
||||||
gfx::NativeView view,
|
gfx::NativeView view,
|
||||||
const gfx::Rect& source_rect,
|
const gfx::Rect& source_rect,
|
||||||
|
@ -102,13 +102,6 @@ void GrabWindowSnapshotAsyncAura(aura::Window* window,
|
|||||||
|
|
||||||
#if !BUILDFLAG(IS_WIN)
|
#if !BUILDFLAG(IS_WIN)
|
||||||
|
|
||||||
bool GrabViewSnapshot(gfx::NativeView view,
|
|
||||||
const gfx::Rect& snapshot_bounds,
|
|
||||||
gfx::Image* image) {
|
|
||||||
// Not supported in Aura. Callers should fall back to the async version.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrabWindowSnapshotAndScaleAsync(gfx::NativeWindow window,
|
void GrabWindowSnapshotAndScaleAsync(gfx::NativeWindow window,
|
||||||
const gfx::Rect& source_rect,
|
const gfx::Rect& source_rect,
|
||||||
const gfx::Size& target_size,
|
const gfx::Size& target_size,
|
||||||
|
@ -31,27 +31,19 @@ UIImage* GetViewSnapshot(UIView* view, CGRect bounds) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool GrabViewSnapshot(gfx::NativeView view,
|
|
||||||
const gfx::Rect& snapshot_bounds,
|
|
||||||
gfx::Image* image) {
|
|
||||||
UIView* source_view = view.Get();
|
|
||||||
if (source_view == nil) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UIImage* snapshot = GetViewSnapshot(source_view, snapshot_bounds.ToCGRect());
|
|
||||||
if (snapshot) {
|
|
||||||
*image = gfx::Image(snapshot);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrabViewSnapshotAsync(gfx::NativeView view,
|
void GrabViewSnapshotAsync(gfx::NativeView view,
|
||||||
const gfx::Rect& source_rect,
|
const gfx::Rect& source_rect,
|
||||||
GrabSnapshotImageCallback callback) {
|
GrabSnapshotImageCallback callback) {
|
||||||
gfx::Image image;
|
gfx::Image image;
|
||||||
GrabViewSnapshot(view, source_rect, &image);
|
|
||||||
|
UIView* source_view = view.Get();
|
||||||
|
if (source_view) {
|
||||||
|
UIImage* snapshot = GetViewSnapshot(source_view, source_rect.ToCGRect());
|
||||||
|
if (snapshot) {
|
||||||
|
image = gfx::Image(snapshot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::move(callback).Run(image);
|
std::move(callback).Run(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,15 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
bool GrabViewSnapshot(gfx::NativeView native_view,
|
namespace {
|
||||||
const gfx::Rect& snapshot_bounds,
|
|
||||||
gfx::Image* image) {
|
// This implementation uses the obsolete CGWindowListCreateImage API.
|
||||||
|
// TODO(https://crbug.com/1464728): When there is a ScreenCaptureKit API that
|
||||||
|
// allows window self-capture without menu chip and without TCC requirements,
|
||||||
|
// switch to that API.
|
||||||
|
void GrabViewSnapshotImpl(gfx::NativeView native_view,
|
||||||
|
const gfx::Rect& snapshot_bounds,
|
||||||
|
gfx::Image* image) {
|
||||||
NSView* view = native_view.GetNativeNSView();
|
NSView* view = native_view.GetNativeNSView();
|
||||||
NSWindow* window = view.window;
|
NSWindow* window = view.window;
|
||||||
NSScreen* screen = NSScreen.screens.firstObject;
|
NSScreen* screen = NSScreen.screens.firstObject;
|
||||||
@ -45,29 +51,33 @@ bool GrabViewSnapshot(gfx::NativeView native_view,
|
|||||||
screen_snapshot_bounds.ToCGRect(), kCGWindowListOptionIncludingWindow,
|
screen_snapshot_bounds.ToCGRect(), kCGWindowListOptionIncludingWindow,
|
||||||
window.windowNumber, kCGWindowImageBoundsIgnoreFraming));
|
window.windowNumber, kCGWindowImageBoundsIgnoreFraming));
|
||||||
if (CGImageGetWidth(windowSnapshot.get()) <= 0) {
|
if (CGImageGetWidth(windowSnapshot.get()) <= 0) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*image = gfx::Image([[NSImage alloc] initWithCGImage:windowSnapshot.get()
|
*image = gfx::Image([[NSImage alloc] initWithCGImage:windowSnapshot.get()
|
||||||
size:NSZeroSize]);
|
size:NSZeroSize]);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void GrabWindowSnapshotAsync(gfx::NativeWindow native_window,
|
void GrabWindowSnapshotAsync(gfx::NativeWindow native_window,
|
||||||
const gfx::Rect& source_rect,
|
const gfx::Rect& source_rect,
|
||||||
GrabSnapshotImageCallback callback) {
|
GrabSnapshotImageCallback callback) {
|
||||||
// Make sure to grab the "window frame" view so we get current tab +
|
// Make sure to grab the "window frame" view so we get current tab +
|
||||||
// tabstrip.
|
// tabstrip.
|
||||||
NSWindow* window = native_window.GetNativeNSWindow();
|
NSView* view = native_window.GetNativeNSWindow().contentView.superview;
|
||||||
return GrabViewSnapshotAsync(window.contentView.superview, source_rect,
|
|
||||||
std::move(callback));
|
gfx::Image image;
|
||||||
|
GrabViewSnapshotImpl(view, source_rect, &image);
|
||||||
|
std::move(callback).Run(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrabViewSnapshotAsync(gfx::NativeView view,
|
void GrabViewSnapshotAsync(gfx::NativeView view,
|
||||||
const gfx::Rect& source_rect,
|
const gfx::Rect& source_rect,
|
||||||
GrabSnapshotImageCallback callback) {
|
GrabSnapshotImageCallback callback) {
|
||||||
gfx::Image image;
|
gfx::Image image;
|
||||||
GrabViewSnapshot(view, source_rect, &image);
|
GrabViewSnapshotImpl(view, source_rect, &image);
|
||||||
std::move(callback).Run(image);
|
std::move(callback).Run(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace ui {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool GrabHwndSnapshot(HWND window_handle,
|
void GrabHwndSnapshot(HWND window_handle,
|
||||||
const gfx::Rect& snapshot_bounds_in_pixels,
|
const gfx::Rect& snapshot_bounds_in_pixels,
|
||||||
const gfx::Rect& clip_rect_in_pixels,
|
const gfx::Rect& clip_rect_in_pixels,
|
||||||
gfx::Image* image) {
|
gfx::Image* image) {
|
||||||
@ -45,7 +45,7 @@ bool GrabHwndSnapshot(HWND window_handle,
|
|||||||
BOOL result = PrintWindow(window_handle, mem_hdc, flags);
|
BOOL result = PrintWindow(window_handle, mem_hdc, flags);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PLOG(ERROR) << "Failed to print window";
|
PLOG(ERROR) << "Failed to print window";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
@ -69,15 +69,15 @@ bool GrabHwndSnapshot(HWND window_handle,
|
|||||||
|
|
||||||
*image = gfx::Image::CreateFrom1xBitmap(bitmap);
|
*image = gfx::Image::CreateFrom1xBitmap(bitmap);
|
||||||
|
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
|
void GrabNativeWindowSnapshot(gfx::NativeWindow native_window,
|
||||||
const gfx::Rect& snapshot_bounds,
|
const gfx::Rect& snapshot_bounds,
|
||||||
gfx::Image* image) {
|
gfx::Image* image) {
|
||||||
DCHECK(window_handle);
|
DCHECK(native_window);
|
||||||
gfx::Rect window_bounds = window_handle->GetBoundsInRootWindow();
|
gfx::Rect window_bounds = native_window->GetBoundsInRootWindow();
|
||||||
aura::WindowTreeHost* host = window_handle->GetHost();
|
aura::WindowTreeHost* host = native_window->GetHost();
|
||||||
DCHECK(host);
|
DCHECK(host);
|
||||||
HWND hwnd = host->GetAcceleratedWidget();
|
HWND hwnd = host->GetAcceleratedWidget();
|
||||||
|
|
||||||
@ -92,23 +92,17 @@ bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
|
|||||||
|
|
||||||
expanded_window_bounds_in_pixels.Intersect(client_area_rect);
|
expanded_window_bounds_in_pixels.Intersect(client_area_rect);
|
||||||
|
|
||||||
return GrabHwndSnapshot(hwnd, snapshot_bounds_in_pixels,
|
GrabHwndSnapshot(hwnd, snapshot_bounds_in_pixels,
|
||||||
expanded_window_bounds_in_pixels, image);
|
expanded_window_bounds_in_pixels, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool GrabViewSnapshot(gfx::NativeView view_handle,
|
|
||||||
const gfx::Rect& snapshot_bounds,
|
|
||||||
gfx::Image* image) {
|
|
||||||
return GrabWindowSnapshot(view_handle, snapshot_bounds, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrabWindowSnapshotAsync(gfx::NativeWindow window,
|
void GrabWindowSnapshotAsync(gfx::NativeWindow window,
|
||||||
const gfx::Rect& source_rect,
|
const gfx::Rect& source_rect,
|
||||||
GrabSnapshotImageCallback callback) {
|
GrabSnapshotImageCallback callback) {
|
||||||
gfx::Image image;
|
gfx::Image image;
|
||||||
GrabWindowSnapshot(window, source_rect, &image);
|
GrabNativeWindowSnapshot(window, source_rect, &image);
|
||||||
std::move(callback).Run(image);
|
std::move(callback).Run(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +110,7 @@ void GrabViewSnapshotAsync(gfx::NativeView view,
|
|||||||
const gfx::Rect& source_rect,
|
const gfx::Rect& source_rect,
|
||||||
GrabSnapshotImageCallback callback) {
|
GrabSnapshotImageCallback callback) {
|
||||||
gfx::Image image;
|
gfx::Image image;
|
||||||
GrabViewSnapshot(view, source_rect, &image);
|
GrabNativeWindowSnapshot(view, source_rect, &image);
|
||||||
std::move(callback).Run(image);
|
std::move(callback).Run(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user