1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // MemoryObject.h: Implements the gl::MemoryObject class [EXT_external_objects]
7
8 #include "libANGLE/MemoryObject.h"
9
10 #include "common/angleutils.h"
11 #include "libANGLE/renderer/GLImplFactory.h"
12 #include "libANGLE/renderer/MemoryObjectImpl.h"
13
14 namespace gl
15 {
16
MemoryObject(rx::GLImplFactory * factory,MemoryObjectID id)17 MemoryObject::MemoryObject(rx::GLImplFactory *factory, MemoryObjectID id)
18 : RefCountObject(factory->generateSerial(), id),
19 mImplementation(factory->createMemoryObject()),
20 mImmutable(false),
21 mDedicatedMemory(false),
22 mProtectedMemory(false)
23 {}
24
~MemoryObject()25 MemoryObject::~MemoryObject() {}
26
onDestroy(const Context * context)27 void MemoryObject::onDestroy(const Context *context)
28 {
29 mImplementation->onDestroy(context);
30 }
31
setDedicatedMemory(const Context * context,bool dedicatedMemory)32 angle::Result MemoryObject::setDedicatedMemory(const Context *context, bool dedicatedMemory)
33 {
34 ANGLE_TRY(mImplementation->setDedicatedMemory(context, dedicatedMemory));
35 mDedicatedMemory = dedicatedMemory;
36 return angle::Result::Continue;
37 }
38
setProtectedMemory(const Context * context,bool protectedMemory)39 angle::Result MemoryObject::setProtectedMemory(const Context *context, bool protectedMemory)
40 {
41 ANGLE_TRY(mImplementation->setProtectedMemory(context, protectedMemory));
42 mProtectedMemory = protectedMemory;
43 return angle::Result::Continue;
44 }
45
importFd(Context * context,GLuint64 size,HandleType handleType,GLint fd)46 angle::Result MemoryObject::importFd(Context *context,
47 GLuint64 size,
48 HandleType handleType,
49 GLint fd)
50 {
51 ANGLE_TRY(mImplementation->importFd(context, size, handleType, fd));
52 mImmutable = true;
53 return angle::Result::Continue;
54 }
55
importZirconHandle(Context * context,GLuint64 size,HandleType handleType,GLuint handle)56 angle::Result MemoryObject::importZirconHandle(Context *context,
57 GLuint64 size,
58 HandleType handleType,
59 GLuint handle)
60 {
61 ANGLE_TRY(mImplementation->importZirconHandle(context, size, handleType, handle));
62 mImmutable = true;
63 return angle::Result::Continue;
64 }
65
66 } // namespace gl
67