| 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 CONTENT_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ |
| 6 #define CONTENT_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ | 6 #define CONTENT_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 "content/child/thread_safe_sender.h" |
| 17 #include "mojo/public/cpp/bindings/thread_safe_interface_ptr.h" | |
| 18 | 17 |
| 19 namespace content { | 18 namespace content { |
| 20 | 19 |
| 21 class SharedMemoryBitmap : public cc::SharedBitmap { | 20 class SharedMemoryBitmap : public cc::SharedBitmap { |
| 22 public: | 21 public: |
| 23 base::SharedMemory* shared_memory() { return shared_memory_; } | 22 base::SharedMemory* shared_memory() { return shared_memory_; } |
| 24 | 23 |
| 25 protected: | 24 protected: |
| 26 SharedMemoryBitmap(uint8_t* pixels, | 25 SharedMemoryBitmap(uint8_t* pixels, |
| 27 const cc::SharedBitmapId& id, | 26 const cc::SharedBitmapId& id, |
| 28 base::SharedMemory* shared_memory); | 27 base::SharedMemory* shared_memory); |
| 29 | 28 |
| 30 base::SharedMemory* shared_memory_; | 29 base::SharedMemory* shared_memory_; |
| 31 }; | 30 }; |
| 32 | 31 |
| 33 class ChildSharedBitmapManager : public cc::SharedBitmapManager { | 32 class ChildSharedBitmapManager : public cc::SharedBitmapManager { |
| 34 public: | 33 public: |
| 35 explicit ChildSharedBitmapManager( | 34 ChildSharedBitmapManager(scoped_refptr<ThreadSafeSender> sender); |
| 36 const scoped_refptr<mojom::ThreadSafeRenderMessageFilterAssociatedPtr>& | |
| 37 render_message_filter_ptr); | |
| 38 ~ChildSharedBitmapManager() override; | 35 ~ChildSharedBitmapManager() override; |
| 39 | 36 |
| 40 // cc::SharedBitmapManager implementation. | 37 // cc::SharedBitmapManager implementation. |
| 41 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap( | 38 std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap( |
| 42 const gfx::Size& size) override; | 39 const gfx::Size& size) override; |
| 43 std::unique_ptr<cc::SharedBitmap> GetSharedBitmapFromId( | 40 std::unique_ptr<cc::SharedBitmap> GetSharedBitmapFromId( |
| 44 const gfx::Size&, | 41 const gfx::Size&, |
| 45 const cc::SharedBitmapId&) override; | 42 const cc::SharedBitmapId&) override; |
| 46 | 43 |
| 47 std::unique_ptr<cc::SharedBitmap> GetBitmapForSharedMemory( | 44 std::unique_ptr<cc::SharedBitmap> GetBitmapForSharedMemory( |
| 48 base::SharedMemory* mem); | 45 base::SharedMemory* mem); |
| 46 std::unique_ptr<SharedMemoryBitmap> AllocateSharedMemoryBitmap( |
| 47 const gfx::Size& size); |
| 49 | 48 |
| 50 private: | 49 private: |
| 51 void NotifyAllocatedSharedBitmap(base::SharedMemory* memory, | 50 scoped_refptr<ThreadSafeSender> sender_; |
| 52 const cc::SharedBitmapId& id); | |
| 53 | |
| 54 scoped_refptr<mojom::ThreadSafeRenderMessageFilterAssociatedPtr> | |
| 55 render_message_filter_ptr_; | |
| 56 | 51 |
| 57 DISALLOW_COPY_AND_ASSIGN(ChildSharedBitmapManager); | 52 DISALLOW_COPY_AND_ASSIGN(ChildSharedBitmapManager); |
| 58 }; | 53 }; |
| 59 | 54 |
| 60 } // namespace content | 55 } // namespace content |
| 61 | 56 |
| 62 #endif // CONTENT_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ | 57 #endif // CONTENT_CHILD_CHILD_SHARED_BITMAP_MANAGER_H_ |
| OLD | NEW |