apply fixes
This commit is contained in:
		
					parent
					
						
							
								6e1db86a77
							
						
					
				
			
			
				commit
				
					
						f90e62a7a5
					
				
			
		
					 4 changed files with 16 additions and 27 deletions
				
			
		|  | @ -281,6 +281,8 @@ class WebContents : public mate::TrackableObject<WebContents>, | ||||||
|  private: |  private: | ||||||
|   AtomBrowserContext* GetBrowserContext() const; |   AtomBrowserContext* GetBrowserContext() const; | ||||||
| 
 | 
 | ||||||
|  |   atom::OnPaintCallback paint_callback_; | ||||||
|  | 
 | ||||||
|   uint32_t GetNextRequestId() { |   uint32_t GetNextRequestId() { | ||||||
|     return ++request_id_; |     return ++request_id_; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -10,23 +10,18 @@ | ||||||
| 
 | 
 | ||||||
| namespace atom { | namespace atom { | ||||||
| 
 | 
 | ||||||
| OffScreenOutputDevice::OffScreenOutputDevice(const OnPaintCallback& callback) | OffScreenOutputDevice::OffScreenOutputDevice(bool transparent, | ||||||
|     : callback_(callback), |   const OnPaintCallback& callback) | ||||||
|  |     : transparent_(transparent), | ||||||
|  |       callback_(callback), | ||||||
|       active_(false) { |       active_(false) { | ||||||
|   DCHECK(!callback_.is_null()); |   DCHECK(!callback_.is_null()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| OffScreenOutputDevice::~OffScreenOutputDevice() { | OffScreenOutputDevice::~OffScreenOutputDevice() { } | ||||||
|   std::cout << "~OffScreenOutputDevice" << std::endl; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void OffScreenOutputDevice::SetPaintCallback(const OnPaintCallback* callback) { |  | ||||||
|   callback_.reset(callback); |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| void OffScreenOutputDevice::Resize( | void OffScreenOutputDevice::Resize( | ||||||
|   const gfx::Size& pixel_size, float scale_factor) { |   const gfx::Size& pixel_size, float scale_factor) { | ||||||
|   std::cout << "Resize" << std::endl; |  | ||||||
|   std::cout << pixel_size.width() << "x" << pixel_size.height() << std::endl; |   std::cout << pixel_size.width() << "x" << pixel_size.height() << std::endl; | ||||||
| 
 | 
 | ||||||
|   scale_factor_ = scale_factor; |   scale_factor_ = scale_factor; | ||||||
|  | @ -38,14 +33,15 @@ void OffScreenOutputDevice::Resize( | ||||||
|   bitmap_.reset(new SkBitmap); |   bitmap_.reset(new SkBitmap); | ||||||
|   bitmap_->allocN32Pixels(viewport_pixel_size_.width(), |   bitmap_->allocN32Pixels(viewport_pixel_size_.width(), | ||||||
|                           viewport_pixel_size_.height(), |                           viewport_pixel_size_.height(), | ||||||
|                           false); |                           !transparent_); | ||||||
|   if (bitmap_->drawsNothing()) { |   if (bitmap_->drawsNothing()) { | ||||||
|     std::cout << "drawsNothing" << std::endl; |  | ||||||
|     NOTREACHED(); |     NOTREACHED(); | ||||||
|     bitmap_.reset(NULL); |     bitmap_.reset(NULL); | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|   bitmap_->eraseARGB(0, 0, 0, 0); | 
 | ||||||
|  |   if (transparent_) | ||||||
|  |     bitmap_->eraseARGB(0, 0, 0, 0); | ||||||
| 
 | 
 | ||||||
|   canvas_.reset(new SkCanvas(*bitmap_.get())); |   canvas_.reset(new SkCanvas(*bitmap_.get())); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| #include "base/callback.h" | #include "base/callback.h" | ||||||
| 
 | 
 | ||||||
| namespace atom { | namespace atom { | ||||||
|    | 
 | ||||||
| typedef base::Callback<void(const gfx::Rect&,int,int,void*)> OnPaintCallback; | typedef base::Callback<void(const gfx::Rect&,int,int,void*)> OnPaintCallback; | ||||||
| 
 | 
 | ||||||
| class OffScreenOutputDevice : public cc::SoftwareOutputDevice { | class OffScreenOutputDevice : public cc::SoftwareOutputDevice { | ||||||
|  | @ -20,25 +20,21 @@ public: | ||||||
|   typedef base::Callback<void(const gfx::Rect&,int,int,void*)> |   typedef base::Callback<void(const gfx::Rect&,int,int,void*)> | ||||||
|       OnPaintCallback; |       OnPaintCallback; | ||||||
| 
 | 
 | ||||||
|   OffScreenOutputDevice(const OnPaintCallback& callback); |   OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback); | ||||||
|   ~OffScreenOutputDevice(); |   ~OffScreenOutputDevice(); | ||||||
|    |  | ||||||
|   void SetPaintCallback(const OnPaintCallback*); |  | ||||||
| 
 | 
 | ||||||
|   // void saveSkBitmapToBMPFile(const SkBitmap& skBitmap, const char* path);
 |  | ||||||
|   void Resize(const gfx::Size& pixel_size, float scale_factor) override; |   void Resize(const gfx::Size& pixel_size, float scale_factor) override; | ||||||
| 
 | 
 | ||||||
|   SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override; |   SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override; | ||||||
| 
 | 
 | ||||||
|   void EndPaint() override; |   void EndPaint() override; | ||||||
|    |  | ||||||
|   void OnPaint(const gfx::Rect& damage_rect); |  | ||||||
| 
 | 
 | ||||||
|   void SetActive(bool active); |   void SetActive(bool active); | ||||||
| 
 | 
 | ||||||
|   void OnPaint(const gfx::Rect& damage_rect); |   void OnPaint(const gfx::Rect& damage_rect); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  |   const bool transparent_; | ||||||
|   const OnPaintCallback callback_; |   const OnPaintCallback callback_; | ||||||
| 
 | 
 | ||||||
|   bool active_; |   bool active_; | ||||||
|  | @ -46,8 +42,6 @@ private: | ||||||
|   std::unique_ptr<SkCanvas> canvas_; |   std::unique_ptr<SkCanvas> canvas_; | ||||||
|   std::unique_ptr<SkBitmap> bitmap_; |   std::unique_ptr<SkBitmap> bitmap_; | ||||||
|   gfx::Rect pending_damage_rect_; |   gfx::Rect pending_damage_rect_; | ||||||
|    |  | ||||||
|   std::unique_ptr<const atom::OnPaintCallback> callback_; |  | ||||||
| 
 | 
 | ||||||
|   DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice); |   DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -309,7 +309,6 @@ class CefCopyFrameGenerator { | ||||||
| 
 | 
 | ||||||
|     uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels()); |     uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels()); | ||||||
| 
 | 
 | ||||||
|     std::cout << "ASDADASDA" << std::endl; |  | ||||||
|     view_->OnPaint(damage_rect, bitmap.width(), bitmap.height(), pixels); |     view_->OnPaint(damage_rect, bitmap.width(), bitmap.height(), pixels); | ||||||
| 
 | 
 | ||||||
|     // Reset the frame retry count on successful frame generation.
 |     // 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) { | void OffScreenWindow::SetPaintCallback(const OnPaintCallback* callback) { | ||||||
|   paintCallback.reset(callback); |   paintCallback.reset(callback); | ||||||
|   if (software_output_device_)  |  | ||||||
|     software_output_device_->SetPaintCallback(paintCallback.get()); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| OffScreenWindow::~OffScreenWindow() { | OffScreenWindow::~OffScreenWindow() { | ||||||
|  | @ -880,8 +877,8 @@ std::unique_ptr<cc::SoftwareOutputDevice> | ||||||
|   DCHECK_EQ(compositor_.get(), compositor); |   DCHECK_EQ(compositor_.get(), compositor); | ||||||
|   DCHECK(!copy_frame_generator_); |   DCHECK(!copy_frame_generator_); | ||||||
|   DCHECK(!software_output_device_); |   DCHECK(!software_output_device_); | ||||||
|   std::cout << "CREATEEEEE" << std::endl; | 
 | ||||||
|   software_output_device_ = new OffScreenOutputDevice( |   software_output_device_ = new OffScreenOutputDevice(true, | ||||||
|       base::Bind(&OffScreenWindow::OnPaint, |       base::Bind(&OffScreenWindow::OnPaint, | ||||||
|                  weak_ptr_factory_.GetWeakPtr())); |                  weak_ptr_factory_.GetWeakPtr())); | ||||||
|   return base::WrapUnique(software_output_device_); |   return base::WrapUnique(software_output_device_); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 gellert
				gellert