Index: content/renderer/gpu/compositor_software_output_device.h |
diff --git a/content/renderer/gpu/compositor_software_output_device.h b/content/renderer/gpu/compositor_software_output_device.h |
index b82ffe2dd5463940ef2d8f60a3885bfc4deda332..49b90c2010044f64a677d9ef35a05bb1cdad9f93 100644 |
--- a/content/renderer/gpu/compositor_software_output_device.h |
+++ b/content/renderer/gpu/compositor_software_output_device.h |
@@ -5,11 +5,16 @@ |
#ifndef CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ |
#define CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ |
+#include "base/memory/scoped_ptr.h" |
#include "base/memory/scoped_vector.h" |
+#include "base/memory/shared_memory.h" |
#include "base/threading/non_thread_safe.h" |
#include "cc/output/software_output_device.h" |
+#include "content/public/renderer/render_thread.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
+class SkRegion; |
+ |
namespace content { |
// This class can be created only on the main thread, but then becomes pinned |
@@ -26,43 +31,63 @@ public: |
virtual SkCanvas* BeginPaint(gfx::Rect damage_rect) OVERRIDE; |
virtual void EndPaint(cc::SoftwareFrameData* frame_data) OVERRIDE; |
- virtual void ReclaimDIB(const TransportDIB::Id& id) OVERRIDE; |
+ virtual void ReclaimSoftwareFrame(unsigned id) OVERRIDE; |
private: |
- class DIB { |
+ // Internal buffer class that manages shared memory lifetime and ownership. |
+ // It also tracks buffers' history so we can calculate what's the minimum |
+ // damage rect difference between any two given buffers (see SetParent and |
+ // FindDamageDifferenceFrom). |
+ class Buffer { |
public: |
- explicit DIB(size_t size); |
- ~DIB(); |
+ explicit Buffer(unsigned id, scoped_ptr<base::SharedMemory> mem); |
+ ~Buffer(); |
- TransportDIB* dib() const { |
- return dib_; |
- } |
+ unsigned id() const { return id_; } |
+ |
+ void* memory() const { return mem_->memory(); } |
+ base::SharedMemoryHandle handle() const { return mem_->handle(); } |
+ |
+ bool free() const { return free_; } |
+ void SetFree(bool free) { free_ = free; } |
+ |
+ Buffer* parent() const { return parent_; } |
+ void SetParent(Buffer* parent, const gfx::Rect& damage); |
+ |
+ bool FindDamageDifferenceFrom(Buffer* buffer, SkRegion* result) const; |
private: |
- TransportDIB* dib_; |
+ const unsigned id_; |
+ scoped_ptr<base::SharedMemory> mem_; |
+ bool free_; |
+ Buffer* parent_; |
+ gfx::Rect damage_; |
- DISALLOW_COPY_AND_ASSIGN(DIB); |
+ DISALLOW_COPY_AND_ASSIGN(Buffer); |
}; |
class CompareById { |
public: |
- CompareById(const TransportDIB::Id& id) : id_(id) {} |
+ CompareById(unsigned id) : id_(id) {} |
- bool operator()(const DIB* dib) const { |
- return dib->dib() && dib->dib()->id() == id_; |
+ bool operator()(const Buffer* buffer) const { |
+ return buffer->id() == id_; |
} |
private: |
- TransportDIB::Id id_; |
+ const unsigned id_; |
}; |
- DIB* CreateDIB(); |
+ unsigned GetNextId(); |
+ Buffer* CreateBuffer(); |
+ size_t FindFreeBuffer(size_t hint); |
- int front_buffer_; |
- int num_free_buffers_; |
- ScopedVector<DIB> dibs_; |
- ScopedVector<DIB> awaiting_ack_; |
+ size_t current_index_; |
+ unsigned next_buffer_id_; |
+ ScopedVector<Buffer> buffers_; |
+ ScopedVector<Buffer> awaiting_ack_; |
SkBitmap bitmap_; |
+ RenderThread* render_thread_; |
}; |
} // namespace content |