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
; }
17 typedef gpu::Mailbox SharedBitmapId
;
19 class CC_EXPORT SharedBitmap
{
21 SharedBitmap(base::SharedMemory
* memory
,
22 const SharedBitmapId
& id
,
23 const base::Callback
<void(SharedBitmap
*)>& free_callback
);
27 bool operator<(const SharedBitmap
& right
) const {
28 if (memory_
< right
.memory_
)
30 if (memory_
> right
.memory_
)
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_
; }
42 base::SharedMemory
* memory_
;
44 base::Callback
<void(SharedBitmap
*)> free_callback_
;
46 DISALLOW_COPY_AND_ASSIGN(SharedBitmap
);
51 #endif // CC_RESOURCES_SHARED_BITMAP_H_