| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ | 5 #ifndef CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ |
| 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ | 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 12 #include "cc/output/software_output_device.h" | 12 #include "cc/output/software_output_device.h" |
| 13 #include "cc/resources/shared_bitmap.h" | 13 #include "cc/resources/shared_bitmap.h" |
| 14 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 | 16 |
| 17 class SkRegion; | 17 class SkRegion; |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 class SharedBitmapManager; | 20 class SharedBitmapManager; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 // This class can be created only on the main thread, but then becomes pinned | 25 // This class can be created only on the main thread, but then becomes pinned |
| 26 // to a fixed thread when BindToClient is called. | 26 // to a fixed thread when BindToClient is called. |
| 27 class CompositorSoftwareOutputDevice | 27 class CompositorSoftwareOutputDevice |
| 28 : NON_EXPORTED_BASE(public cc::SoftwareOutputDevice), | 28 : NON_EXPORTED_BASE(public cc::SoftwareOutputDevice), |
| 29 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 29 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 30 public: | 30 public: |
| 31 CompositorSoftwareOutputDevice(); | 31 CompositorSoftwareOutputDevice(); |
| 32 virtual ~CompositorSoftwareOutputDevice(); | 32 virtual ~CompositorSoftwareOutputDevice(); |
| 33 | 33 |
| 34 virtual void Resize(const gfx::Size& pixel_size, float scale_factor) OVERRIDE; | 34 virtual void Resize(const gfx::Size& pixel_size, float scale_factor) OVERRIDE; |
| 35 | 35 |
| 36 virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect) OVERRIDE; | 36 virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect) OVERRIDE; |
| 37 virtual void EndPaint(cc::SoftwareFrameData* frame_data) OVERRIDE; | 37 virtual void EndPaint(cc::SoftwareFrameData* frame_data) OVERRIDE; |
| 38 virtual void EnsureBackbuffer() OVERRIDE; | 38 virtual void EnsureBackbuffer() OVERRIDE; |
| 39 virtual void DiscardBackbuffer() OVERRIDE; | 39 virtual void DiscardBackbuffer() OVERRIDE; |
| 40 | 40 |
| 41 virtual void ReclaimSoftwareFrame(unsigned id) OVERRIDE; | 41 virtual void ReclaimSoftwareFrame(unsigned id) OVERRIDE; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // Internal buffer class that manages shared memory lifetime and ownership. | 44 // Internal buffer class that manages shared memory lifetime and ownership. |
| 45 // It also tracks buffers' history so we can calculate what's the minimum | 45 // It also tracks buffers' history so we can calculate what's the minimum |
| 46 // damage rect difference between any two given buffers (see SetParent and | 46 // damage rect difference between any two given buffers (see SetParent and |
| 47 // FindDamageDifferenceFrom). | 47 // FindDamageDifferenceFrom). |
| 48 class Buffer { | 48 class Buffer { |
| 49 public: | 49 public: |
| 50 explicit Buffer(unsigned id, scoped_ptr<cc::SharedBitmap> bitmap); | 50 explicit Buffer(unsigned id, scoped_ptr<cc::SharedBitmap> bitmap); |
| 51 ~Buffer(); | 51 ~Buffer(); |
| 52 | 52 |
| 53 unsigned id() const { return id_; } | 53 unsigned id() const { return id_; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 size_t current_index_; | 92 size_t current_index_; |
| 93 unsigned next_buffer_id_; | 93 unsigned next_buffer_id_; |
| 94 ScopedVector<Buffer> buffers_; | 94 ScopedVector<Buffer> buffers_; |
| 95 ScopedVector<Buffer> awaiting_ack_; | 95 ScopedVector<Buffer> awaiting_ack_; |
| 96 cc::SharedBitmapManager* shared_bitmap_manager_; | 96 cc::SharedBitmapManager* shared_bitmap_manager_; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 } // namespace content | 99 } // namespace content |
| 100 | 100 |
| 101 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ | 101 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ |
| OLD | NEW |