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
using namespace cppcoro; | |
static const std::filesystem::path testCSS{"../test_res/style.css"}; | |
static const std::filesystem::path testHTML{"../test_res/index.html"}; | |
using DataBuffer = std::unique_ptr<std::uint8_t[]>; | |
task<DataBuffer> ReadFile(const std::filesystem::path& p) | |
{ | |
DataBuffer result = std::make_unique<std::uint8_t[]>(len); |
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
static const std::filesystem::path testHTML{"../test_res/index.html"}; | |
static const std::filesystem::path testCSS{"../test_res/style.css"}; | |
using DataBuffer = std::unique_ptr<std::uint8_t[]>; | |
struct Document | |
{ | |
DataBuffer HTMLData; | |
DataBuffer CSSData; | |
std::mutex DataMut; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<!-- | |
Created using JS Bin | |
http://jsbin.com | |
Copyright (c) 2017 by jakearchibald (http://jsbin.com/surane/7/edit) | |
Copyright (c) 2017 by Stoyan Nikolov |
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
// By default passing a naked pointer to a task is fobidden | |
template<typename T> | |
struct allow_thread_sharing_from_naked_ptr | |
{ | |
using type = std::false_type; | |
}; | |
// The macro allows explicitly marking a type | |
// as sharable in a task by naked pointer | |
#define ALLOW_TASK_SHARING_AS_NAKED_PTR(TYPE) \ |
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
template<typename T> | |
TaskValidation_t ValidateTaskParameters(const T& arg) | |
{ | |
static_assert(meta_if<std::is_pointer<T>::value, typename allow_thread_sharing_from_naked_ptr<typename std::remove_pointer<typename std::remove_cv<T>::type>::type>::type, std::true_type>::type::value, "It is not allowed to pass naked pointers of this type in tasks!"); | |
//.. More conditions omitted for brevity | |
static_assert(!forbid_thread_sharing<typename std::remove_pointer<typename std::remove_cv<T>::type>::type>::type::value, "This type is explicitly forbidden to be passed in tasks!"); | |
return TaskValidation_t{}; | |
} |
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
auto recalcVisualStyle = Task::Create("RecalculateVisualStyle", | |
TASK_PARAMS(recordRenderingParams, info)(Task*, TaskFamily) mutable { | |
LayoutSolver::RecalcVisualStyle(info, | |
recordRenderingParams->LayoutRoot.get(), | |
recordRenderingParams->ViewDims, | |
recordRenderingParams->DirtyRegion); | |
} | |
); |
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
static const BlendingState s_BlendingModes2State[] = { | |
{ /* Clear */ | |
true, | |
BC_Zero, | |
BC_Zero, | |
BLOP_Add, | |
BC_Zero, | |
BC_Zero, | |
BLOP_Add, | |
}, |
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
inline BlendingState BlendingMode2State(BlendModes mode) | |
{ | |
static BlendingState states[] = { | |
{ /* Clear */ | |
true, | |
BC_Zero, | |
BC_Zero, | |
BLOP_Add, | |
BC_Zero, | |
BC_Zero, |
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
template | |
void Unite2D(const Rectangle& other, bool allowEmpty = false) | |
{ | |
static_assert(sizeof...(Components) >= sizeof...(RhsComponents), "Cannot assign to type with less components than operand!"); | |
static_assert(meta_contains_types<meta_packer, meta_packer>::value, "Operand has components that are not part of this object!"); | |
m_Value.Unite2D(other.m_Value, allowEmpty); | |
} |
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
// Data-oriented variant for drawing moving shapes | |
struct Positions | |
{ | |
unsigned Count; | |
float* Xs; // Simplify SIMD-ification | |
float* Ys; | |
}; | |
struct ShapePositions |
NewerOlder