removes logs and adds webcontentsview init

This commit is contained in:
gellert 2016-07-25 15:55:00 +02:00
parent 81be0bc123
commit 6eba509d53
6 changed files with 271 additions and 217 deletions

View file

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

View file

@ -164,4 +164,17 @@ void OffScreenWebContentsView::CloseTabAfterEventTracking() {
}
#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

View file

@ -5,11 +5,13 @@
#ifndef 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"
namespace atom {
class OffScreenWebContentsView : public content::WebContentsView {
class OffScreenWebContentsView : public content::WebContentsView,
public content::RenderViewHostDelegateView {
public:
OffScreenWebContentsView();
~OffScreenWebContentsView();
@ -48,6 +50,15 @@ public:
void CloseTabAfterEventTracking() override;
#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:
content::RenderWidgetHostViewBase* view_;
};

View file

@ -17,6 +17,7 @@
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h"
#include "base/location.h"
#include "base/time/time.h"
#include "ui/gfx/native_widget_types.h"
#include <iostream>
#include <chrono>
@ -33,6 +34,8 @@
#include "content/public/browser/browser_thread.h"
#include "cc/scheduler/delay_based_time_source.h"
#include "content/common/host_shared_bitmap_manager.h"
// const float kDefaultScaleFactor = 1.0;
// The maximum number of retry counts if frame capture fails.
@ -66,6 +69,7 @@ class CefCopyFrameGenerator {
frame_in_progress_(false),
frame_retry_count_(0),
weak_ptr_factory_(this) {
last_time_ = base::Time::Now();
}
void GenerateCopyFrame(
@ -83,8 +87,10 @@ class CefCopyFrameGenerator {
pending_damage_rect_.Union(damage_rect);
// 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;
}
frame_in_progress_ = true;
// Don't exceed the frame rate threshold.
@ -198,6 +204,14 @@ class CefCopyFrameGenerator {
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(
texture_mailbox.mailbox(),
texture_mailbox.sync_token(),
@ -293,6 +307,10 @@ class CefCopyFrameGenerator {
std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock) {
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++) {
// int x = static_cast<int>(pixels[i]);
// std::cout << std::hex << x << std::dec << std::endl;
@ -328,6 +346,8 @@ class CefCopyFrameGenerator {
int frame_rate_threshold_ms_;
OffScreenWindow* view_;
base::Time last_time_;
base::TimeTicks frame_start_time_;
bool frame_pending_;
bool frame_in_progress_;
@ -393,6 +413,8 @@ OffScreenWindow::OffScreenWindow(content::RenderWidgetHost* host)
// std::cout << "OffScreenWindow" << std::endl;
render_widget_host_->SetView(this);
last_time_ = base::Time::Now();
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
CreatePlatformWidget();
@ -406,6 +428,11 @@ OffScreenWindow::OffScreenWindow(content::RenderWidgetHost* host)
#endif
// compositor_->SetDelegate(this);
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() {
@ -614,7 +641,9 @@ bool OffScreenWindow::GetScreenColorProfile(std::vector<char>*) {
void OffScreenWindow::OnSwapCompositorFrame(
uint32_t output_surface_id,
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;
@ -622,9 +651,8 @@ void OffScreenWindow::OnSwapCompositorFrame(
last_scroll_offset_ = frame->metadata.root_scroll_offset;
}
if (!frame->delegated_frame_data) {
if (!frame->delegated_frame_data)
return;
}
if (software_output_device_) {
// if (!begin_frame_timer_.get()) {
@ -650,7 +678,6 @@ void OffScreenWindow::OnSwapCompositorFrame(
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
damage_rect.Intersect(gfx::Rect(frame_size));
if (frame->delegated_frame_data)
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
std::move(frame));
@ -887,10 +914,10 @@ void OffScreenWindow::OnSetNeedsBeginFrames(bool enabled) {
void OffScreenWindow::SetFrameRate() {
// Only set the frame rate one time.
if (frame_rate_threshold_ms_ != 0)
return;
// if (frame_rate_threshold_ms_ != 0)
// return;
const int frame_rate = 120;
const int frame_rate = 60;
frame_rate_threshold_ms_ = 1000 / frame_rate;
// Configure the VSync interval for the browser process.

View file

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

View file

@ -40,212 +40,212 @@ exports.load = (appUrl) => {
end1 = +new Date();
const d = end1 - start1
console.log(`browser #1: ${d < 10 ? ` ${d}` : d} ms`)
// console.log(`browser #1: ${d < 10 ? ` ${d}` : d} ms`)
start1 = end1
})
mainWindow2 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
nodeIntegration: false
}
})
mainWindow2.loadURL(appUrl)
mainWindow2.focus()
mainWindow2.webContents.on('dom-ready', () => {
mainWindow2.webContents.beginFrameSubscription(() => {
console.log("asd")
})
})
// mainWindow2 = new BrowserWindow({
// width: 800,
// height: 600,
// autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
// useContentSize: true,
// webPreferences: {
// nodeIntegration: false
// }
// })
// mainWindow2.loadURL(appUrl)
// mainWindow2.focus()
// mainWindow2.webContents.on('dom-ready', () => {
// mainWindow2.webContents.beginFrameSubscription(() => {
// 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
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
})
mainWindow5 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
nodeIntegration: false
}
})
mainWindow5.loadURL(appUrl)
mainWindow5.focus()
mainWindow5.webContents.on('dom-ready', () => {
mainWindow5.webContents.beginFrameSubscription(() => {
console.log("asd")
})
})
var start5, end5
start5 = +new Date();
mainWindow5.webContents.on('paint', (e, rect, w, h, data) => {
end5 = +new Date();
const d = end5 - start5
console.log(`browser #5: ${d < 10 ? ` ${d}` : d} ms`)
start5 = end5
})
mainWindow6 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
nodeIntegration: false
}
})
mainWindow6.loadURL(appUrl)
mainWindow6.focus()
mainWindow6.webContents.on('dom-ready', () => {
mainWindow6.webContents.beginFrameSubscription(() => {
console.log("asd")
})
})
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
})
// mainWindow5 = new BrowserWindow({
// width: 800,
// height: 600,
// autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
// useContentSize: true,
// webPreferences: {
// nodeIntegration: false
// }
// })
// mainWindow5.loadURL(appUrl)
// mainWindow5.focus()
// mainWindow5.webContents.on('dom-ready', () => {
// mainWindow5.webContents.beginFrameSubscription(() => {
// console.log("asd")
// })
// })
//
// var start5, end5
// start5 = +new Date();
// mainWindow5.webContents.on('paint', (e, rect, w, h, data) => {
// end5 = +new Date();
//
// const d = end5 - start5
// console.log(`browser #5: ${d < 10 ? ` ${d}` : d} ms`)
//
// start5 = end5
// })
//
// mainWindow6 = new BrowserWindow({
// width: 800,
// height: 600,
// autoHideMenuBar: true,
// backgroundColor: '#FFFFFF',
// useContentSize: true,
// webPreferences: {
// nodeIntegration: false
// }
// })
// mainWindow6.loadURL(appUrl)
// mainWindow6.focus()
// mainWindow6.webContents.on('dom-ready', () => {
// mainWindow6.webContents.beginFrameSubscription(() => {
// console.log("asd")
// })
// })
//
// 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
// })
})
}