Repository: google/filament
File: filament/backend/include/backend/Platform.h (C/C++)

Code before:
     * same key, in which case newer values should overwrite older values.
     *
     * This function is guaranteed to be called only on a single thread, the Filament driver
     * thread.
     *
     * @param key           a null-terminated C-string with the key of the debug statistic
     * @param intValue      the updated integer value of key (the string value passed to the
     *                      callback will be empty)
     */
    void debugUpdateStat(const char* UTILS_NONNULL key, uint64_t intValue);

    /**
     * To track backend-specific statistics, the backend implementation can call the
     * application-provided callback function debugUpdateStatFunc to associate or update a value
     * with a given key. It is possible for this function to be called multiple times with the
     * same key, in which case newer values should overwrite older values.
     *
     * This function is guaranteed to be called only on a single thread, the Filament driver
     * thread.
     *
     * @param key           a null-terminated C-string with the key of the debug statistic
     * @param stringValue   the updated string value of key (the integer value passed to the
     *                      callback will be 0)
     */
    void debugUpdateStat(const char* UTILS_NONNULL key, utils::CString stringValue);

private:
    InsertBlobFunc mInsertBlob;
    RetrieveBlobFunc mRetrieveBlob;
    DebugUpdateStatFunc mDebugUpdateStat;
};

} // namespace filament

#endif // TNT_FILAMENT_BACKEND_PLATFORM_H


Review comment (suggestion):
We should document in big capital letters that only short and non blocking work should be done in the callback and that GL calls are forbidden, because it's called from the backend thread.

Code after:
     */
    bool hasDebugUpdateStatFunc() const noexcept;

    /**
     * To track backend-specific statistics, the backend implementation can call the
     * application-provided callback function debugUpdateStatFunc to associate or update a value
     * with a given key. It is possible for this function to be called multiple times with the
     * same key, in which case newer values should overwrite older values.
     *
     * This function is guaranteed to be called only on a single thread, the Filament driver
     * thread.
     *
     * @param key           a null-terminated C-string with the key of the debug statistic
     * @param intValue      the updated integer value of key (the string value passed to the
     *                      callback will be empty)
     */
    void debugUpdateStat(const char* UTILS_NONNULL key, uint64_t intValue);

    /**
     * To track backend-specific statistics, the backend implementation can call the
     * application-provided callback function debugUpdateStatFunc to associate or update a value
     * with a given key. It is possible for this function to be called multiple times with the
     * same key, in which case newer values should overwrite older values.
     *
     * This function is guaranteed to be called only on a single thread, the Filament driver
     * thread.
     *
     * @param key           a null-terminated C-string with the key of the debug statistic
     * @param stringValue   the updated string value of key (the integer value passed to the
     *                      callback will be 0)
     */
    void debugUpdateStat(const char* UTILS_NONNULL key, utils::CString stringValue);

private:
    std::shared_ptr<InsertBlobFunc> mInsertBlob;
    std::shared_ptr<RetrieveBlobFunc> mRetrieveBlob;
    std::shared_ptr<DebugUpdateStatFunc> mDebugUpdateStat;
    mutable utils::Mutex mMutex;
};

} // namespace filament

#endif // TNT_FILAMENT_BACKEND_PLATFORM_H