blob: 7160f2036a478a8005d64160560f9f3b54660d82 [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
8#include "GrSemaphoreOp.h"
9
Robert Phillips7c525e62018-06-12 10:11:12 -040010#include "GrContext.h"
11#include "GrContextPriv.h"
Greg Danielfe71b9d2017-03-09 10:41:31 -050012#include "GrGpu.h"
Robert Phillips7c525e62018-06-12 10:11:12 -040013#include "GrMemoryPool.h"
Greg Danielfe71b9d2017-03-09 10:41:31 -050014#include "GrOpFlushState.h"
15
Greg Danielfe71b9d2017-03-09 10:41:31 -050016class GrWaitSemaphoreOp final : public GrSemaphoreOp {
17public:
18 DEFINE_OP_CLASS_ID
19
Robert Phillips7c525e62018-06-12 10:11:12 -040020 static std::unique_ptr<GrOp> Make(GrContext* context,
21 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 Phillips7c525e62018-06-12 10:11:12 -040045std::unique_ptr<GrOp> GrSemaphoreOp::MakeWait(GrContext* context,
46 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