• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef DAWNNATIVE_OBJECTBASE_H_
16 #define DAWNNATIVE_OBJECTBASE_H_
17 
18 #include "dawn_native/RefCounted.h"
19 
20 namespace dawn_native {
21 
22     class DeviceBase;
23 
24     class ObjectBase : public RefCounted {
25       public:
26         struct ErrorTag {};
27         static constexpr ErrorTag kError = {};
28 
29         ObjectBase(DeviceBase* device);
30         ObjectBase(DeviceBase* device, ErrorTag tag);
31         virtual ~ObjectBase();
32 
33         DeviceBase* GetDevice() const;
34         bool IsError() const;
35 
36       private:
37         DeviceBase* mDevice;
38         // TODO(cwallez@chromium.org): This most likely adds 4 bytes to most Dawn objects, see if
39         // that bit can be hidden in the refcount once it is a single 64bit refcount.
40         // See https://bugs.chromium.org/p/dawn/issues/detail?id=105
41         bool mIsError;
42     };
43 
44 }  // namespace dawn_native
45 
46 #endif  // DAWNNATIVE_OBJECTBASE_H_
47