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 <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include "base/macros.h" |
9 #include "base/trace_event/memory_allocator_dump.h" | 12 #include "base/trace_event/memory_allocator_dump.h" |
10 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
11 #include "gpu/command_buffer/common/mailbox.h" | 14 #include "gpu/command_buffer/common/mailbox.h" |
12 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
13 | 16 |
14 namespace cc { | 17 namespace cc { |
15 typedef gpu::Mailbox SharedBitmapId; | 18 typedef gpu::Mailbox SharedBitmapId; |
16 | 19 |
17 CC_EXPORT base::trace_event::MemoryAllocatorDumpGuid | 20 CC_EXPORT base::trace_event::MemoryAllocatorDumpGuid |
18 GetSharedBitmapGUIDForTracing(const SharedBitmapId& bitmap_id); | 21 GetSharedBitmapGUIDForTracing(const SharedBitmapId& bitmap_id); |
19 | 22 |
20 class CC_EXPORT SharedBitmap { | 23 class CC_EXPORT SharedBitmap { |
21 public: | 24 public: |
22 SharedBitmap(uint8* pixels, const SharedBitmapId& id); | 25 SharedBitmap(uint8_t* pixels, const SharedBitmapId& id); |
23 | 26 |
24 virtual ~SharedBitmap(); | 27 virtual ~SharedBitmap(); |
25 | 28 |
26 uint8* pixels() { return pixels_; } | 29 uint8_t* pixels() { return pixels_; } |
27 | 30 |
28 const SharedBitmapId& id() { return id_; } | 31 const SharedBitmapId& id() { return id_; } |
29 | 32 |
30 // Returns true if the size is valid and false otherwise. | 33 // Returns true if the size is valid and false otherwise. |
31 static bool SizeInBytes(const gfx::Size& size, size_t* size_in_bytes); | 34 static bool SizeInBytes(const gfx::Size& size, size_t* size_in_bytes); |
32 // Dies with a CRASH() if the size can not be represented as a positive number | 35 // Dies with a CRASH() if the size can not be represented as a positive number |
33 // of bytes. | 36 // of bytes. |
34 static size_t CheckedSizeInBytes(const gfx::Size& size); | 37 static size_t CheckedSizeInBytes(const gfx::Size& size); |
35 // Returns the size in bytes but may overflow or return 0. Only do this for | 38 // Returns the size in bytes but may overflow or return 0. Only do this for |
36 // sizes that have already been checked. | 39 // sizes that have already been checked. |
37 static size_t UncheckedSizeInBytes(const gfx::Size& size); | 40 static size_t UncheckedSizeInBytes(const gfx::Size& size); |
38 // Returns true if the size is valid and false otherwise. | 41 // Returns true if the size is valid and false otherwise. |
39 static bool VerifySizeInBytes(const gfx::Size& size); | 42 static bool VerifySizeInBytes(const gfx::Size& size); |
40 | 43 |
41 static SharedBitmapId GenerateId(); | 44 static SharedBitmapId GenerateId(); |
42 | 45 |
43 private: | 46 private: |
44 uint8* pixels_; | 47 uint8_t* pixels_; |
45 SharedBitmapId id_; | 48 SharedBitmapId id_; |
46 | 49 |
47 DISALLOW_COPY_AND_ASSIGN(SharedBitmap); | 50 DISALLOW_COPY_AND_ASSIGN(SharedBitmap); |
48 }; | 51 }; |
49 | 52 |
50 } // namespace cc | 53 } // namespace cc |
51 | 54 |
52 #endif // CC_RESOURCES_SHARED_BITMAP_H_ | 55 #endif // CC_RESOURCES_SHARED_BITMAP_H_ |
OLD | NEW |