GrSemaphoreOp.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2017 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "src/gpu/ops/GrSemaphoreOp.h"
  8. #include "include/private/GrRecordingContext.h"
  9. #include "src/gpu/GrGpu.h"
  10. #include "src/gpu/GrMemoryPool.h"
  11. #include "src/gpu/GrOpFlushState.h"
  12. #include "src/gpu/GrRecordingContextPriv.h"
  13. class GrWaitSemaphoreOp final : public GrSemaphoreOp {
  14. public:
  15. DEFINE_OP_CLASS_ID
  16. static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
  17. sk_sp<GrSemaphore> semaphore,
  18. GrRenderTargetProxy* proxy) {
  19. GrOpMemoryPool* pool = context->priv().opMemoryPool();
  20. return pool->allocate<GrWaitSemaphoreOp>(std::move(semaphore), proxy);
  21. }
  22. const char* name() const override { return "WaitSemaphore"; }
  23. private:
  24. friend class GrOpMemoryPool; // for ctor
  25. explicit GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy)
  26. : INHERITED(ClassID(), std::move(semaphore), proxy) {}
  27. void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override {
  28. state->gpu()->waitSemaphore(fSemaphore);
  29. }
  30. typedef GrSemaphoreOp INHERITED;
  31. };
  32. ////////////////////////////////////////////////////////////////////////////////
  33. std::unique_ptr<GrOp> GrSemaphoreOp::MakeWait(GrRecordingContext* context,
  34. sk_sp<GrSemaphore> semaphore,
  35. GrRenderTargetProxy* proxy) {
  36. return GrWaitSemaphoreOp::Make(context, std::move(semaphore), proxy);
  37. }