Flutter Impeller
allocator_gles.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 
6 
7 #include <memory>
8 
10 #include "impeller/base/config.h"
13 
14 namespace impeller {
15 
16 AllocatorGLES::AllocatorGLES(std::shared_ptr<ReactorGLES> reactor)
17  : reactor_(std::move(reactor)), is_valid_(true) {}
18 
19 // |Allocator|
20 AllocatorGLES::~AllocatorGLES() = default;
21 
22 // |Allocator|
23 bool AllocatorGLES::IsValid() const {
24  return is_valid_;
25 }
26 
27 // |Allocator|
28 std::shared_ptr<DeviceBuffer> AllocatorGLES::OnCreateBuffer(
29  const DeviceBufferDescriptor& desc) {
30  auto backing_store = std::make_shared<Allocation>();
31  if (!backing_store->Truncate(Bytes{desc.size})) {
32  return nullptr;
33  }
34  return std::make_shared<DeviceBufferGLES>(desc, //
35  reactor_, //
36  std::move(backing_store) //
37  );
38 }
39 
40 // |Allocator|
41 std::shared_ptr<Texture> AllocatorGLES::OnCreateTexture(
42  const TextureDescriptor& desc) {
43  return std::make_shared<TextureGLES>(reactor_, desc);
44 }
45 
46 // |Allocator|
47 ISize AllocatorGLES::GetMaxTextureSizeSupported() const {
48  return reactor_->GetProcTable().GetCapabilities()->max_texture_size;
49 }
50 
51 } // namespace impeller
AllocationSize< 1u > Bytes
ISize64 ISize
Definition: size.h:162
Definition: comparable.h:95