Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: content/renderer/gpu/compositor_software_output_device.h

Issue 15001027: [Aura] Added Support for rendering software compositor frames as cc::TextureLayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/memory/shared_memory.h"
9 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
10 #include "cc/output/software_output_device.h" 12 #include "cc/output/software_output_device.h"
13 #include "content/public/renderer/render_thread.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
12 15
16 class SkRegion;
17
13 namespace content { 18 namespace content {
14 19
15 // This class can be created only on the main thread, but then becomes pinned 20 // This class can be created only on the main thread, but then becomes pinned
16 // to a fixed thread when BindToClient is called. 21 // to a fixed thread when BindToClient is called.
17 class CompositorSoftwareOutputDevice 22 class CompositorSoftwareOutputDevice
18 : NON_EXPORTED_BASE(public cc::SoftwareOutputDevice), 23 : NON_EXPORTED_BASE(public cc::SoftwareOutputDevice),
19 NON_EXPORTED_BASE(public base::NonThreadSafe) { 24 NON_EXPORTED_BASE(public base::NonThreadSafe) {
20 public: 25 public:
21 CompositorSoftwareOutputDevice(); 26 CompositorSoftwareOutputDevice();
22 virtual ~CompositorSoftwareOutputDevice(); 27 virtual ~CompositorSoftwareOutputDevice();
23 28
24 virtual void Resize(gfx::Size size) OVERRIDE; 29 virtual void Resize(gfx::Size size) OVERRIDE;
25 30
26 virtual SkCanvas* BeginPaint(gfx::Rect damage_rect) OVERRIDE; 31 virtual SkCanvas* BeginPaint(gfx::Rect damage_rect) OVERRIDE;
27 virtual void EndPaint(cc::SoftwareFrameData* frame_data) OVERRIDE; 32 virtual void EndPaint(cc::SoftwareFrameData* frame_data) OVERRIDE;
28 33
29 virtual void ReclaimDIB(const TransportDIB::Id& id) OVERRIDE; 34 virtual void ReclaimSoftwareFrame(int id) OVERRIDE;
30 35
31 private: 36 private:
32 class DIB { 37 class Buffer {
33 public: 38 public:
34 explicit DIB(size_t size); 39 explicit Buffer(int id, scoped_ptr<base::SharedMemory> mem);
35 ~DIB(); 40 ~Buffer();
36 41
37 TransportDIB* dib() const { 42 int id() const { return id_; }
38 return dib_; 43
39 } 44 void* memory() const { return mem_->memory(); }
45 base::SharedMemoryHandle handle() const { return mem_->handle(); }
46
47 bool free() const { return free_; }
48 void SetFree(bool free) { free_ = free; }
49
50 Buffer* parent() const { return parent_; }
51 void SetParent(Buffer* parent, const gfx::Rect& damage);
piman 2013/05/28 20:58:57 The "parenting" relationship could use an explanat
slavi 2013/05/29 18:31:48 Done.
52
53 bool FindDamageDifferenceFrom(Buffer* buffer, SkRegion* result) const;
40 54
41 private: 55 private:
42 TransportDIB* dib_; 56 const int id_;
57 scoped_ptr<base::SharedMemory> mem_;
58 bool free_;
59 Buffer* parent_;
60 gfx::Rect damage_;
43 61
44 DISALLOW_COPY_AND_ASSIGN(DIB); 62 DISALLOW_COPY_AND_ASSIGN(Buffer);
45 }; 63 };
46 64
47 class CompareById { 65 class CompareById {
48 public: 66 public:
49 CompareById(const TransportDIB::Id& id) : id_(id) {} 67 CompareById(int id) : id_(id) {}
50 68
51 bool operator()(const DIB* dib) const { 69 bool operator()(const Buffer* buffer) const {
52 return dib->dib() && dib->dib()->id() == id_; 70 return buffer->id() == id_;
53 } 71 }
54 72
55 private: 73 private:
56 TransportDIB::Id id_; 74 const int id_;
57 }; 75 };
58 76
59 DIB* CreateDIB(); 77 int GetNextId();
78 Buffer* CreateBuffer();
79 int FindFreeBuffer(int hint);
60 80
61 int front_buffer_; 81 int current_index_;
62 int num_free_buffers_; 82 int next_buffer_id_;
63 ScopedVector<DIB> dibs_; 83 ScopedVector<Buffer> buffers_;
64 ScopedVector<DIB> awaiting_ack_; 84 ScopedVector<Buffer> awaiting_ack_;
65 SkBitmap bitmap_; 85 SkBitmap bitmap_;
86 RenderThread* render_thread_;
66 }; 87 };
67 88
68 } // namespace content 89 } // namespace content
69 90
70 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_ 91 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_SOFTWARE_OUTPUT_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698