-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move FlutterBackingStorePresentInfo into FlutterBackingStore
- Loading branch information
Showing
21 changed files
with
590 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/platform/embedder/embedder_backing_store.h" | ||
|
||
namespace flutter { | ||
|
||
bool EmbedderBackingStore::SetPresetInfo(FlutterBackingStorePresentInfo* info) { | ||
if (backing_store_.struct_size == sizeof(FlutterBackingStoreVersion2)) { | ||
version2_.present_info = info; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_BACKING_STORE_H_ | ||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_BACKING_STORE_H_ | ||
|
||
#include "flutter/shell/platform/embedder/embedder.h" | ||
|
||
namespace flutter { | ||
|
||
typedef struct { | ||
/// The size of this struct. Must be sizeof(FlutterBackingStore). | ||
size_t struct_size; | ||
/// A baton that is not interpreted by the engine in any way. The embedder may | ||
/// use this to associate resources that are tied to the lifecycle of the | ||
/// `FlutterBackingStore`. | ||
void* user_data; | ||
/// Specifies the type of backing store. | ||
FlutterBackingStoreType type; | ||
/// Indicates if this backing store was updated since the last time it was | ||
/// associated with a presented layer. | ||
bool did_update; | ||
union { | ||
/// The description of the OpenGL backing store. | ||
FlutterOpenGLBackingStore open_gl; | ||
/// The description of the software backing store. | ||
FlutterSoftwareBackingStore software; | ||
/// The description of the software backing store. | ||
FlutterSoftwareBackingStore2 software2; | ||
// The description of the Metal backing store. | ||
FlutterMetalBackingStore metal; | ||
// The description of the Vulkan backing store. | ||
FlutterVulkanBackingStore vulkan; | ||
}; | ||
} FlutterBackingStoreVersion1; | ||
|
||
typedef FlutterBackingStore FlutterBackingStoreVersion2; | ||
|
||
/// Wrapper around FlutterBackingStore that handles different versions of the | ||
/// struct. | ||
class EmbedderBackingStore { | ||
public: | ||
EmbedderBackingStore() { | ||
// By default assume the oldest version of backing store. Embedder can | ||
// override this by setting the struct_size field. | ||
backing_store_ = { | ||
.struct_size = sizeof(FlutterBackingStoreVersion1), | ||
}; | ||
} | ||
|
||
bool IsValid() const { | ||
return backing_store_.struct_size == sizeof(FlutterBackingStoreVersion1) || | ||
backing_store_.struct_size == sizeof(FlutterBackingStoreVersion2); | ||
} | ||
|
||
FlutterBackingStoreType type() const { return version1_.type; } | ||
|
||
const FlutterOpenGLBackingStore& open_gl() const { return version1_.open_gl; } | ||
|
||
const FlutterSoftwareBackingStore& software() const { | ||
return version1_.software; | ||
} | ||
|
||
const FlutterSoftwareBackingStore2& software2() const { | ||
return version1_.software2; | ||
} | ||
|
||
const FlutterMetalBackingStore& metal() const { return version1_.metal; } | ||
|
||
const FlutterVulkanBackingStore& vulkan() const { return version1_.vulkan; } | ||
|
||
void SetDidUpdate(bool did_update) { version1_.did_update = true; } | ||
|
||
bool SetPresetInfo(FlutterBackingStorePresentInfo* info); | ||
|
||
/// Returns pointer to the backing store. This is intentionally opaque to | ||
/// prevent embedder from accessing the fields directly and is meant for | ||
/// passing back to the embedder client. | ||
void* GetBackingStorePointer() { return &backing_store_; } | ||
const void* GetBackingStorePointer() const { return &backing_store_; } | ||
|
||
private: | ||
union { | ||
size_t struct_size_; | ||
FlutterBackingStoreVersion1 version1_; | ||
FlutterBackingStoreVersion2 version2_; | ||
FlutterBackingStore backing_store_; | ||
}; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_BACKING_STORE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.