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

Unified Diff: extensions/browser/api/web_contents_capture_client.cc

Issue 2702093002: Consistent CopyFromSurface() API, consolidated to RWHV (Closed)
Patch Set: REBASE Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/api/web_contents_capture_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/web_contents_capture_client.cc
diff --git a/extensions/browser/api/web_contents_capture_client.cc b/extensions/browser/api/web_contents_capture_client.cc
index 04f7c96e1cb974d07fb132731e6b8c2f5c54f60d..78ee2851a3f6c264e8fdb13388132b1e1689432a 100644
--- a/extensions/browser/api/web_contents_capture_client.cc
+++ b/extensions/browser/api/web_contents_capture_client.cc
@@ -12,11 +12,8 @@
#include "extensions/browser/extension_function.h"
#include "extensions/common/constants.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/display/display.h"
-#include "ui/display/screen.h"
#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/codec/png_codec.h"
-#include "ui/gfx/geometry/size_conversions.h"
using content::RenderWidgetHost;
using content::RenderWidgetHostView;
@@ -53,30 +50,17 @@ bool WebContentsCaptureClient::CaptureAsync(
// TODO(miu): Account for fullscreen render widget? http://crbug.com/419878
RenderWidgetHostView* const view = web_contents->GetRenderWidgetHostView();
- RenderWidgetHost* const host = view ? view->GetRenderWidgetHost() : nullptr;
- if (!view || !host) {
+ if (!view) {
OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE);
return false;
}
-
- // By default, the requested bitmap size is the view size in screen
- // coordinates. However, if there's more pixel detail available on the
- // current system, increase the requested bitmap size to capture it all.
- const gfx::Size view_size = view->GetViewBounds().size();
- gfx::Size bitmap_size = view_size;
- const gfx::NativeView native_view = view->GetNativeView();
- display::Screen* const screen = display::Screen::GetScreen();
- const float scale =
- screen->GetDisplayNearestWindow(native_view).device_scale_factor();
- if (scale > 1.0f)
- bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
-
- host->CopyFromBackingStore(gfx::Rect(view_size), bitmap_size, callback,
- kN32_SkColorType);
+ view->CopyFromSurface(gfx::Rect(), // Copy entire surface area.
+ gfx::Size(), // Result contains device-level detail.
+ callback, kN32_SkColorType);
return true;
}
-void WebContentsCaptureClient::CopyFromBackingStoreComplete(
+void WebContentsCaptureClient::CopyFromSurfaceComplete(
const SkBitmap& bitmap,
content::ReadbackResponse response) {
if (response == content::READBACK_SUCCESS) {
« no previous file with comments | « extensions/browser/api/web_contents_capture_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698