1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_VIZ_COMMON_QUADS_RENDER_PASS_DRAW_QUAD_H_
6 #define COMPONENTS_VIZ_COMMON_QUADS_RENDER_PASS_DRAW_QUAD_H_
7 
8 #include <stddef.h>
9 
10 #include <memory>
11 
12 #include "cc/paint/filter_operations.h"
13 #include "components/viz/common/quads/draw_quad.h"
14 #include "components/viz/common/quads/render_pass.h"
15 #include "components/viz/common/viz_common_export.h"
16 
17 #include "ui/gfx/geometry/point_f.h"
18 #include "ui/gfx/geometry/rect_f.h"
19 
20 namespace viz {
21 
22 class VIZ_COMMON_EXPORT RenderPassDrawQuad : public DrawQuad {
23  public:
24   static const size_t kMaskResourceIdIndex = 0;
25 
26   RenderPassDrawQuad();
27   RenderPassDrawQuad(const RenderPassDrawQuad& other);
28   ~RenderPassDrawQuad() override;
29 
30   void SetNew(const SharedQuadState* shared_quad_state,
31               const gfx::Rect& rect,
32               const gfx::Rect& visible_rect,
33               RenderPassId render_pass_id,
34               ResourceId mask_resource_id,
35               const gfx::RectF& mask_uv_rect,
36               const gfx::Size& mask_texture_size,
37               const gfx::Vector2dF& filters_scale,
38               const gfx::PointF& filters_origin,
39               const gfx::RectF& tex_coord_rect,
40               bool force_anti_aliasing_off,
41               float backdrop_filter_quality);
42 
43   void SetAll(const SharedQuadState* shared_quad_state,
44               const gfx::Rect& rect,
45               const gfx::Rect& visible_rect,
46               bool needs_blending,
47               RenderPassId render_pass_id,
48               ResourceId mask_resource_id,
49               const gfx::RectF& mask_uv_rect,
50               const gfx::Size& mask_texture_size,
51               const gfx::Vector2dF& filters_scale,
52               const gfx::PointF& filters_origin,
53               const gfx::RectF& tex_coord_rect,
54               bool force_anti_aliasing_off,
55               float backdrop_filter_quality,
56               bool can_use_backdrop_filter_cache);
57 
58   RenderPassId render_pass_id;
59   gfx::RectF mask_uv_rect;
60   gfx::Size mask_texture_size;
61 
62   // The scale from layer space of the root layer of the render pass to
63   // the render pass physical pixels. This scale is applied to the filter
64   // parameters for pixel-moving filters. This scale should include
65   // content-to-target-space scale, and device pixel ratio.
66   gfx::Vector2dF filters_scale;
67 
68   // The origin for post-processing filters which will be used to offset
69   // crop rects, lights, etc.
70   gfx::PointF filters_origin;
71 
72   gfx::RectF tex_coord_rect;
73 
74   float backdrop_filter_quality;
75 
76   bool force_anti_aliasing_off;
77 
78   // If the quad has backdrop filters, this flag indicates if the cached
79   // backdrop filtered result can be used instead of having to recompute the
80   // filter operation.
81   mutable bool can_use_backdrop_filter_cache;
82 
mask_resource_id()83   ResourceId mask_resource_id() const {
84     return resources.ids[kMaskResourceIdIndex];
85   }
86 
87   static const RenderPassDrawQuad* MaterialCast(const DrawQuad*);
88 
89  private:
90   void ExtendValue(base::trace_event::TracedValue* value) const override;
91 };
92 
93 }  // namespace viz
94 
95 #endif  // COMPONENTS_VIZ_COMMON_QUADS_RENDER_PASS_DRAW_QUAD_H_
96