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_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ | 5 #ifndef COMPONENTS_DISPLAY_COMPOSITOR_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ |
6 #define CONTENT_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ | 6 #define COMPONENTS_DISPLAY_COMPOSITOR_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
15 #include "cc/resources/shared_bitmap_manager.h" | 15 #include "cc/resources/shared_bitmap_manager.h" |
16 #include "content/common/render_message_filter.mojom.h" | 16 #include "components/display_compositor/display_compositor_export.h" |
| 17 #include "components/display_compositor/interfaces/shared_bitmap_manager.mojom.h
" |
17 #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" | 18 #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" |
18 | 19 |
19 namespace content { | 20 namespace display_compositor { |
20 | 21 |
21 class SharedMemoryBitmap : public cc::SharedBitmap { | 22 class SharedMemoryBitmap : public cc::SharedBitmap { |
22 public: | 23 public: |
23 base::SharedMemory* shared_memory() { return shared_memory_; } | 24 base::SharedMemory* shared_memory() { return shared_memory_; } |
24 | 25 |
25 protected: | 26 protected: |
26 SharedMemoryBitmap(uint8_t* pixels, | 27 SharedMemoryBitmap(uint8_t* pixels, |
27 const cc::SharedBitmapId& id, | 28 const cc::SharedBitmapId& id, |
28 base::SharedMemory* shared_memory); | 29 base::SharedMemory* shared_memory); |
29 | 30 |
30 base::SharedMemory* shared_memory_; | 31 base::SharedMemory* shared_memory_; |
31 }; | 32 }; |
32 | 33 |
33 class ChildSharedBitmapManager : public cc::SharedBitmapManager { | 34 class DISPLAY_COMPOSITOR_EXPORT ChildSharedBitmapManager |
| 35 : public cc::SharedBitmapManager { |
34 public: | 36 public: |
35 explicit ChildSharedBitmapManager( | 37 explicit ChildSharedBitmapManager( |
36 const scoped_refptr<mojom::ThreadSafeRenderMessageFilterAssociatedPtr>& | 38 const scoped_refptr<mojom::ThreadSafeSharedBitmapManagerAssociatedPtr>& |
37 render_message_filter_ptr); | 39 render_message_filter_ptr); |
38 ~ChildSharedBitmapManager() override; | 40 ~ChildSharedBitmapManager() override; |
39 | 41 |
| 42 // Allocates a block of shared memory of the given size. Returns nullptr on |
| 43 // failure. |
| 44 static std::unique_ptr<base::SharedMemory> AllocateSharedMemory( |
| 45 size_t buf_size); |
| 46 |
40 // cc::SharedBitmapManager implementation. | 47 // cc::SharedBitmapManager implementation. |
41 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap( | 48 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap( |
42 const gfx::Size& size) override; | 49 const gfx::Size& size) override; |
43 std::unique_ptr<cc::SharedBitmap> GetSharedBitmapFromId( | 50 std::unique_ptr<cc::SharedBitmap> GetSharedBitmapFromId( |
44 const gfx::Size&, | 51 const gfx::Size&, |
45 const cc::SharedBitmapId&) override; | 52 const cc::SharedBitmapId&) override; |
46 | 53 |
47 std::unique_ptr<cc::SharedBitmap> GetBitmapForSharedMemory( | 54 std::unique_ptr<cc::SharedBitmap> GetBitmapForSharedMemory( |
48 base::SharedMemory* mem); | 55 base::SharedMemory* mem); |
49 | 56 |
50 private: | 57 private: |
51 void NotifyAllocatedSharedBitmap(base::SharedMemory* memory, | 58 void NotifyAllocatedSharedBitmap(base::SharedMemory* memory, |
52 const cc::SharedBitmapId& id); | 59 const cc::SharedBitmapId& id); |
53 | 60 |
54 scoped_refptr<mojom::ThreadSafeRenderMessageFilterAssociatedPtr> | 61 scoped_refptr<mojom::ThreadSafeSharedBitmapManagerAssociatedPtr> |
55 render_message_filter_ptr_; | 62 shared_bitmap_manager_ptr_; |
56 | 63 |
57 DISALLOW_COPY_AND_ASSIGN(ChildSharedBitmapManager); | 64 DISALLOW_COPY_AND_ASSIGN(ChildSharedBitmapManager); |
58 }; | 65 }; |
59 | 66 |
60 } // namespace content | 67 } // namespace display_compositor |
61 | 68 |
62 #endif // CONTENT_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ | 69 #endif // COMPONENTS_DISPLAY_COMPOSITOR_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ |
OLD | NEW |