1 /*
2  * Copyright 2018 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 #ifndef GrDrawableOp_DEFINED
9 #define GrDrawableOp_DEFINED
10 
11 #include "src/gpu/ops/GrOp.h"
12 
13 #include "include/core/SkDrawable.h"
14 #include "include/core/SkMatrix.h"
15 #include "src/gpu/GrSemaphore.h"
16 
17 class GrRecordingContext;
18 
19 class GrDrawableOp final : public GrOp {
20 public:
21     DEFINE_OP_CLASS_ID
22 
23     static GrOp::Owner Make(GrRecordingContext*,
24                             std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
25                             const SkRect& bounds);
26 
name()27     const char* name() const override { return "Drawable"; }
28 
29 private:
30     friend class GrOp; // for ctor
31 
32     GrDrawableOp(std::unique_ptr<SkDrawable::GpuDrawHandler>, const SkRect& bounds);
33 
onCombineIfPossible(GrOp * that,SkArenaAlloc *,const GrCaps & caps)34     CombineResult onCombineIfPossible(GrOp* that, SkArenaAlloc*, const GrCaps& caps) override {
35         return CombineResult::kCannotCombine;
36     }
37 
onPrePrepare(GrRecordingContext *,const GrSurfaceProxyView & writeView,GrAppliedClip *,const GrXferProcessor::DstProxyView &,GrXferBarrierFlags renderPassXferBarriers,GrLoadOp colorLoadOp)38     void onPrePrepare(GrRecordingContext*,
39                       const GrSurfaceProxyView& writeView,
40                       GrAppliedClip*,
41                       const GrXferProcessor::DstProxyView&,
42                       GrXferBarrierFlags renderPassXferBarriers,
43                       GrLoadOp colorLoadOp) override {}
44 
onPrepare(GrOpFlushState *)45     void onPrepare(GrOpFlushState*) override {}
46 
47     void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
48 
49     std::unique_ptr<SkDrawable::GpuDrawHandler> fDrawable;
50 
51     using INHERITED = GrOp;
52 };
53 
54 #endif
55 
56