diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 762e8bb7289f..203dd9d42617 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -281,6 +281,8 @@ class WebContents : public mate::TrackableObject, private: AtomBrowserContext* GetBrowserContext() const; + atom::OnPaintCallback paint_callback_; + uint32_t GetNextRequestId() { return ++request_id_; } diff --git a/atom/browser/osr_output_device.cc b/atom/browser/osr_output_device.cc index d2b338414cec..8e6b5b02a9dd 100644 --- a/atom/browser/osr_output_device.cc +++ b/atom/browser/osr_output_device.cc @@ -10,23 +10,18 @@ namespace atom { -OffScreenOutputDevice::OffScreenOutputDevice(const OnPaintCallback& callback) - : callback_(callback), +OffScreenOutputDevice::OffScreenOutputDevice(bool transparent, + const OnPaintCallback& callback) + : transparent_(transparent), + callback_(callback), active_(false) { DCHECK(!callback_.is_null()); } -OffScreenOutputDevice::~OffScreenOutputDevice() { - std::cout << "~OffScreenOutputDevice" << std::endl; -} - -void OffScreenOutputDevice::SetPaintCallback(const OnPaintCallback* callback) { - callback_.reset(callback); -} +OffScreenOutputDevice::~OffScreenOutputDevice() { } void OffScreenOutputDevice::Resize( const gfx::Size& pixel_size, float scale_factor) { - std::cout << "Resize" << std::endl; std::cout << pixel_size.width() << "x" << pixel_size.height() << std::endl; scale_factor_ = scale_factor; @@ -38,14 +33,15 @@ void OffScreenOutputDevice::Resize( bitmap_.reset(new SkBitmap); bitmap_->allocN32Pixels(viewport_pixel_size_.width(), viewport_pixel_size_.height(), - false); + !transparent_); if (bitmap_->drawsNothing()) { - std::cout << "drawsNothing" << std::endl; NOTREACHED(); bitmap_.reset(NULL); return; } - bitmap_->eraseARGB(0, 0, 0, 0); + + if (transparent_) + bitmap_->eraseARGB(0, 0, 0, 0); canvas_.reset(new SkCanvas(*bitmap_.get())); } diff --git a/atom/browser/osr_output_device.h b/atom/browser/osr_output_device.h index f0e44aff7265..71342e25409c 100644 --- a/atom/browser/osr_output_device.h +++ b/atom/browser/osr_output_device.h @@ -12,7 +12,7 @@ #include "base/callback.h" namespace atom { - + typedef base::Callback OnPaintCallback; class OffScreenOutputDevice : public cc::SoftwareOutputDevice { @@ -20,25 +20,21 @@ public: typedef base::Callback OnPaintCallback; - OffScreenOutputDevice(const OnPaintCallback& callback); + OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback); ~OffScreenOutputDevice(); - - void SetPaintCallback(const OnPaintCallback*); - // void saveSkBitmapToBMPFile(const SkBitmap& skBitmap, const char* path); void Resize(const gfx::Size& pixel_size, float scale_factor) override; SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override; void EndPaint() override; - - void OnPaint(const gfx::Rect& damage_rect); void SetActive(bool active); void OnPaint(const gfx::Rect& damage_rect); private: + const bool transparent_; const OnPaintCallback callback_; bool active_; @@ -46,8 +42,6 @@ private: std::unique_ptr canvas_; std::unique_ptr bitmap_; gfx::Rect pending_damage_rect_; - - std::unique_ptr callback_; DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice); }; diff --git a/atom/browser/osr_window.cc b/atom/browser/osr_window.cc index 0f41db584f58..bef3b65edba6 100644 --- a/atom/browser/osr_window.cc +++ b/atom/browser/osr_window.cc @@ -309,7 +309,6 @@ class CefCopyFrameGenerator { uint8_t* pixels = reinterpret_cast(bitmap.getPixels()); - std::cout << "ASDADASDA" << std::endl; view_->OnPaint(damage_rect, bitmap.width(), bitmap.height(), pixels); // Reset the frame retry count on successful frame generation. @@ -476,8 +475,6 @@ void OffScreenWindow::SendBeginFrame(base::TimeTicks frame_time, void OffScreenWindow::SetPaintCallback(const OnPaintCallback* callback) { paintCallback.reset(callback); - if (software_output_device_) - software_output_device_->SetPaintCallback(paintCallback.get()); } OffScreenWindow::~OffScreenWindow() { @@ -880,8 +877,8 @@ std::unique_ptr DCHECK_EQ(compositor_.get(), compositor); DCHECK(!copy_frame_generator_); DCHECK(!software_output_device_); - std::cout << "CREATEEEEE" << std::endl; - software_output_device_ = new OffScreenOutputDevice( + + software_output_device_ = new OffScreenOutputDevice(true, base::Bind(&OffScreenWindow::OnPaint, weak_ptr_factory_.GetWeakPtr())); return base::WrapUnique(software_output_device_);