Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ |
| 7 | 7 |
| 8 #include <IOSurface/IOSurface.h> | 8 #include <IOSurface/IOSurface.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 void EndPaint() override; | 35 void EndPaint() override; |
| 36 void DiscardBackbuffer() override; | 36 void DiscardBackbuffer() override; |
| 37 void EnsureBackbuffer() override; | 37 void EnsureBackbuffer() override; |
| 38 gfx::VSyncProvider* GetVSyncProvider() override; | 38 gfx::VSyncProvider* GetVSyncProvider() override; |
| 39 | 39 |
| 40 // gfx::VSyncProvider implementation. | 40 // gfx::VSyncProvider implementation. |
| 41 void GetVSyncParameters( | 41 void GetVSyncParameters( |
| 42 const gfx::VSyncProvider::UpdateVSyncCallback& callback) override; | 42 const gfx::VSyncProvider::UpdateVSyncCallback& callback) override; |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 bool EnsureBuffersExist(); | 45 // |
| 46 struct Buffer { | |
| 47 Buffer(); | |
| 48 ~Buffer(); | |
| 49 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; | |
| 50 // The damage of all BeginPaints since this buffer was the back buffer. | |
| 51 SkRegion accumulated_damage; | |
| 52 }; | |
| 46 | 53 |
| 47 // Copy the pixels from the previous buffer to the new buffer. | 54 // Copy the pixels from the previous buffer to the new buffer, and union |
| 48 void CopyPreviousBufferDamage(const SkRegion& new_damage_rect); | 55 // |new_damage_rect| into all |buffer_queue_|'s accumulated damages. |
| 56 void UpdateAndCopyBufferDamage(Buffer* previous_paint_buffer, | |
| 57 const SkRegion& new_damage_rect); | |
| 49 | 58 |
| 50 ui::Compositor* compositor_; | 59 ui::Compositor* compositor_ = nullptr; |
| 51 gfx::Size pixel_size_; | 60 gfx::Size pixel_size_; |
| 52 float scale_factor_; | 61 float scale_factor_ = 1; |
| 53 | 62 |
| 54 // This surface is double-buffered. The two buffers are in |io_surfaces_|, | 63 // This surface is double-buffered. The two buffers are in |io_surfaces_|, |
|
jbauman
2017/05/05 19:19:25
Fix comment.
ccameron
2017/05/05 22:06:08
Done.
| |
| 55 // and the index of the current buffer is |current_buffer_|. | 64 // and the index of the current buffer is |current_buffer_|. |
| 56 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces_[2]; | 65 std::list<std::unique_ptr<Buffer>> buffer_queue_; |
| 57 int current_index_; | |
| 58 | 66 |
| 59 // The previous frame's damage rectangle. Used to copy unchanged content | 67 // A pointer to the last element of |buffer_queue_| during paint. It is only |
| 60 // between buffers in CopyPreviousBufferDamage. | 68 // valid between BeginPaint and EndPaint. |
| 61 SkRegion previous_buffer_damage_region_; | 69 Buffer* current_paint_buffer_ = nullptr; |
| 62 | 70 |
| 63 // The SkCanvas wrapps the mapped current IOSurface. It is valid only between | 71 // The SkCanvas wraps the mapped |current_paint_buffer_|'s IOSurface. It is |
| 64 // BeginPaint and EndPaint. | 72 // valid only between BeginPaint and EndPaint. |
| 65 std::unique_ptr<SkCanvas> canvas_; | 73 std::unique_ptr<SkCanvas> current_paint_canvas_ = nullptr; |
| 66 | 74 |
| 67 gfx::VSyncProvider::UpdateVSyncCallback update_vsync_callback_; | 75 gfx::VSyncProvider::UpdateVSyncCallback update_vsync_callback_; |
| 68 | 76 |
| 69 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceMac); | 77 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceMac); |
| 70 }; | 78 }; |
| 71 | 79 |
| 72 } // namespace content | 80 } // namespace content |
| 73 | 81 |
| 74 #endif // CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ | 82 #endif // CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ |
| OLD | NEW |