| 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> |
| 9 |
| 10 #include "base/mac/scoped_cftyperef.h" |
| 8 #include "cc/output/software_output_device.h" | 11 #include "cc/output/software_output_device.h" |
| 12 #include "third_party/skia/include/core/SkRegion.h" |
| 9 | 13 |
| 10 namespace gfx { | 14 namespace gfx { |
| 11 class Canvas; | 15 class Canvas; |
| 12 } | 16 } |
| 13 | 17 |
| 14 namespace ui { | 18 namespace ui { |
| 15 class Compositor; | 19 class Compositor; |
| 16 } | 20 } |
| 17 | 21 |
| 18 namespace content { | 22 namespace content { |
| 19 | 23 |
| 20 class SoftwareOutputDeviceMac : public cc::SoftwareOutputDevice { | 24 class SoftwareOutputDeviceMac : public cc::SoftwareOutputDevice { |
| 21 public: | 25 public: |
| 22 explicit SoftwareOutputDeviceMac(ui::Compositor* compositor); | 26 explicit SoftwareOutputDeviceMac(ui::Compositor* compositor); |
| 23 ~SoftwareOutputDeviceMac() override; | 27 ~SoftwareOutputDeviceMac() override; |
| 24 | 28 |
| 29 void Resize(const gfx::Size& pixel_size, float scale_factor) override; |
| 30 SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override; |
| 25 void EndPaint() override; | 31 void EndPaint() override; |
| 32 void DiscardBackbuffer() override; |
| 33 void EnsureBackbuffer() override; |
| 26 | 34 |
| 27 private: | 35 private: |
| 36 bool EnsureBuffersExist(); |
| 37 |
| 38 // Copy the pixels from the previous buffer to the new buffer. |
| 39 void CopyPreviousBufferDamage(const SkRegion& new_damage_rect); |
| 40 |
| 28 ui::Compositor* compositor_; | 41 ui::Compositor* compositor_; |
| 42 gfx::Size pixel_size_; |
| 43 float scale_factor_; |
| 44 |
| 45 // This surface is double-buffered. The two buffers are in |io_surfaces_|, |
| 46 // and the index of the current buffer is |current_buffer_|. |
| 47 base::ScopedCFTypeRef<IOSurfaceRef> io_surfaces_[2]; |
| 48 int current_index_; |
| 49 |
| 50 // The previous frame's damage rectangle. Used to copy unchanged content |
| 51 // between buffers in CopyPreviousBufferDamage. |
| 52 SkRegion previous_buffer_damage_region_; |
| 53 |
| 54 // The SkCanvas wrapps the mapped current IOSurface. It is valid only between |
| 55 // BeginPaint and EndPaint. |
| 56 skia::RefPtr<SkCanvas> canvas_; |
| 29 | 57 |
| 30 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceMac); | 58 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceMac); |
| 31 }; | 59 }; |
| 32 | 60 |
| 33 } // namespace content | 61 } // namespace content |
| 34 | 62 |
| 35 #endif // CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ | 63 #endif // CONTENT_BROWSER_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_MAC_H_ |
| OLD | NEW |