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 {
|
||||
|
||||
// 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 GrabSnapshotDataCallback =
|
||||
base::OnceCallback<void(scoped_refptr<base::RefCountedMemory> data)>;
|
||||
|
@ -20,14 +20,6 @@
|
||||
|
||||
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(
|
||||
gfx::NativeView view,
|
||||
const gfx::Rect& source_rect,
|
||||
|
@ -102,13 +102,6 @@ void GrabWindowSnapshotAsyncAura(aura::Window* window,
|
||||
|
||||
#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,
|
||||
const gfx::Rect& source_rect,
|
||||
const gfx::Size& target_size,
|
||||
|
@ -31,27 +31,19 @@ UIImage* GetViewSnapshot(UIView* view, CGRect bounds) {
|
||||
|
||||
} // 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,
|
||||
const gfx::Rect& source_rect,
|
||||
GrabSnapshotImageCallback callback) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,15 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
bool GrabViewSnapshot(gfx::NativeView native_view,
|
||||
const gfx::Rect& snapshot_bounds,
|
||||
gfx::Image* image) {
|
||||
namespace {
|
||||
|
||||
// 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();
|
||||
NSWindow* window = view.window;
|
||||
NSScreen* screen = NSScreen.screens.firstObject;
|
||||
@ -45,29 +51,33 @@ bool GrabViewSnapshot(gfx::NativeView native_view,
|
||||
screen_snapshot_bounds.ToCGRect(), kCGWindowListOptionIncludingWindow,
|
||||
window.windowNumber, kCGWindowImageBoundsIgnoreFraming));
|
||||
if (CGImageGetWidth(windowSnapshot.get()) <= 0) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
*image = gfx::Image([[NSImage alloc] initWithCGImage:windowSnapshot.get()
|
||||
size:NSZeroSize]);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void GrabWindowSnapshotAsync(gfx::NativeWindow native_window,
|
||||
const gfx::Rect& source_rect,
|
||||
GrabSnapshotImageCallback callback) {
|
||||
// Make sure to grab the "window frame" view so we get current tab +
|
||||
// tabstrip.
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
return GrabViewSnapshotAsync(window.contentView.superview, source_rect,
|
||||
std::move(callback));
|
||||
NSView* view = native_window.GetNativeNSWindow().contentView.superview;
|
||||
|
||||
gfx::Image image;
|
||||
GrabViewSnapshotImpl(view, source_rect, &image);
|
||||
std::move(callback).Run(image);
|
||||
}
|
||||
|
||||
void GrabViewSnapshotAsync(gfx::NativeView view,
|
||||
const gfx::Rect& source_rect,
|
||||
GrabSnapshotImageCallback callback) {
|
||||
gfx::Image image;
|
||||
GrabViewSnapshot(view, source_rect, &image);
|
||||
GrabViewSnapshotImpl(view, source_rect, &image);
|
||||
std::move(callback).Run(image);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace ui {
|
||||
|
||||
namespace {
|
||||
|
||||
bool GrabHwndSnapshot(HWND window_handle,
|
||||
void GrabHwndSnapshot(HWND window_handle,
|
||||
const gfx::Rect& snapshot_bounds_in_pixels,
|
||||
const gfx::Rect& clip_rect_in_pixels,
|
||||
gfx::Image* image) {
|
||||
@ -45,7 +45,7 @@ bool GrabHwndSnapshot(HWND window_handle,
|
||||
BOOL result = PrintWindow(window_handle, mem_hdc, flags);
|
||||
if (!result) {
|
||||
PLOG(ERROR) << "Failed to print window";
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
SkBitmap bitmap;
|
||||
@ -69,15 +69,15 @@ bool GrabHwndSnapshot(HWND window_handle,
|
||||
|
||||
*image = gfx::Image::CreateFrom1xBitmap(bitmap);
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
|
||||
const gfx::Rect& snapshot_bounds,
|
||||
gfx::Image* image) {
|
||||
DCHECK(window_handle);
|
||||
gfx::Rect window_bounds = window_handle->GetBoundsInRootWindow();
|
||||
aura::WindowTreeHost* host = window_handle->GetHost();
|
||||
void GrabNativeWindowSnapshot(gfx::NativeWindow native_window,
|
||||
const gfx::Rect& snapshot_bounds,
|
||||
gfx::Image* image) {
|
||||
DCHECK(native_window);
|
||||
gfx::Rect window_bounds = native_window->GetBoundsInRootWindow();
|
||||
aura::WindowTreeHost* host = native_window->GetHost();
|
||||
DCHECK(host);
|
||||
HWND hwnd = host->GetAcceleratedWidget();
|
||||
|
||||
@ -92,23 +92,17 @@ bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
|
||||
|
||||
expanded_window_bounds_in_pixels.Intersect(client_area_rect);
|
||||
|
||||
return GrabHwndSnapshot(hwnd, snapshot_bounds_in_pixels,
|
||||
expanded_window_bounds_in_pixels, image);
|
||||
GrabHwndSnapshot(hwnd, snapshot_bounds_in_pixels,
|
||||
expanded_window_bounds_in_pixels, image);
|
||||
}
|
||||
|
||||
} // 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,
|
||||
const gfx::Rect& source_rect,
|
||||
GrabSnapshotImageCallback callback) {
|
||||
gfx::Image image;
|
||||
GrabWindowSnapshot(window, source_rect, &image);
|
||||
GrabNativeWindowSnapshot(window, source_rect, &image);
|
||||
std::move(callback).Run(image);
|
||||
}
|
||||
|
||||
@ -116,7 +110,7 @@ void GrabViewSnapshotAsync(gfx::NativeView view,
|
||||
const gfx::Rect& source_rect,
|
||||
GrabSnapshotImageCallback callback) {
|
||||
gfx::Image image;
|
||||
GrabViewSnapshot(view, source_rect, &image);
|
||||
GrabNativeWindowSnapshot(view, source_rect, &image);
|
||||
std::move(callback).Run(image);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user