Merge pull request #6713 from MaxWhere/offscreen-rendering-fixes
Fixes buffer size in offscreen mode
This commit is contained in:
commit
32d9382417
7 changed files with 20 additions and 9 deletions
|
@ -1345,11 +1345,18 @@ bool WebContents::IsOffScreen() const {
|
|||
|
||||
void WebContents::OnPaint(const gfx::Rect& dirty_rect,
|
||||
const gfx::Size& bitmap_size,
|
||||
int pixel_size,
|
||||
void* bitmap_pixels) {
|
||||
v8::MaybeLocal<v8::Object> buffer = node::Buffer::New(
|
||||
isolate(), reinterpret_cast<char*>(bitmap_pixels), sizeof(bitmap_pixels));
|
||||
v8::MaybeLocal<v8::Object> buffer = node::Buffer::Copy(
|
||||
isolate(), reinterpret_cast<char*>(bitmap_pixels),
|
||||
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());
|
||||
|
||||
if (!buffer.IsEmpty())
|
||||
Emit("paint", dirty_rect, buffer.ToLocalChecked(), bitmap_size);
|
||||
Emit("paint", dirty_rect, buffer.ToLocalChecked(), dict);
|
||||
}
|
||||
|
||||
void WebContents::StartPainting() {
|
||||
|
@ -1359,8 +1366,8 @@ void WebContents::StartPainting() {
|
|||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (osr_rwhv) {
|
||||
osr_rwhv->SetPainting(true);
|
||||
osr_rwhv->Show();
|
||||
osr_rwhv->SetPainting(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
bool IsOffScreen() const;
|
||||
void OnPaint(const gfx::Rect& dirty_rect,
|
||||
const gfx::Size& bitmap_size,
|
||||
const int pixel_size,
|
||||
void* bitmap_pixels);
|
||||
void StartPainting();
|
||||
void StopPainting();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue