Line data Source code
1 : /*
2 : * Copyright 2016 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 GrGLGpuCommandBuffer_DEFINED
9 : #define GrGLGpuCommandBuffer_DEFINED
10 :
11 : #include "GrGpuCommandBuffer.h"
12 :
13 : #include "GrGLGpu.h"
14 : #include "GrOpFlushState.h"
15 :
16 : class GrGLRenderTarget;
17 :
18 : class GrGLGpuCommandBuffer : public GrGpuCommandBuffer {
19 : /**
20 : * We do not actually buffer up draws or do any work in the this class for GL. Instead commands
21 : * are immediately sent to the gpu to execute. Thus all the commands in this class are simply
22 : * pass through functions to corresponding calls in the GrGLGpu class.
23 : */
24 : public:
25 0 : GrGLGpuCommandBuffer(GrGLGpu* gpu) : fGpu(gpu), fRenderTarget(nullptr) {}
26 :
27 0 : ~GrGLGpuCommandBuffer() override {}
28 :
29 0 : void end() override {}
30 :
31 0 : void discard(GrRenderTarget* rt) override {
32 0 : GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt);
33 0 : if (!fRenderTarget) {
34 0 : fRenderTarget = target;
35 : }
36 0 : SkASSERT(target == fRenderTarget);
37 0 : }
38 :
39 0 : void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload,
40 : GrRenderTarget*) override {
41 0 : state->doUpload(upload);
42 0 : }
43 :
44 : private:
45 0 : GrGpu* gpu() override { return fGpu; }
46 0 : GrRenderTarget* renderTarget() override { return fRenderTarget; }
47 :
48 0 : void onSubmit() override {}
49 :
50 0 : void onDraw(const GrPipeline& pipeline,
51 : const GrPrimitiveProcessor& primProc,
52 : const GrMesh* mesh,
53 : int meshCount,
54 : const SkRect& bounds) override {
55 0 : GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget());
56 0 : if (!fRenderTarget) {
57 0 : fRenderTarget = target;
58 : }
59 0 : SkASSERT(target == fRenderTarget);
60 0 : fGpu->draw(pipeline, primProc, mesh, meshCount);
61 0 : }
62 :
63 0 : void onClear(GrRenderTarget* rt, const GrFixedClip& clip, GrColor color) override {
64 0 : GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt);
65 0 : if (!fRenderTarget) {
66 0 : fRenderTarget = target;
67 : }
68 0 : SkASSERT(target == fRenderTarget);
69 0 : fGpu->clear(clip, color, fRenderTarget);
70 0 : }
71 :
72 0 : void onClearStencilClip(GrRenderTarget* rt, const GrFixedClip& clip,
73 : bool insideStencilMask) override {
74 0 : GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(rt);
75 0 : if (!fRenderTarget) {
76 0 : fRenderTarget = target;
77 : }
78 0 : SkASSERT(target == fRenderTarget);
79 0 : fGpu->clearStencilClip(clip, insideStencilMask, fRenderTarget);
80 0 : }
81 :
82 : GrGLGpu* fGpu;
83 : GrGLRenderTarget* fRenderTarget;
84 :
85 : typedef GrGpuCommandBuffer INHERITED;
86 : };
87 :
88 : #endif
89 :
|