forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapshot_android.cc
45 lines (38 loc) · 1.51 KB
/
snapshot_android.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/snapshot/snapshot.h"
#include "base/callback.h"
#include "ui/base/android/view_android.h"
#include "ui/base/android/window_android.h"
#include "ui/gfx/display.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
namespace ui {
bool GrabViewSnapshot(gfx::NativeView view,
std::vector<unsigned char>* png_representation,
const gfx::Rect& snapshot_bounds) {
return GrabWindowSnapshot(
view->GetWindowAndroid(), png_representation, snapshot_bounds);
}
bool GrabWindowSnapshot(gfx::NativeWindow window,
std::vector<unsigned char>* png_representation,
const gfx::Rect& snapshot_bounds) {
gfx::Display display =
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
gfx::Rect scaled_bounds =
gfx::ScaleToEnclosingRect(snapshot_bounds,
display.device_scale_factor());
return window->GrabSnapshot(
scaled_bounds.x(), scaled_bounds.y(), scaled_bounds.width(),
scaled_bounds.height(), png_representation);
}
SNAPSHOT_EXPORT void GrapWindowSnapshotAsync(
gfx::NativeWindow window,
const gfx::Rect& snapshot_bounds,
const gfx::Size& target_size,
scoped_refptr<base::TaskRunner> background_task_runner,
GrapWindowSnapshotAsyncCallback callback) {
NOTIMPLEMENTED();
}
} // namespace ui