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 UI_GFX_GPU_MEMORY_HANDLE_H_ 6 #define UI_GFX_GPU_MEMORY_HANDLE_H_ 7 8 #include "base/memory/ref_counted.h" 9 #include "ui/base/ui_export.h" 10 11 namespace gfx { 12 13 // A class that encapsulates the lifetime management of a 14 // GpuMemory and allows it to be shared across threads. 15 // It is useful when a thread that didn't allocate the memory 16 // needs to access the memory asynchronously. Even though the 17 // creator thread attempts to free the memory, as long as 18 // the accessor thread holds a reference the memory will not 19 // be freed. 20 class UI_EXPORT GpuMemoryHandle 21 : public base::RefCountedThreadSafe<GpuMemoryHandle> { 22 public: 23 GpuMemoryHandle(); 24 virtual void* GetNativeHandle() const = 0; 25 virtual int GetBufferId() const = 0; 26 27 protected: 28 friend class base::RefCountedThreadSafe<GpuMemoryHandle>; 29 virtual ~GpuMemoryHandle(); 30 }; 31 32 } // namespace gfx 33 34 #endif // UI_GFX_GPU_MEMORY_HANDLE_H_ 35