Home | History | Annotate | Download | only in resources
      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 "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"
     13 
     14 namespace base { class SharedMemory; }
     15 
     16 namespace cc {
     17 typedef gpu::Mailbox SharedBitmapId;
     18 
     19 class CC_EXPORT SharedBitmap {
     20  public:
     21   SharedBitmap(base::SharedMemory* memory,
     22                const SharedBitmapId& id,
     23                const base::Callback<void(SharedBitmap*)>& free_callback);
     24 
     25   ~SharedBitmap();
     26 
     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_;
     33   }
     34 
     35   uint8* pixels() { return static_cast<uint8*>(memory_->memory()); }
     36 
     37   base::SharedMemory* memory() { return memory_; }
     38 
     39   SharedBitmapId id() { return id_; }
     40 
     41  private:
     42   base::SharedMemory* memory_;
     43   SharedBitmapId id_;
     44   base::Callback<void(SharedBitmap*)> free_callback_;
     45 
     46   DISALLOW_COPY_AND_ASSIGN(SharedBitmap);
     47 };
     48 
     49 }  // namespace cc
     50 
     51 #endif  // CC_RESOURCES_SHARED_BITMAP_H_
     52