From 1b0af6f6f159a5a48d4ffbff0dff917fdeb7dd7c Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Thu, 4 Aug 2016 05:18:27 +0200 Subject: [PATCH] removed bpp (it can be calculated) fixed buffer size calculation (we actually send the whole image, not just the dirty part) removed the unnecessary resets and const now we use Copy instead of New --- atom/browser/api/atom_api_web_contents.cc | 9 ++++----- atom/browser/osr/osr_render_widget_host_view.cc | 7 ------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index a5aa18f24e..8b7b77f240 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1345,16 +1345,15 @@ bool WebContents::IsOffScreen() const { void WebContents::OnPaint(const gfx::Rect& dirty_rect, const gfx::Size& bitmap_size, - const int pixel_size, + int pixel_size, void* bitmap_pixels) { - v8::MaybeLocal buffer = node::Buffer::New( + v8::MaybeLocal buffer = node::Buffer::Copy( isolate(), reinterpret_cast(bitmap_pixels), - pixel_size * dirty_rect.width() * dirty_rect.height()); + pixel_size * bitmap_size.width() * bitmap_size.height()); mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate()); dict.Set("width", bitmap_size.width()); dict.Set("height", bitmap_size.height()); - dict.Set("bytesPerPixel", pixel_size); if (!buffer.IsEmpty()) Emit("paint", dirty_rect, buffer.ToLocalChecked(), dict); @@ -1367,8 +1366,8 @@ void WebContents::StartPainting() { auto* osr_rwhv = static_cast( web_contents()->GetRenderWidgetHostView()); if (osr_rwhv) { - osr_rwhv->SetPainting(true); osr_rwhv->Show(); + osr_rwhv->SetPainting(true); } } diff --git a/atom/browser/osr/osr_render_widget_host_view.cc b/atom/browser/osr/osr_render_widget_host_view.cc index ecb8c6628e..4ae3a578a8 100644 --- a/atom/browser/osr/osr_render_widget_host_view.cc +++ b/atom/browser/osr/osr_render_widget_host_view.cc @@ -379,13 +379,6 @@ OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() { #if defined(OS_MACOSX) DestroyPlatformWidget(); #endif - - if (copy_frame_generator_.get()) - copy_frame_generator_.reset(nullptr); - - delegated_frame_host_.reset(nullptr); - compositor_.reset(nullptr); - root_layer_.reset(nullptr); } void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() {