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,
|
||||
const gfx::Size& bitmap_size,
|
||||
int pixel_size,
|
||||
void* bitmap_pixels) {
|
||||
const SkBitmap& bitmap) {
|
||||
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(), dict);
|
||||
isolate(),
|
||||
reinterpret_cast<char*>(bitmap.getPixels()), bitmap.getSize());
|
||||
if (!buffer.IsEmpty()) {
|
||||
Emit("paint", dirty_rect, buffer.ToLocalChecked(),
|
||||
gfx::Size(bitmap.width(), bitmap.height()));
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::StartPainting() {
|
||||
|
|
|
@ -158,10 +158,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
|
||||
// Methods for offscreen rendering
|
||||
bool IsOffScreen() const;
|
||||
void OnPaint(const gfx::Rect& dirty_rect,
|
||||
const gfx::Size& bitmap_size,
|
||||
const int pixel_size,
|
||||
void* bitmap_pixels);
|
||||
void OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap);
|
||||
void StartPainting();
|
||||
void StopPainting();
|
||||
bool IsPainting() const;
|
||||
|
|
|
@ -86,8 +86,7 @@ void OffScreenOutputDevice::OnPaint(const gfx::Rect& damage_rect) {
|
|||
return;
|
||||
|
||||
SkAutoLockPixels bitmap_pixels_lock(*bitmap_);
|
||||
callback_.Run(rect, gfx::Size(bitmap_->width(), bitmap_->height()),
|
||||
bitmap_->bytesPerPixel(), bitmap_->getPixels());
|
||||
callback_.Run(rect, *bitmap_);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
typedef base::Callback<void(const gfx::Rect&, const gfx::Size&,
|
||||
const int, void*)> OnPaintCallback;
|
||||
typedef base::Callback<void(const gfx::Rect&, const SkBitmap&)> OnPaintCallback;
|
||||
|
||||
class OffScreenOutputDevice : public cc::SoftwareOutputDevice {
|
||||
public:
|
||||
|
|
|
@ -260,9 +260,7 @@ class AtomCopyFrameGenerator {
|
|||
const gfx::Rect& damage_rect,
|
||||
const SkBitmap& bitmap,
|
||||
std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock) {
|
||||
view_->OnPaint(damage_rect,
|
||||
gfx::Size(bitmap.width(), bitmap.height()),
|
||||
bitmap.bytesPerPixel(), bitmap.getPixels());
|
||||
view_->OnPaint(damage_rect, bitmap);
|
||||
|
||||
if (frame_retry_count_ > 0)
|
||||
frame_retry_count_ = 0;
|
||||
|
@ -756,7 +754,8 @@ std::unique_ptr<cc::SoftwareOutputDevice>
|
|||
DCHECK(!copy_frame_generator_);
|
||||
DCHECK(!software_output_device_);
|
||||
|
||||
software_output_device_ = new OffScreenOutputDevice(transparent_,
|
||||
software_output_device_ = new OffScreenOutputDevice(
|
||||
transparent_,
|
||||
base::Bind(&OffScreenRenderWidgetHostView::OnPaint,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
return base::WrapUnique(software_output_device_);
|
||||
|
@ -786,12 +785,9 @@ void OffScreenRenderWidgetHostView::OnSetNeedsBeginFrames(bool enabled) {
|
|||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::OnPaint(
|
||||
const gfx::Rect& damage_rect,
|
||||
const gfx::Size& bitmap_size,
|
||||
int pixel_size,
|
||||
void* bitmap_pixels) {
|
||||
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
|
||||
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) {
|
||||
|
|
|
@ -190,10 +190,7 @@ class OffScreenRenderWidgetHostView
|
|||
void DestroyPlatformWidget();
|
||||
#endif
|
||||
|
||||
void OnPaint(const gfx::Rect& damage_rect,
|
||||
const gfx::Size& bitmap_size,
|
||||
int pixel_size,
|
||||
void* bitmap_pixels);
|
||||
void OnPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
|
||||
|
||||
void SetPainting(bool painting);
|
||||
bool IsPainting() const;
|
||||
|
|
|
@ -471,7 +471,6 @@ Returns:
|
|||
* `bitmapSize` Object
|
||||
* `width` Number - the width 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
|
||||
buffer.
|
||||
|
|
Loading…
Reference in a new issue