| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_RESOURCES_SHARED_BITMAP_H_ | 5 #ifndef CC_RESOURCES_SHARED_BITMAP_H_ |
| 6 #define CC_RESOURCES_SHARED_BITMAP_H_ | 6 #define CC_RESOURCES_SHARED_BITMAP_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "gpu/command_buffer/common/mailbox.h" | 12 #include "gpu/command_buffer/common/mailbox.h" |
| 13 #include "ui/gfx/size.h" |
| 13 | 14 |
| 14 namespace base { class SharedMemory; } | 15 namespace base { class SharedMemory; } |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 typedef gpu::Mailbox SharedBitmapId; | 18 typedef gpu::Mailbox SharedBitmapId; |
| 18 | 19 |
| 19 class CC_EXPORT SharedBitmap { | 20 class CC_EXPORT SharedBitmap { |
| 20 public: | 21 public: |
| 21 SharedBitmap(base::SharedMemory* memory, | 22 SharedBitmap(base::SharedMemory* memory, |
| 22 const SharedBitmapId& id, | 23 const SharedBitmapId& id, |
| 23 const base::Callback<void(SharedBitmap*)>& free_callback); | 24 const base::Callback<void(SharedBitmap*)>& free_callback); |
| 24 | 25 |
| 25 ~SharedBitmap(); | 26 ~SharedBitmap(); |
| 26 | 27 |
| 27 bool operator<(const SharedBitmap& right) const { | 28 bool operator<(const SharedBitmap& right) const { |
| 28 if (memory_ < right.memory_) | 29 if (memory_ < right.memory_) |
| 29 return true; | 30 return true; |
| 30 if (memory_ > right.memory_) | 31 if (memory_ > right.memory_) |
| 31 return false; | 32 return false; |
| 32 return id_ < right.id_; | 33 return id_ < right.id_; |
| 33 } | 34 } |
| 34 | 35 |
| 35 uint8* pixels() { return static_cast<uint8*>(memory_->memory()); } | 36 uint8* pixels() { return static_cast<uint8*>(memory_->memory()); } |
| 36 | 37 |
| 37 base::SharedMemory* memory() { return memory_; } | 38 base::SharedMemory* memory() { return memory_; } |
| 38 | 39 |
| 39 SharedBitmapId id() { return id_; } | 40 SharedBitmapId id() { return id_; } |
| 40 | 41 |
| 42 // Returns true if the size is valid and false otherwise. |
| 43 static bool GetSizeInBytes(const gfx::Size& size, size_t* size_in_bytes); |
| 44 |
| 45 static SharedBitmapId GenerateId(); |
| 46 |
| 41 private: | 47 private: |
| 42 base::SharedMemory* memory_; | 48 base::SharedMemory* memory_; |
| 43 SharedBitmapId id_; | 49 SharedBitmapId id_; |
| 44 base::Callback<void(SharedBitmap*)> free_callback_; | 50 base::Callback<void(SharedBitmap*)> free_callback_; |
| 45 | 51 |
| 46 DISALLOW_COPY_AND_ASSIGN(SharedBitmap); | 52 DISALLOW_COPY_AND_ASSIGN(SharedBitmap); |
| 47 }; | 53 }; |
| 48 | 54 |
| 49 } // namespace cc | 55 } // namespace cc |
| 50 | 56 |
| 51 #endif // CC_RESOURCES_SHARED_BITMAP_H_ | 57 #endif // CC_RESOURCES_SHARED_BITMAP_H_ |
| OLD | NEW |