removes logs and adds webcontentsview init

This commit is contained in:
gellert 2016-07-25 15:55:00 +02:00
parent 0ad0c79202
commit 8fb7872b84
6 changed files with 271 additions and 217 deletions

View file

@ -309,13 +309,13 @@ WebContents::WebContents(v8::Isolate* isolate,
web_contents = content::WebContents::Create(params); web_contents = content::WebContents::Create(params);
} else { } else {
content::WebContents::CreateParams params(session->browser_context()); content::WebContents::CreateParams params(session->browser_context());
params.view = new OffScreenWebContentsView();
params.delegate_view = (content::RenderViewHostDelegateView *)params.view;
web_contents = content::WebContents::Create(params); web_contents = content::WebContents::Create(params);
} }
content::WebContentsImpl* impl =
reinterpret_cast<content::WebContentsImpl*>(web_contents);
impl->SetView(new OffScreenWebContentsView);
Observe(web_contents); Observe(web_contents);
InitWithWebContents(web_contents, session->browser_context()); InitWithWebContents(web_contents, session->browser_context());

View file

@ -164,4 +164,17 @@ void OffScreenWebContentsView::CloseTabAfterEventTracking() {
} }
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
void OffScreenWebContentsView::StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info) {
}
void OffScreenWebContentsView::UpdateDragCursor(
blink::WebDragOperation operation) {
}
} // namespace atom } // namespace atom

View file

@ -5,11 +5,13 @@
#ifndef ATOM_BROWSER_OSR_WEB_CONTENTS_VIEW_H_ #ifndef ATOM_BROWSER_OSR_WEB_CONTENTS_VIEW_H_
#define ATOM_BROWSER_OSR_WEB_CONTENTS_VIEW_H_ #define ATOM_BROWSER_OSR_WEB_CONTENTS_VIEW_H_
#include "content/browser/renderer_host/render_view_host_delegate_view.h"
#include "content/browser/web_contents/web_contents_view.h" #include "content/browser/web_contents/web_contents_view.h"
namespace atom { namespace atom {
class OffScreenWebContentsView : public content::WebContentsView { class OffScreenWebContentsView : public content::WebContentsView,
public content::RenderViewHostDelegateView {
public: public:
OffScreenWebContentsView(); OffScreenWebContentsView();
~OffScreenWebContentsView(); ~OffScreenWebContentsView();
@ -48,6 +50,15 @@ public:
void CloseTabAfterEventTracking() override; void CloseTabAfterEventTracking() override;
#endif #endif
// RenderViewHostDelegateView methods.
void StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info) override;
void UpdateDragCursor(blink::WebDragOperation operation) override;
private: private:
content::RenderWidgetHostViewBase* view_; content::RenderWidgetHostViewBase* view_;
}; };

View file

@ -17,6 +17,7 @@
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h" #include "ui/compositor/layer_type.h"
#include "base/location.h" #include "base/location.h"
#include "base/time/time.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
@ -33,6 +34,8 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "cc/scheduler/delay_based_time_source.h" #include "cc/scheduler/delay_based_time_source.h"
#include "content/common/host_shared_bitmap_manager.h"
// const float kDefaultScaleFactor = 1.0; // const float kDefaultScaleFactor = 1.0;
// The maximum number of retry counts if frame capture fails. // The maximum number of retry counts if frame capture fails.
@ -66,6 +69,7 @@ class CefCopyFrameGenerator {
frame_in_progress_(false), frame_in_progress_(false),
frame_retry_count_(0), frame_retry_count_(0),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
last_time_ = base::Time::Now();
} }
void GenerateCopyFrame( void GenerateCopyFrame(
@ -83,8 +87,10 @@ class CefCopyFrameGenerator {
pending_damage_rect_.Union(damage_rect); pending_damage_rect_.Union(damage_rect);
// Don't attempt to generate a frame while one is currently in-progress. // Don't attempt to generate a frame while one is currently in-progress.
if (frame_in_progress_) if (frame_in_progress_) {
// std::cout << "FRAME IN PROGRESS" << std::endl;
return; return;
}
frame_in_progress_ = true; frame_in_progress_ = true;
// Don't exceed the frame rate threshold. // Don't exceed the frame rate threshold.
@ -198,6 +204,14 @@ class CefCopyFrameGenerator {
ignore_result(scoped_callback_runner.Release()); ignore_result(scoped_callback_runner.Release());
// base::Time now = base::Time::Now();
// std::cout << "delta: " << (now - last_time_).InMilliseconds() << " ms" << std::endl;
// last_time_ = now;
// frame_in_progress_ = false;
// if (view_->paintCallback) {
// view_->paintCallback->Run(damage_rect, bitmap_->width(), bitmap_->height(),
// pixels);
// }
gl_helper->CropScaleReadbackAndCleanMailbox( gl_helper->CropScaleReadbackAndCleanMailbox(
texture_mailbox.mailbox(), texture_mailbox.mailbox(),
texture_mailbox.sync_token(), texture_mailbox.sync_token(),
@ -293,6 +307,10 @@ class CefCopyFrameGenerator {
std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock) { std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock) {
uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels()); uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels());
base::Time now = base::Time::Now();
// std::cout << "delta: " << (now - last_time_).InMilliseconds() << " ms" << std::endl;
last_time_ = now;
// for (int i = 0; i<4; i++) { // for (int i = 0; i<4; i++) {
// int x = static_cast<int>(pixels[i]); // int x = static_cast<int>(pixels[i]);
// std::cout << std::hex << x << std::dec << std::endl; // std::cout << std::hex << x << std::dec << std::endl;
@ -328,6 +346,8 @@ class CefCopyFrameGenerator {
int frame_rate_threshold_ms_; int frame_rate_threshold_ms_;
OffScreenWindow* view_; OffScreenWindow* view_;
base::Time last_time_;
base::TimeTicks frame_start_time_; base::TimeTicks frame_start_time_;
bool frame_pending_; bool frame_pending_;
bool frame_in_progress_; bool frame_in_progress_;
@ -393,6 +413,8 @@ OffScreenWindow::OffScreenWindow(content::RenderWidgetHost* host)
// std::cout << "OffScreenWindow" << std::endl; // std::cout << "OffScreenWindow" << std::endl;
render_widget_host_->SetView(this); render_widget_host_->SetView(this);
last_time_ = base::Time::Now();
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
CreatePlatformWidget(); CreatePlatformWidget();
@ -406,6 +428,11 @@ OffScreenWindow::OffScreenWindow(content::RenderWidgetHost* host)
#endif #endif
// compositor_->SetDelegate(this); // compositor_->SetDelegate(this);
compositor_->SetRootLayer(root_layer_.get()); compositor_->SetRootLayer(root_layer_.get());
ResizeRootLayer();
std::unique_ptr<cc::SharedBitmap> sbp = content::HostSharedBitmapManager::current()->AllocateSharedBitmap(gfx::Size(800, 600));
printf("shared bitmap: %p\n", sbp.get());
} }
void OffScreenWindow::ResizeRootLayer() { void OffScreenWindow::ResizeRootLayer() {
@ -614,7 +641,9 @@ bool OffScreenWindow::GetScreenColorProfile(std::vector<char>*) {
void OffScreenWindow::OnSwapCompositorFrame( void OffScreenWindow::OnSwapCompositorFrame(
uint32_t output_surface_id, uint32_t output_surface_id,
std::unique_ptr<cc::CompositorFrame> frame) { std::unique_ptr<cc::CompositorFrame> frame) {
// std::cout << "OnSwapCompositorFrame" << std::endl; base::Time now = base::Time::Now();
// std::cout << "OnSwapCompositorFrame " << (now - last_time_).InMilliseconds() << " ms" << std::endl;
last_time_ = now;
// std::cout << output_surface_id << std::endl; // std::cout << output_surface_id << std::endl;
@ -622,9 +651,8 @@ void OffScreenWindow::OnSwapCompositorFrame(
last_scroll_offset_ = frame->metadata.root_scroll_offset; last_scroll_offset_ = frame->metadata.root_scroll_offset;
} }
if (!frame->delegated_frame_data) { if (!frame->delegated_frame_data)
return; return;
}
if (software_output_device_) { if (software_output_device_) {
// if (!begin_frame_timer_.get()) { // if (!begin_frame_timer_.get()) {
@ -650,9 +678,8 @@ void OffScreenWindow::OnSwapCompositorFrame(
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect)); gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
damage_rect.Intersect(gfx::Rect(frame_size)); damage_rect.Intersect(gfx::Rect(frame_size));
if (frame->delegated_frame_data) delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
delegated_frame_host_->SwapDelegatedFrame(output_surface_id, std::move(frame));
std::move(frame));
// Request a copy of the last compositor frame which will eventually call // Request a copy of the last compositor frame which will eventually call
// OnPaint asynchronously. // OnPaint asynchronously.
@ -887,10 +914,10 @@ void OffScreenWindow::OnSetNeedsBeginFrames(bool enabled) {
void OffScreenWindow::SetFrameRate() { void OffScreenWindow::SetFrameRate() {
// Only set the frame rate one time. // Only set the frame rate one time.
if (frame_rate_threshold_ms_ != 0) // if (frame_rate_threshold_ms_ != 0)
return; // return;
const int frame_rate = 120; const int frame_rate = 60;
frame_rate_threshold_ms_ = 1000 / frame_rate; frame_rate_threshold_ms_ = 1000 / frame_rate;
// Configure the VSync interval for the browser process. // Configure the VSync interval for the browser process.

View file

@ -14,6 +14,7 @@
#include "cc/output/compositor_frame.h" #include "cc/output/compositor_frame.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/time/time.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/compositor/layer_delegate.h" #include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_owner.h" #include "ui/compositor/layer_owner.h"
@ -204,6 +205,8 @@ private:
int frame_rate_threshold_ms_; int frame_rate_threshold_ms_;
base::Time last_time_;
float scale_factor_; float scale_factor_;
bool is_showing_; bool is_showing_;
gfx::Vector2dF last_scroll_offset_; gfx::Vector2dF last_scroll_offset_;

View file

@ -40,212 +40,212 @@ exports.load = (appUrl) => {
end1 = +new Date(); end1 = +new Date();
const d = end1 - start1 const d = end1 - start1
console.log(`browser #1: ${d < 10 ? ` ${d}` : d} ms`) // console.log(`browser #1: ${d < 10 ? ` ${d}` : d} ms`)
start1 = end1 start1 = end1
}) })
mainWindow2 = new BrowserWindow({ // mainWindow2 = new BrowserWindow({
width: 800, // width: 800,
height: 600, // height: 600,
autoHideMenuBar: true, // autoHideMenuBar: true,
backgroundColor: '#FFFFFF', // backgroundColor: '#FFFFFF',
useContentSize: true, // useContentSize: true,
webPreferences: { // webPreferences: {
nodeIntegration: false // nodeIntegration: false
} // }
}) // })
mainWindow2.loadURL(appUrl) // mainWindow2.loadURL(appUrl)
mainWindow2.focus() // mainWindow2.focus()
mainWindow2.webContents.on('dom-ready', () => { // mainWindow2.webContents.on('dom-ready', () => {
mainWindow2.webContents.beginFrameSubscription(() => { // mainWindow2.webContents.beginFrameSubscription(() => {
console.log("asd") // console.log("asd")
}) // })
}) // })
//
// var start2, end2
// start2 = +new Date();
// mainWindow2.webContents.on('paint', (e, rect, w, h, data) => {
// end2 = +new Date();
//
// const d = end2 - start2
// console.log(`browser #2: ${d < 10 ? ` ${d}` : d} ms`)
//
// start2 = end2
// })
//
// mainWindow3 = new BrowserWindow({
// width: 800,
// height: 600,
// autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
// useContentSize: true,
// webPreferences: {
// nodeIntegration: false
// }
// })
// mainWindow3.loadURL(appUrl)
// mainWindow3.focus()
// mainWindow3.webContents.on('dom-ready', () => {
// mainWindow3.webContents.beginFrameSubscription(() => {
// console.log("asd")
// })
// })
//
// var start3, end3
// start3 = +new Date();
// mainWindow3.webContents.on('paint', (e, rect, w, h, data) => {
// end3 = +new Date();
//
// const d = end3 - start3
// console.log(`browser #3: ${d < 10 ? ` ${d}` : d} ms`)
//
// start3 = end3
// })
//
// mainWindow4 = new BrowserWindow({
// width: 800,
// height: 600,
// autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
// useContentSize: true,
// webPreferences: {
// nodeIntegration: false
// }
// })
// mainWindow4.loadURL(appUrl)
// mainWindow4.focus()
// mainWindow4.webContents.on('dom-ready', () => {
// mainWindow4.webContents.beginFrameSubscription(() => {
// console.log("asd")
// })
// })
//
// var start4, end4
// start4 = +new Date();
// mainWindow4.webContents.on('paint', (e, rect, w, h, data) => {
// end4 = +new Date();
//
// const d = end4 - start4
// console.log(`browser #4: ${d < 10 ? ` ${d}` : d} ms`)
//
// start4 = end4
// })
var start2, end2 // mainWindow5 = new BrowserWindow({
start2 = +new Date(); // width: 800,
mainWindow2.webContents.on('paint', (e, rect, w, h, data) => { // height: 600,
end2 = +new Date(); // autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
const d = end2 - start2 // useContentSize: true,
console.log(`browser #2: ${d < 10 ? ` ${d}` : d} ms`) // webPreferences: {
// nodeIntegration: false
start2 = end2 // }
}) // })
// mainWindow5.loadURL(appUrl)
mainWindow3 = new BrowserWindow({ // mainWindow5.focus()
width: 800, // mainWindow5.webContents.on('dom-ready', () => {
height: 600, // mainWindow5.webContents.beginFrameSubscription(() => {
autoHideMenuBar: true, // console.log("asd")
backgroundColor: '#FFFFFF', // })
useContentSize: true, // })
webPreferences: { //
nodeIntegration: false // var start5, end5
} // start5 = +new Date();
}) // mainWindow5.webContents.on('paint', (e, rect, w, h, data) => {
mainWindow3.loadURL(appUrl) // end5 = +new Date();
mainWindow3.focus() //
mainWindow3.webContents.on('dom-ready', () => { // const d = end5 - start5
mainWindow3.webContents.beginFrameSubscription(() => { // console.log(`browser #5: ${d < 10 ? ` ${d}` : d} ms`)
console.log("asd") //
}) // start5 = end5
}) // })
//
var start3, end3 // mainWindow6 = new BrowserWindow({
start3 = +new Date(); // width: 800,
mainWindow3.webContents.on('paint', (e, rect, w, h, data) => { // height: 600,
end3 = +new Date(); // autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
const d = end3 - start3 // useContentSize: true,
console.log(`browser #3: ${d < 10 ? ` ${d}` : d} ms`) // webPreferences: {
// nodeIntegration: false
start3 = end3 // }
}) // })
// mainWindow6.loadURL(appUrl)
mainWindow4 = new BrowserWindow({ // mainWindow6.focus()
width: 800, // mainWindow6.webContents.on('dom-ready', () => {
height: 600, // mainWindow6.webContents.beginFrameSubscription(() => {
autoHideMenuBar: true, // console.log("asd")
backgroundColor: '#FFFFFF', // })
useContentSize: true, // })
webPreferences: { //
nodeIntegration: false // var start6, end6
} // start6 = +new Date();
}) // mainWindow6.webContents.on('paint', (e, rect, w, h, data) => {
mainWindow4.loadURL(appUrl) // end6 = +new Date();
mainWindow4.focus() //
mainWindow4.webContents.on('dom-ready', () => { // const d = end6 - start6
mainWindow4.webContents.beginFrameSubscription(() => { // console.log(`browser #6: ${d < 10 ? ` ${d}` : d} ms`)
console.log("asd") //
}) // start6 = end6
}) // })
//
var start4, end4 // mainWindow7 = new BrowserWindow({
start4 = +new Date(); // width: 800,
mainWindow4.webContents.on('paint', (e, rect, w, h, data) => { // height: 600,
end4 = +new Date(); // autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
const d = end4 - start4 // useContentSize: true,
console.log(`browser #4: ${d < 10 ? ` ${d}` : d} ms`) // webPreferences: {
// nodeIntegration: false
start4 = end4 // }
}) // })
// mainWindow7.loadURL(appUrl)
mainWindow5 = new BrowserWindow({ // mainWindow7.focus()
width: 800, // mainWindow7.webContents.on('dom-ready', () => {
height: 600, // mainWindow7.webContents.beginFrameSubscription(() => {
autoHideMenuBar: true, // console.log("asd")
backgroundColor: '#FFFFFF', // })
useContentSize: true, // })
webPreferences: { //
nodeIntegration: false // var start7, end7
} // start7 = +new Date();
}) // mainWindow7.webContents.on('paint', (e, rect, w, h, data) => {
mainWindow5.loadURL(appUrl) // end7 = +new Date();
mainWindow5.focus() //
mainWindow5.webContents.on('dom-ready', () => { // const d = end7 - start7
mainWindow5.webContents.beginFrameSubscription(() => { // console.log(`browser #7: ${d < 10 ? ` ${d}` : d} ms`)
console.log("asd") //
}) // start7 = end7
}) // })
//
var start5, end5 // mainWindow8 = new BrowserWindow({
start5 = +new Date(); // width: 800,
mainWindow5.webContents.on('paint', (e, rect, w, h, data) => { // height: 600,
end5 = +new Date(); // autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
const d = end5 - start5 // useContentSize: true,
console.log(`browser #5: ${d < 10 ? ` ${d}` : d} ms`) // webPreferences: {
// nodeIntegration: false
start5 = end5 // }
}) // })
// mainWindow8.loadURL(appUrl)
mainWindow6 = new BrowserWindow({ // mainWindow8.focus()
width: 800, // mainWindow8.webContents.on('dom-ready', () => {
height: 600, // mainWindow8.webContents.beginFrameSubscription(() => {
autoHideMenuBar: true, // console.log("asd")
backgroundColor: '#FFFFFF', // })
useContentSize: true, // })
webPreferences: { //
nodeIntegration: false // var start8, end8
} // start8 = +new Date();
}) // mainWindow8.webContents.on('paint', (e, rect, w, h, data) => {
mainWindow6.loadURL(appUrl) // end8 = +new Date();
mainWindow6.focus() //
mainWindow6.webContents.on('dom-ready', () => { // const d = end8 - start8
mainWindow6.webContents.beginFrameSubscription(() => { // console.log(`browser #8: ${d < 10 ? ` ${d}` : d} ms`)
console.log("asd") //
}) // start8 = end8
}) // })
var start6, end6
start6 = +new Date();
mainWindow6.webContents.on('paint', (e, rect, w, h, data) => {
end6 = +new Date();
const d = end6 - start6
console.log(`browser #6: ${d < 10 ? ` ${d}` : d} ms`)
start6 = end6
})
mainWindow7 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
nodeIntegration: false
}
})
mainWindow7.loadURL(appUrl)
mainWindow7.focus()
mainWindow7.webContents.on('dom-ready', () => {
mainWindow7.webContents.beginFrameSubscription(() => {
console.log("asd")
})
})
var start7, end7
start7 = +new Date();
mainWindow7.webContents.on('paint', (e, rect, w, h, data) => {
end7 = +new Date();
const d = end7 - start7
console.log(`browser #7: ${d < 10 ? ` ${d}` : d} ms`)
start7 = end7
})
mainWindow8 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
nodeIntegration: false
}
})
mainWindow8.loadURL(appUrl)
mainWindow8.focus()
mainWindow8.webContents.on('dom-ready', () => {
mainWindow8.webContents.beginFrameSubscription(() => {
console.log("asd")
})
})
var start8, end8
start8 = +new Date();
mainWindow8.webContents.on('paint', (e, rect, w, h, data) => {
end8 = +new Date();
const d = end8 - start8
console.log(`browser #8: ${d < 10 ? ` ${d}` : d} ms`)
start8 = end8
})
}) })
} }