-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73579fe
commit c4b6c52
Showing
36 changed files
with
290 additions
and
190 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,9 +147,9 @@ auto Row::_getChunk(const std::string& columnName) const -> std::shared_ptr<arro | |
|
||
// Iterate over column chunks and find the chunk that contains row data | ||
int64_t offset = 0; | ||
for (auto chunk : column->chunks()) { | ||
for (const auto& chunk : column->chunks()) { | ||
if (this->_rowIndex >= offset && this->_rowIndex < offset + chunk->length()) { | ||
// TODO([email protected]): Cache | ||
// TODO([email protected]): Cache chunks once Rows are being reused properly | ||
return chunk; | ||
} | ||
|
||
|
@@ -183,7 +183,7 @@ auto Row::_getRowChunkData(const std::shared_ptr<arrow::Table>& table, int64_t r | |
throw std::logic_error("Invalid chunk lookup"); | ||
} | ||
|
||
// TODO([email protected]): Sacrificing performance and precision for conciseness, revisit | ||
// Sacrificing performance and precision for conciseness. Revisit if this becomes a bottleneck | ||
auto Row::_getDouble(const std::shared_ptr<arrow::Array>& chunk) const -> std::optional<double> { | ||
switch (chunk->type_id()) { | ||
case arrow::Type::DOUBLE: | ||
|
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 |
---|---|---|
|
@@ -23,8 +23,8 @@ | |
using namespace deckgl; | ||
|
||
// Setters and getters for properties | ||
// TODO([email protected]): auto generate from language-independent prop definition schema | ||
// TODO([email protected]): Generate a unique id instead of an empty string for default value? | ||
// TODO([email protected]): Auto generate from language-independent prop definition schema | ||
// TODO([email protected]): Generate a unique id instead of an empty string for default value of id? | ||
static const std::vector<std::shared_ptr<Property>> propTypeDefs = {std::make_shared<PropertyT<std::string>>( | ||
"id", [](const JSONObject* props) { return dynamic_cast<const Component::Props*>(props)->id; }, | ||
[](JSONObject* props, std::string value) { return dynamic_cast<Component::Props*>(props)->id = value; }, "")}; | ||
|
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
using namespace deckgl; | ||
|
||
// Setters and getters for properties | ||
// TODO([email protected]): auto generate from language-independent prop definition schema | ||
// TODO([email protected]): Auto generate from language-independent prop definition schema | ||
static const std::vector<std::shared_ptr<Property>> propTypeDefs = { | ||
std::make_shared<PropertyT<std::list<std::shared_ptr<Layer::Props>>>>( | ||
"layers", [](const JSONObject* props) { return dynamic_cast<const Deck::Props*>(props)->layers; }, | ||
|
@@ -200,9 +200,11 @@ void Deck::_drawLayers(wgpu::RenderPassEncoder pass, std::function<void(Deck*)> | |
// Expose the current viewport to layers for project* function | ||
this->layerManager->activateViewport(viewport); | ||
|
||
for (auto const& layer : this->layerManager->layers) { | ||
// TODO([email protected]): Pass relevant layer properties to getUniformsFromViewport | ||
auto viewportUniforms = getUniformsFromViewport(viewport, this->animationLoop->devicePixelRatio()); | ||
for (auto const& layer : this->layerManager->layers()) { | ||
auto layerProps = layer->props(); | ||
auto viewportUniforms = getUniformsFromViewport(viewport, this->animationLoop->devicePixelRatio(), | ||
layerProps->modelMatrix, layerProps->coordinateSystem, | ||
layerProps->coordinateOrigin, layerProps->wrapLongitude); | ||
|
||
this->_viewportUniformsBuffer.SetSubData(0, sizeof(ViewportUniforms), &viewportUniforms); | ||
for (auto const& model : layer->models()) { | ||
|
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 |
---|---|---|
|
@@ -34,6 +34,8 @@ | |
|
||
namespace deckgl { | ||
|
||
/// \brief Deck is a class that takes deck.gl layer instances and viewport parameters, and renders those | ||
/// layers as a transparent overlay. | ||
class Deck : public Component { | ||
public: | ||
class Props; | ||
|
@@ -55,23 +57,40 @@ class Deck : public Component { | |
explicit Deck(std::shared_ptr<Deck::Props> props = std::make_shared<Deck::Props>()); | ||
~Deck(); | ||
|
||
/// \brief Returns the current properties attached to this Deck instance. | ||
auto props() { return std::dynamic_pointer_cast<Props>(this->_props); } | ||
|
||
/// \brief Sets a new set of properties, picking up all the differences compared to the current one. | ||
/// @param props A new set of properties to use. | ||
void setProps(std::shared_ptr<Deck::Props> props); | ||
|
||
/// \brief Runs an animation loop that draws this Deck. | ||
/// \param onAfterRender Function that'll be called whenever frame has been drawn. | ||
void run(std::function<void(Deck*)> onAfterRender = [](Deck*) {}); | ||
|
||
/// \brief Draws the current Deck state into the given textureView, calling onAfteRender once drawing has finished. | ||
/// \param textureView Texture view to draw the current state into. | ||
/// \param onAfterRender Function that'll be called whenever frame has been drawn. | ||
void draw( | ||
wgpu::TextureView textureView, std::function<void(Deck*)> onAfterRender = [](Deck*) {}); | ||
|
||
/// \brief Stops the animation loop, if one is currently running. | ||
void stop(); | ||
|
||
/// \brief Check if a redraw is needed. | ||
/// \param clearRedrawFlags Whether needsRedraw flag should be cleared or not. | ||
/// \returns Returns an optional string summarizing the redraw reason. | ||
auto needsRedraw(bool clearRedrawFlags = false) -> std::optional<std::string>; | ||
|
||
/// \brief Gets a list of views that this Deck is viewed from. | ||
/// \returns A list of View instances that this Deck can be viewed from. | ||
auto getViews() -> std::list<std::shared_ptr<View>> { return this->viewManager->getViews(); } | ||
|
||
/// \brief Gets the current viewport size of this Deck. | ||
/// \returns Width and height of the current viewport. | ||
auto size() -> lumagl::Size { return this->_size; }; | ||
|
||
// TODO([email protected]): These should be get-only? | ||
std::shared_ptr<lumagl::AnimationLoop> animationLoop; | ||
std::shared_ptr<ViewManager> viewManager{new ViewManager()}; | ||
std::shared_ptr<LayerContext> context; | ||
|
@@ -96,13 +115,17 @@ class Deck : public Component { | |
|
||
// Instead of maintaining another structure with options, we reuse the relevant struct from lumagl | ||
using DrawingOptions = lumagl::AnimationLoop::Options; | ||
/// \brief A set of properties that represent a single Deck. | ||
class Deck::Props : public Component::Props { | ||
public: | ||
using super = Component::Props; | ||
|
||
int width{100}; // Dummy value, ensure something is visible if user forgets to set window size | ||
/// \brief Width of the viewport, in pixels. | ||
int width{100}; // Dummy value, ensure something is visible if user forgets to set window size | ||
/// \brief Height of the viewport, in pixels. | ||
int height{100}; // Dummy value, ensure something is visible if user forgets to set window size | ||
|
||
/// \brief A set of options that customize the drawing of this Deck. | ||
std::shared_ptr<DrawingOptions> drawingOptions; | ||
|
||
// Layer/View/Controller settings | ||
|
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 |
---|---|---|
|
@@ -32,7 +32,7 @@ class Deck; | |
class LayerManager; | ||
class Viewport; | ||
|
||
/// \brief LayerContext is data shared between all layers. | ||
/// \brief LayerContext contains data shared between all layers. | ||
class LayerContext { | ||
public: | ||
// TODO([email protected]): Do we need to have this circular dependency here? | ||
|
Oops, something went wrong.