Skip to content

Commit

Permalink
matdbg: refactor EDIT command (google#7255)
Browse files Browse the repository at this point in the history
The websocket code for parsing the EDIT command is pretty verbose.
Proposing that we move to a HTTP POST request instead.

Also moved the API handler code out of DebugServer.h for clarity.
  • Loading branch information
poweifeng authored and plepers committed Dec 9, 2023
1 parent 409cbe9 commit 7233628
Show file tree
Hide file tree
Showing 6 changed files with 451 additions and 366 deletions.
3 changes: 2 additions & 1 deletion libs/matdbg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ set(PUBLIC_HDRS
)

set(SRCS
src/ApiHandler.cpp
src/ApiHandler.h
src/CommonWriter.h
src/CommonWriter.cpp
src/DebugServer.cpp
Expand Down Expand Up @@ -59,7 +61,6 @@ endif()
set(DUMMY_SRC "${RESOURCE_DIR}/dummy.c")
add_custom_command(OUTPUT ${DUMMY_SRC} COMMAND echo "//" > ${DUMMY_SRC})


add_library(matdbg_resources ${DUMMY_SRC} ${RESGEN_SOURCE})
set_target_properties(matdbg_resources PROPERTIES FOLDER Libs)

Expand Down
33 changes: 17 additions & 16 deletions libs/matdbg/include/matdbg/DebugServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@

class CivetServer;

namespace filament {
namespace matdbg {
namespace filament::matdbg {

using MaterialKey = uint32_t;

struct MaterialRecord {
void* userdata;
const uint8_t* package;
size_t packageSize;
utils::CString name;
MaterialKey key;
VariantList activeVariants;
};

/**
* Server-side material debugger.
*
Expand All @@ -41,6 +49,9 @@ using MaterialKey = uint32_t;
*/
class DebugServer {
public:
static std::string_view const kSuccessHeader;
static std::string_view const kErrorHeader;

DebugServer(backend::Backend backend, int port);
~DebugServer();

Expand Down Expand Up @@ -74,16 +85,7 @@ class DebugServer {
bool isReady() const { return mServer; }

private:
struct MaterialRecord {
void* userdata;
const uint8_t* package;
size_t packageSize;
utils::CString name;
MaterialKey key;
VariantList activeVariants;
};

const MaterialRecord* getRecord(const MaterialKey& key) const;
MaterialRecord const* getRecord(const MaterialKey& key) const;

void updateActiveVariants();

Expand All @@ -109,15 +111,14 @@ class DebugServer {
QueryCallback mQueryCallback = nullptr;

class FileRequestHandler* mFileHandler = nullptr;
class RestRequestHandler* mRestHandler = nullptr;
class ApiHandler* mApiHandler = nullptr;
class WebSocketHandler* mWebSocketHandler = nullptr;

friend class FileRequestHandler;
friend class RestRequestHandler;
friend class ApiHandler;
friend class WebSocketHandler;
};

} // namespace matdbg
} // namespace filament
} // namespace filament::matdbg

#endif // MATDBG_DEBUGSERVER_H
Loading

0 comments on commit 7233628

Please sign in to comment.