Reland "Add base::TimeDelta::Max()"
[chromium-blink-merge.git] / cc / resources / texture_mailbox.h
blob229f7a735148892d44106c22a67c656b4abe14b4
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_TEXTURE_MAILBOX_H_
6 #define CC_RESOURCES_TEXTURE_MAILBOX_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/shared_memory.h"
12 #include "cc/base/cc_export.h"
13 #include "gpu/command_buffer/common/mailbox_holder.h"
14 #include "ui/gfx/size.h"
16 namespace cc {
18 // TODO(skaslev, danakj) Rename this class more apropriately since now it
19 // can hold a shared memory resource as well as a texture mailbox.
20 class CC_EXPORT TextureMailbox {
21 public:
22 TextureMailbox();
23 explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder);
24 TextureMailbox(const gpu::Mailbox& mailbox, uint32 target, uint32 sync_point);
25 TextureMailbox(base::SharedMemory* shared_memory, const gfx::Size& size);
27 ~TextureMailbox();
29 bool IsValid() const { return IsTexture() || IsSharedMemory(); }
30 bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); }
31 bool IsSharedMemory() const { return shared_memory_ != NULL; }
33 bool Equals(const TextureMailbox&) const;
35 const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; }
36 const int8* name() const { return mailbox().name; }
37 uint32 target() const { return mailbox_holder_.texture_target; }
38 uint32 sync_point() const { return mailbox_holder_.sync_point; }
39 void set_sync_point(int32 sync_point) {
40 mailbox_holder_.sync_point = sync_point;
43 base::SharedMemory* shared_memory() const { return shared_memory_; }
44 gfx::Size shared_memory_size() const { return shared_memory_size_; }
45 size_t shared_memory_size_in_bytes() const;
47 private:
48 gpu::MailboxHolder mailbox_holder_;
49 base::SharedMemory* shared_memory_;
50 gfx::Size shared_memory_size_;
53 } // namespace cc
55 #endif // CC_RESOURCES_TEXTURE_MAILBOX_H_