Move OSR api to OsrWCV to allow api calls to take effect sooner
This commit is contained in:
parent
1a8916ed47
commit
406f171c88
6 changed files with 105 additions and 25 deletions
|
@ -378,8 +378,8 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
|||
options.Get("transparent", &transparent);
|
||||
|
||||
content::WebContents::CreateParams params(session->browser_context());
|
||||
auto* view = new OffScreenWebContentsView(
|
||||
transparent, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||
auto* view = new OffScreenWebContentsView(transparent,
|
||||
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||
params.view = view;
|
||||
params.delegate_view = view;
|
||||
|
||||
|
@ -1652,10 +1652,14 @@ void WebContents::StartPainting() {
|
|||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->SetPainting(true);
|
||||
const auto* wc_impl = web_contents_impl();
|
||||
if (!wc_impl)
|
||||
return;
|
||||
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
|
||||
wc_impl->GetView());
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetPainting(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1664,10 +1668,14 @@ void WebContents::StopPainting() {
|
|||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->SetPainting(false);
|
||||
const auto* wc_impl = web_contents_impl();
|
||||
if (!wc_impl)
|
||||
return;
|
||||
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
|
||||
wc_impl->GetView());
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetPainting(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1676,9 +1684,13 @@ bool WebContents::IsPainting() const {
|
|||
return false;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
const auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
return osr_rwhv && osr_rwhv->IsPainting();
|
||||
const auto* wc_impl = web_contents_impl();
|
||||
if (!wc_impl)
|
||||
return false;
|
||||
|
||||
const auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
|
||||
wc_impl->GetView());
|
||||
return osr_wcv && osr_wcv->IsPainting();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -1689,10 +1701,14 @@ void WebContents::SetFrameRate(int frame_rate) {
|
|||
return;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv)
|
||||
osr_rwhv->SetFrameRate(frame_rate);
|
||||
const auto* wc_impl = web_contents_impl();
|
||||
if (!wc_impl)
|
||||
return;
|
||||
|
||||
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
|
||||
wc_impl->GetView());
|
||||
if (osr_wcv)
|
||||
osr_wcv->SetFrameRate(frame_rate);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1701,9 +1717,13 @@ int WebContents::GetFrameRate() const {
|
|||
return 0;
|
||||
|
||||
#if defined(ENABLE_OSR)
|
||||
const auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
return osr_rwhv ? osr_rwhv->GetFrameRate() : 0;
|
||||
const auto* wc_impl = web_contents_impl();
|
||||
if (!wc_impl)
|
||||
return 0;
|
||||
|
||||
const auto* osr_wcv = static_cast<OffScreenWebContentsView*>(
|
||||
wc_impl->GetView());
|
||||
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue