Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: extensions/browser/api/capture_web_contents_function.cc

Issue 672823002: Remove IsDIPEnabled from Screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dpi-cleanup-1
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/api/capture_web_contents_function.h" 5 #include "extensions/browser/api/capture_web_contents_function.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "content/public/browser/render_widget_host.h" 9 #include "content/public/browser/render_widget_host.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return false; 69 return false;
70 } 70 }
71 71
72 // By default, the requested bitmap size is the view size in screen 72 // By default, the requested bitmap size is the view size in screen
73 // coordinates. However, if there's more pixel detail available on the 73 // coordinates. However, if there's more pixel detail available on the
74 // current system, increase the requested bitmap size to capture it all. 74 // current system, increase the requested bitmap size to capture it all.
75 const gfx::Size view_size = view->GetViewBounds().size(); 75 const gfx::Size view_size = view->GetViewBounds().size();
76 gfx::Size bitmap_size = view_size; 76 gfx::Size bitmap_size = view_size;
77 const gfx::NativeView native_view = view->GetNativeView(); 77 const gfx::NativeView native_view = view->GetNativeView();
78 gfx::Screen* const screen = gfx::Screen::GetScreenFor(native_view); 78 gfx::Screen* const screen = gfx::Screen::GetScreenFor(native_view);
79 if (screen->IsDIPEnabled()) { 79 const float scale =
80 const float scale = 80 screen->GetDisplayNearestWindow(native_view).device_scale_factor();
81 screen->GetDisplayNearestWindow(native_view).device_scale_factor(); 81 if (scale > 1.0f)
82 if (scale > 1.0f) 82 bitmap_size = gfx::ToCeiledSize(gfx::ScaleSize(view_size, scale));
83 bitmap_size = gfx::ToCeiledSize(gfx::ScaleSize(view_size, scale));
84 }
85 83
86 host->CopyFromBackingStore( 84 host->CopyFromBackingStore(
87 gfx::Rect(view_size), 85 gfx::Rect(view_size),
88 bitmap_size, 86 bitmap_size,
89 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, 87 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete,
90 this), 88 this),
91 kN32_SkColorType); 89 kN32_SkColorType);
92 return true; 90 return true;
93 } 91 }
94 92
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); 138 reinterpret_cast<const char*>(vector_as_array(&data)), data.size());
141 139
142 base::Base64Encode(stream_as_string, &base64_result); 140 base::Base64Encode(stream_as_string, &base64_result);
143 base64_result.insert( 141 base64_result.insert(
144 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); 142 0, base::StringPrintf("data:%s;base64,", mime_type.c_str()));
145 SetResult(new base::StringValue(base64_result)); 143 SetResult(new base::StringValue(base64_result));
146 SendResponse(true); 144 SendResponse(true);
147 } 145 }
148 146
149 } // namespace extensions 147 } // namespace extensions
OLDNEW
« no previous file with comments | « content/browser/media/capture/web_contents_video_capture_device_unittest.cc ('k') | mojo/aura/screen_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698