Fix capturePage under accelerated mode, fixes #223.
This commit is contained in:
parent
ac11c95da6
commit
b21e5a6300
1 changed files with 17 additions and 1 deletions
|
@ -271,12 +271,28 @@ base::ProcessHandle NativeWindow::GetRenderProcessHandle() {
|
||||||
|
|
||||||
void NativeWindow::CapturePage(const gfx::Rect& rect,
|
void NativeWindow::CapturePage(const gfx::Rect& rect,
|
||||||
const CapturePageCallback& callback) {
|
const CapturePageCallback& callback) {
|
||||||
|
content::RenderViewHost* render_view_host =
|
||||||
|
GetWebContents()->GetRenderViewHost();
|
||||||
|
content::RenderWidgetHostView* render_widget_host_view =
|
||||||
|
render_view_host->GetView();
|
||||||
|
|
||||||
|
if (!render_widget_host_view) {
|
||||||
|
callback.Run(std::vector<unsigned char>());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Rect flipped_y_rect = rect;
|
gfx::Rect flipped_y_rect = rect;
|
||||||
flipped_y_rect.set_y(-rect.y());
|
flipped_y_rect.set_y(-rect.y());
|
||||||
|
|
||||||
|
gfx::Size size;
|
||||||
|
if (flipped_y_rect.IsEmpty())
|
||||||
|
size = render_widget_host_view->GetViewBounds().size();
|
||||||
|
else
|
||||||
|
size = flipped_y_rect.size();
|
||||||
|
|
||||||
GetWebContents()->GetRenderViewHost()->CopyFromBackingStore(
|
GetWebContents()->GetRenderViewHost()->CopyFromBackingStore(
|
||||||
flipped_y_rect,
|
flipped_y_rect,
|
||||||
gfx::Size(),
|
size,
|
||||||
base::Bind(&NativeWindow::OnCapturePageDone,
|
base::Bind(&NativeWindow::OnCapturePageDone,
|
||||||
weak_factory_.GetWeakPtr(),
|
weak_factory_.GetWeakPtr(),
|
||||||
callback));
|
callback));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue