• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {}
23 
~MemoryObject()24 MemoryObject::~MemoryObject() {}
25 
onDestroy(const Context * context)26 void MemoryObject::onDestroy(const Context *context)
27 {
28     mImplementation->onDestroy(context);
29 }
30 
setDedicatedMemory(const Context * context,bool dedicatedMemory)31 angle::Result MemoryObject::setDedicatedMemory(const Context *context, bool dedicatedMemory)
32 {
33     ANGLE_TRY(mImplementation->setDedicatedMemory(context, dedicatedMemory));
34     mDedicatedMemory = dedicatedMemory;
35     return angle::Result::Continue;
36 }
37 
importFd(Context * context,GLuint64 size,HandleType handleType,GLint fd)38 angle::Result MemoryObject::importFd(Context *context,
39                                      GLuint64 size,
40                                      HandleType handleType,
41                                      GLint fd)
42 {
43     ANGLE_TRY(mImplementation->importFd(context, size, handleType, fd));
44     mImmutable = true;
45     return angle::Result::Continue;
46 }
47 
importZirconHandle(Context * context,GLuint64 size,HandleType handleType,GLuint handle)48 angle::Result MemoryObject::importZirconHandle(Context *context,
49                                                GLuint64 size,
50                                                HandleType handleType,
51                                                GLuint handle)
52 {
53     ANGLE_TRY(mImplementation->importZirconHandle(context, size, handleType, handle));
54     mImmutable = true;
55     return angle::Result::Continue;
56 }
57 
58 }  // namespace gl
59