1 // Copyright 2020 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_INTERNAL_H_ 6 #define COMPONENTS_VIZ_COMMON_QUADS_RENDER_PASS_INTERNAL_H_ 7 8 #include <stddef.h> 9 10 #include <memory> 11 #include <vector> 12 13 #include "base/optional.h" 14 #include "cc/paint/filter_operations.h" 15 #include "components/viz/common/quads/quad_list.h" 16 #include "components/viz/common/viz_common_export.h" 17 #include "ui/gfx/display_color_spaces.h" 18 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/rrect_f.h" 20 #include "ui/gfx/transform.h" 21 22 namespace viz { 23 class SharedQuadState; 24 class CopyOutputRequest; 25 26 using SharedQuadStateList = cc::ListContainer<SharedQuadState>; 27 28 // This class represents common data that is shared between the compositor and 29 // aggregated render passes. 30 class VIZ_COMMON_EXPORT RenderPassInternal { 31 public: 32 SharedQuadState* CreateAndAppendSharedQuadState(); 33 34 // Replaces a quad in |quad_list| with a transparent black SolidColorQuad. 35 void ReplaceExistingQuadWithOpaqueTransparentSolidColor( 36 QuadList::Iterator at); 37 38 // These are in the space of the render pass' physical pixels. 39 gfx::Rect output_rect; 40 gfx::Rect damage_rect; 41 42 // Transforms from the origin of the |output_rect| to the origin of the root 43 // render pass' |output_rect|. 44 gfx::Transform transform_to_root_target; 45 46 // Post-processing filters, applied to the pixels in the render pass' texture. 47 cc::FilterOperations filters; 48 49 // Post-processing filters, applied to the pixels showing through the 50 // backdrop of the render pass, from behind it. 51 cc::FilterOperations backdrop_filters; 52 53 // Clipping bounds for backdrop filter. 54 base::Optional<gfx::RRectF> backdrop_filter_bounds; 55 56 // If false, the pixels in the render pass' texture are all opaque. 57 bool has_transparent_background = true; 58 59 // If true we might reuse the texture if there is no damage. 60 bool cache_render_pass = false; 61 // Indicates whether there is accumulated damage from contributing render 62 // surface or layer or surface quad. Not including property changes on itself. 63 bool has_damage_from_contributing_content = false; 64 65 // Generate mipmap for trilinear filtering, applied to render pass' texture. 66 bool generate_mipmap = false; 67 68 // If non-empty, the renderer should produce a copy of the render pass' 69 // contents as a bitmap, and give a copy of the bitmap to each callback in 70 // this list. 71 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests; 72 73 QuadList quad_list; 74 SharedQuadStateList shared_quad_state_list; 75 76 template <typename RenderPassType> CopyAllForTest(const std::vector<std::unique_ptr<RenderPassType>> & in,std::vector<std::unique_ptr<RenderPassType>> * out)77 static void CopyAllForTest( 78 const std::vector<std::unique_ptr<RenderPassType>>& in, 79 std::vector<std::unique_ptr<RenderPassType>>* out) { 80 for (const auto& source : in) 81 out->push_back(source->DeepCopy()); 82 } 83 84 protected: 85 RenderPassInternal(); 86 explicit RenderPassInternal(size_t num_layers); 87 RenderPassInternal(size_t shared_quad_state_list_size, size_t quad_list_size); 88 89 ~RenderPassInternal(); 90 91 private: 92 DISALLOW_COPY_AND_ASSIGN(RenderPassInternal); 93 }; 94 95 } // namespace viz 96 97 #endif // COMPONENTS_VIZ_COMMON_QUADS_RENDER_PASS_INTERNAL_H_ 98