blob: e13e2449e3eff9d894cd2edcc5cf5d41bae84ca2 [file] [log] [blame]
Greg Danielfe71b9d2017-03-09 10:41:31 -05001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/ops/GrSemaphoreOp.h"
Greg Danielfe71b9d2017-03-09 10:41:31 -05009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/private/GrRecordingContext.h"
11#include "src/gpu/GrGpu.h"
12#include "src/gpu/GrMemoryPool.h"
13#include "src/gpu/GrOpFlushState.h"
14#include "src/gpu/GrRecordingContextPriv.h"
Greg Danielfe71b9d2017-03-09 10:41:31 -050015
Greg Danielfe71b9d2017-03-09 10:41:31 -050016class GrWaitSemaphoreOp final : public GrSemaphoreOp {
17public:
18 DEFINE_OP_CLASS_ID
19
Robert Phillipsb97da532019-02-12 15:24:12 -050020 static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
Robert Phillips7c525e62018-06-12 10:11:12 -040021 sk_sp<GrSemaphore> semaphore,
22 GrRenderTargetProxy* proxy) {
Robert Phillips9da87e02019-02-04 13:26:26 -050023 GrOpMemoryPool* pool = context->priv().opMemoryPool();
Robert Phillipsc994a932018-06-19 13:09:54 -040024
25 return pool->allocate<GrWaitSemaphoreOp>(std::move(semaphore), proxy);
Greg Danielfe71b9d2017-03-09 10:41:31 -050026 }
27
28 const char* name() const override { return "WaitSemaphore"; }
29
30private:
Robert Phillips7c525e62018-06-12 10:11:12 -040031 friend class GrOpMemoryPool; // for ctor
32
Greg Daniela5cb7812017-06-16 09:45:32 -040033 explicit GrWaitSemaphoreOp(sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy)
34 : INHERITED(ClassID(), std::move(semaphore), proxy) {}
Greg Danielfe71b9d2017-03-09 10:41:31 -050035
Brian Salomon588cec72018-11-14 13:56:37 -050036 void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override {
Greg Danielfe71b9d2017-03-09 10:41:31 -050037 state->gpu()->waitSemaphore(fSemaphore);
38 }
39
40 typedef GrSemaphoreOp INHERITED;
41};
42
43////////////////////////////////////////////////////////////////////////////////
44
Robert Phillipsb97da532019-02-12 15:24:12 -050045std::unique_ptr<GrOp> GrSemaphoreOp::MakeWait(GrRecordingContext* context,
Robert Phillips7c525e62018-06-12 10:11:12 -040046 sk_sp<GrSemaphore> semaphore,
47 GrRenderTargetProxy* proxy) {
48 return GrWaitSemaphoreOp::Make(context, std::move(semaphore), proxy);
Greg Danielfe71b9d2017-03-09 10:41:31 -050049}
50
51