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