Pass SkBitmap directly
This commit is contained in:
parent
530fcc8de1
commit
64334fd40b
7 changed files with 16 additions and 34 deletions
|
@ -1338,19 +1338,14 @@ bool WebContents::IsOffScreen() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnPaint(const gfx::Rect& dirty_rect,
|
void WebContents::OnPaint(const gfx::Rect& dirty_rect,
|
||||||
const gfx::Size& bitmap_size,
|
const SkBitmap& bitmap) {
|
||||||
int pixel_size,
|
|
||||||
void* bitmap_pixels) {
|
|
||||||
v8::MaybeLocal<v8::Object> buffer = node::Buffer::Copy(
|
v8::MaybeLocal<v8::Object> buffer = node::Buffer::Copy(
|
||||||
isolate(), reinterpret_cast<char*>(bitmap_pixels),
|
isolate(),
|
||||||
pixel_size * bitmap_size.width() * bitmap_size.height());
|
reinterpret_cast<char*>(bitmap.getPixels()), bitmap.getSize());
|
||||||
|
if (!buffer.IsEmpty()) {
|
||||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate());
|
Emit("paint", dirty_rect, buffer.ToLocalChecked(),
|
||||||
dict.Set("width", bitmap_size.width());
|
gfx::Size(bitmap.width(), bitmap.height()));
|
||||||
dict.Set("height", bitmap_size.height());
|
}
|
||||||
|
|
||||||
if (!buffer.IsEmpty())
|
|
||||||
Emit("paint", dirty_rect, buffer.ToLocalChecked(), dict);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::StartPainting() {
|
void WebContents::StartPainting() {
|
||||||
|
|
|
@ -158,10 +158,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
|
|
||||||
// Methods for offscreen rendering
|
// Methods for offscreen rendering
|
||||||
bool IsOffScreen() const;
|
bool IsOffScreen() const;
|
||||||
void OnPaint(const gfx::Rect& dirty_rect,
|
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
||||||
const gfx::Size& bitmap_size,
|
|
||||||
const int pixel_size,
|
|
||||||
void* bitmap_pixels);
|
|
||||||
void StartPainting();
|
void StartPainting();
|
||||||
void StopPainting();
|
void StopPainting();
|
||||||
bool IsPainting() const;
|
bool IsPainting() const;
|
||||||
|
|
|
@ -86,8 +86,7 @@ void OffScreenOutputDevice::OnPaint(const gfx::Rect& damage_rect) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SkAutoLockPixels bitmap_pixels_lock(*bitmap_);
|
SkAutoLockPixels bitmap_pixels_lock(*bitmap_);
|
||||||
callback_.Run(rect, gfx::Size(bitmap_->width(), bitmap_->height()),
|
callback_.Run(rect, *bitmap_);
|
||||||
bitmap_->bytesPerPixel(), bitmap_->getPixels());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
typedef base::Callback<void(const gfx::Rect&, const gfx::Size&,
|
typedef base::Callback<void(const gfx::Rect&, const SkBitmap&)> OnPaintCallback;
|
||||||
const int, void*)> OnPaintCallback;
|
|
||||||
|
|
||||||
class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
|
class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -260,9 +260,7 @@ class AtomCopyFrameGenerator {
|
||||||
const gfx::Rect& damage_rect,
|
const gfx::Rect& damage_rect,
|
||||||
const SkBitmap& bitmap,
|
const SkBitmap& bitmap,
|
||||||
std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock) {
|
std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock) {
|
||||||
view_->OnPaint(damage_rect,
|
view_->OnPaint(damage_rect, bitmap);
|
||||||
gfx::Size(bitmap.width(), bitmap.height()),
|
|
||||||
bitmap.bytesPerPixel(), bitmap.getPixels());
|
|
||||||
|
|
||||||
if (frame_retry_count_ > 0)
|
if (frame_retry_count_ > 0)
|
||||||
frame_retry_count_ = 0;
|
frame_retry_count_ = 0;
|
||||||
|
@ -756,7 +754,8 @@ std::unique_ptr<cc::SoftwareOutputDevice>
|
||||||
DCHECK(!copy_frame_generator_);
|
DCHECK(!copy_frame_generator_);
|
||||||
DCHECK(!software_output_device_);
|
DCHECK(!software_output_device_);
|
||||||
|
|
||||||
software_output_device_ = new OffScreenOutputDevice(transparent_,
|
software_output_device_ = new OffScreenOutputDevice(
|
||||||
|
transparent_,
|
||||||
base::Bind(&OffScreenRenderWidgetHostView::OnPaint,
|
base::Bind(&OffScreenRenderWidgetHostView::OnPaint,
|
||||||
weak_ptr_factory_.GetWeakPtr()));
|
weak_ptr_factory_.GetWeakPtr()));
|
||||||
return base::WrapUnique(software_output_device_);
|
return base::WrapUnique(software_output_device_);
|
||||||
|
@ -786,12 +785,9 @@ void OffScreenRenderWidgetHostView::OnSetNeedsBeginFrames(bool enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::OnPaint(
|
void OffScreenRenderWidgetHostView::OnPaint(
|
||||||
const gfx::Rect& damage_rect,
|
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
|
||||||
const gfx::Size& bitmap_size,
|
|
||||||
int pixel_size,
|
|
||||||
void* bitmap_pixels) {
|
|
||||||
TRACE_EVENT0("electron", "OffScreenRenderWidgetHostView::OnPaint");
|
TRACE_EVENT0("electron", "OffScreenRenderWidgetHostView::OnPaint");
|
||||||
callback_.Run(damage_rect, bitmap_size, pixel_size, bitmap_pixels);
|
callback_.Run(damage_rect, bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::SetPainting(bool painting) {
|
void OffScreenRenderWidgetHostView::SetPainting(bool painting) {
|
||||||
|
|
|
@ -190,10 +190,7 @@ class OffScreenRenderWidgetHostView
|
||||||
void DestroyPlatformWidget();
|
void DestroyPlatformWidget();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void OnPaint(const gfx::Rect& damage_rect,
|
void OnPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
|
||||||
const gfx::Size& bitmap_size,
|
|
||||||
int pixel_size,
|
|
||||||
void* bitmap_pixels);
|
|
||||||
|
|
||||||
void SetPainting(bool painting);
|
void SetPainting(bool painting);
|
||||||
bool IsPainting() const;
|
bool IsPainting() const;
|
||||||
|
|
|
@ -471,7 +471,6 @@ Returns:
|
||||||
* `bitmapSize` Object
|
* `bitmapSize` Object
|
||||||
* `width` Number - the width of the whole bitmap
|
* `width` Number - the width of the whole bitmap
|
||||||
* `height` Number - the height of the whole bitmap
|
* `height` Number - the height of the whole bitmap
|
||||||
* `bytesPerPixel` Number - The number of bytes per pixel in the bitmap
|
|
||||||
|
|
||||||
Emitted when a new frame is generated. Only the dirty area is passed in the
|
Emitted when a new frame is generated. Only the dirty area is passed in the
|
||||||
buffer.
|
buffer.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue