• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Google LLC
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 "experimental/graphite/src/DrawList.h"
9 
10 #include "experimental/graphite/src/Renderer.h"
11 #include "src/gpu/BufferWriter.h"
12 
13 namespace skgpu {
14 
deduplicateTransform(const Transform & localToDevice)15 const Transform& DrawList::deduplicateTransform(const Transform& localToDevice) {
16     // TODO: This is a pretty simple deduplication strategy and doesn't take advantage of the stack
17     // knowledge that Device has.
18     if (fTransforms.empty() || fTransforms.back() != localToDevice) {
19         fTransforms.push_back(localToDevice);
20     }
21     return fTransforms.back();
22 }
23 
stencilAndFillPath(const Transform & localToDevice,const Shape & shape,const Clip & clip,DrawOrder ordering,const PaintParams * paint)24 void DrawList::stencilAndFillPath(const Transform& localToDevice,
25                                   const Shape& shape,
26                                   const Clip& clip,
27                                   DrawOrder ordering,
28                                   const PaintParams* paint) {
29     SkASSERT(localToDevice.valid());
30     SkASSERT(!shape.isEmpty() && !clip.drawBounds().isEmptyNegativeOrNaN());
31 
32     const Renderer& renderer = Renderer::StencilAndFillPath(shape.fillType());
33     fDraws.push_back({renderer, this->deduplicateTransform(localToDevice),
34                       shape, clip, ordering, paint, nullptr});
35     fRenderStepCount += renderer.numRenderSteps();
36 }
37 
fillConvexPath(const Transform & localToDevice,const Shape & shape,const Clip & clip,DrawOrder ordering,const PaintParams * paint)38 void DrawList::fillConvexPath(const Transform& localToDevice,
39                               const Shape& shape,
40                               const Clip& clip,
41                               DrawOrder ordering,
42                               const PaintParams* paint) {
43     SkASSERT(localToDevice.valid());
44     SkASSERT(!shape.isEmpty() && !clip.drawBounds().isEmptyNegativeOrNaN());
45     // TODO actually record this, but for now just drop the draw since the Renderer
46     // isn't implemented yet
47     // fDraws.push_back({Renderer::FillConvexPath(),
48     //                   this->deduplicateTransform(localToDevice),
49     //                   shape, clip, ordering, paint, nullptr});
50     // fRenderStepCount += Renderer::FillConvexPath().numRenderSteps();
51 }
52 
strokePath(const Transform & localToDevice,const Shape & shape,const StrokeParams & stroke,const Clip & clip,DrawOrder ordering,const PaintParams * paint)53 void DrawList::strokePath(const Transform& localToDevice,
54                           const Shape& shape,
55                           const StrokeParams& stroke,
56                           const Clip& clip,
57                           DrawOrder ordering,
58                           const PaintParams* paint) {
59     SkASSERT(localToDevice.valid());
60     SkASSERT(!shape.isEmpty() && !clip.drawBounds().isEmptyNegativeOrNaN());
61     // TODO actually record this, but for now just drop the draw since the Renderer
62     // isn't implemented yet
63     // fDraws.push_back({Renderer::StrokePath(),
64     //                   this->deduplicateTransform(localToDevice),
65     //                   shape, clip, ordering, paint, stroke});
66     // fRenderStepCount += Renderer::StrokePath().numRenderSteps();
67 }
68 
69 } // namespace skgpu
70