Reland "Add base::TimeDelta::Max()"
[chromium-blink-merge.git] / cc / resources / shared_bitmap.h
blob9575068411ac512038088663b7854aba5b9ada00
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.
5 #ifndef CC_RESOURCES_SHARED_BITMAP_H_
6 #define CC_RESOURCES_SHARED_BITMAP_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/shared_memory.h"
11 #include "cc/base/cc_export.h"
12 #include "gpu/command_buffer/common/mailbox.h"
14 namespace base { class SharedMemory; }
16 namespace cc {
17 typedef gpu::Mailbox SharedBitmapId;
19 class CC_EXPORT SharedBitmap {
20 public:
21 SharedBitmap(base::SharedMemory* memory,
22 const SharedBitmapId& id,
23 const base::Callback<void(SharedBitmap*)>& free_callback);
25 ~SharedBitmap();
27 bool operator<(const SharedBitmap& right) const {
28 if (memory_ < right.memory_)
29 return true;
30 if (memory_ > right.memory_)
31 return false;
32 return id_ < right.id_;
35 uint8* pixels() { return static_cast<uint8*>(memory_->memory()); }
37 base::SharedMemory* memory() { return memory_; }
39 SharedBitmapId id() { return id_; }
41 private:
42 base::SharedMemory* memory_;
43 SharedBitmapId id_;
44 base::Callback<void(SharedBitmap*)> free_callback_;
46 DISALLOW_COPY_AND_ASSIGN(SharedBitmap);
49 } // namespace cc
51 #endif // CC_RESOURCES_SHARED_BITMAP_H_