Skip to content

Commit

Permalink
Add the new API for flushing
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Apr 12, 2024
1 parent 685ebdb commit 1c23d01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/c/gr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ SK_C_API void gr_direct_context_get_resource_cache_usage(gr_direct_context_t* co
SK_C_API void gr_direct_context_flush(gr_direct_context_t* context);
SK_C_API bool gr_direct_context_submit(gr_direct_context_t* context, bool syncCpu);
SK_C_API void gr_direct_context_flush_and_submit(gr_direct_context_t* context, bool syncCpu);
SK_C_API void gr_direct_context_flush_image(gr_direct_context_t* context, const sk_image_t* image);
SK_C_API void gr_direct_context_flush_surface(gr_direct_context_t* context, sk_surface_t* surface);
SK_C_API void gr_direct_context_reset_context(gr_direct_context_t* context, uint32_t state);
SK_C_API void gr_direct_context_dump_memory_statistics(const gr_direct_context_t* context, sk_tracememorydump_t* dump);
SK_C_API void gr_direct_context_free_gpu_resources(gr_direct_context_t* context);
Expand Down
11 changes: 11 additions & 0 deletions src/c/gr_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* found in the LICENSE file.
*/

#include "include/core/SkImage.h"
#include "include/core/SkSurface.h"

#include "include/c/gr_context.h"

#include "src/c/sk_types_priv.h"
Expand Down Expand Up @@ -115,6 +118,14 @@ void gr_direct_context_flush_and_submit(gr_direct_context_t* context, bool syncC
SK_ONLY_GPU(AsGrDirectContext(context)->flushAndSubmit(syncCpu));
}

void gr_direct_context_flush_image(gr_direct_context_t* context, const sk_image_t* image) {
SK_ONLY_GPU(AsGrDirectContext(context)->flush(sk_ref_sp(AsImage(image))));
}

void gr_direct_context_flush_surface(gr_direct_context_t* context, sk_surface_t* surface) {
SK_ONLY_GPU(AsGrDirectContext(context)->flush(sk_ref_sp(AsSurface(surface))));
}

void gr_direct_context_reset_context(gr_direct_context_t* context, uint32_t state) {
SK_ONLY_GPU(AsGrDirectContext(context)->resetContext(state));
}
Expand Down

0 comments on commit 1c23d01

Please sign in to comment.