| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/memory/shared_memory.h" |
| 11 #include "base/hash.h" | 12 #include "base/hash.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/trace_event/memory_allocator_dump.h" | 14 #include "base/trace_event/memory_allocator_dump.h" |
| 14 #include "cc/cc_export.h" | 15 #include "cc/cc_export.h" |
| 15 #include "gpu/command_buffer/common/mailbox.h" | 16 #include "gpu/command_buffer/common/mailbox.h" |
| 16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class SharedMemoryHandle; | 20 class SharedMemoryHandle; |
| 20 } | 21 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 virtual ~SharedBitmap(); | 39 virtual ~SharedBitmap(); |
| 39 | 40 |
| 40 uint8_t* pixels() { return pixels_; } | 41 uint8_t* pixels() { return pixels_; } |
| 41 | 42 |
| 42 const SharedBitmapId& id() { return id_; } | 43 const SharedBitmapId& id() { return id_; } |
| 43 | 44 |
| 44 // Returns the shared memory's handle when the back end is base::SharedMemory. | 45 // Returns the shared memory's handle when the back end is base::SharedMemory. |
| 45 // Otherwise, this returns an invalid handle. | 46 // Otherwise, this returns an invalid handle. |
| 46 virtual base::SharedMemoryHandle GetSharedMemoryHandle() const = 0; | 47 virtual base::SharedMemoryHandle GetSharedMemoryHandle() const = 0; |
| 47 | 48 |
| 49 virtual base::SharedMemory* GetSharedMemory() const = 0; |
| 50 |
| 48 // Returns true if the size is valid and false otherwise. | 51 // Returns true if the size is valid and false otherwise. |
| 49 static bool SizeInBytes(const gfx::Size& size, size_t* size_in_bytes); | 52 static bool SizeInBytes(const gfx::Size& size, size_t* size_in_bytes); |
| 50 // Dies with a CRASH() if the size can not be represented as a positive number | 53 // Dies with a CRASH() if the size can not be represented as a positive number |
| 51 // of bytes. | 54 // of bytes. |
| 52 static size_t CheckedSizeInBytes(const gfx::Size& size); | 55 static size_t CheckedSizeInBytes(const gfx::Size& size); |
| 53 // Returns the size in bytes but may overflow or return 0. Only do this for | 56 // Returns the size in bytes but may overflow or return 0. Only do this for |
| 54 // sizes that have already been checked. | 57 // sizes that have already been checked. |
| 55 static size_t UncheckedSizeInBytes(const gfx::Size& size); | 58 static size_t UncheckedSizeInBytes(const gfx::Size& size); |
| 56 // Returns true if the size is valid and false otherwise. | 59 // Returns true if the size is valid and false otherwise. |
| 57 static bool VerifySizeInBytes(const gfx::Size& size); | 60 static bool VerifySizeInBytes(const gfx::Size& size); |
| 58 | 61 |
| 59 static SharedBitmapId GenerateId(); | 62 static SharedBitmapId GenerateId(); |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 uint8_t* pixels_; | 65 uint8_t* pixels_; |
| 63 SharedBitmapId id_; | 66 SharedBitmapId id_; |
| 64 | 67 |
| 65 DISALLOW_COPY_AND_ASSIGN(SharedBitmap); | 68 DISALLOW_COPY_AND_ASSIGN(SharedBitmap); |
| 66 }; | 69 }; |
| 67 | 70 |
| 68 } // namespace cc | 71 } // namespace cc |
| 69 | 72 |
| 70 #endif // CC_RESOURCES_SHARED_BITMAP_H_ | 73 #endif // CC_RESOURCES_SHARED_BITMAP_H_ |
| OLD | NEW |