OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 CC_OUTPUT_DC_LAYER_OVERLAY_H_ |
| 6 #define CC_OUTPUT_DC_LAYER_OVERLAY_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "cc/quads/render_pass.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "third_party/skia/include/core/SkMatrix44.h" |
| 12 #include "ui/gfx/geometry/rect_f.h" |
| 13 #include "ui/gl/dc_renderer_layer_params.h" |
| 14 |
| 15 namespace cc { |
| 16 class DrawQuad; |
| 17 class ResourceProvider; |
| 18 |
| 19 class CC_EXPORT DCLayerOverlaySharedState |
| 20 : public base::RefCounted<DCLayerOverlaySharedState> { |
| 21 public: |
| 22 DCLayerOverlaySharedState() {} |
| 23 int z_order = 0; |
| 24 // If |is_clipped| is true, then clip to |clip_rect| in the target space. |
| 25 bool is_clipped = false; |
| 26 gfx::RectF clip_rect; |
| 27 // The opacity property for the CAayer. |
| 28 float opacity = 1; |
| 29 // The transform to apply to the DCLayer. |
| 30 SkMatrix44 transform = SkMatrix44(SkMatrix44::kIdentity_Constructor); |
| 31 |
| 32 private: |
| 33 friend class base::RefCounted<DCLayerOverlaySharedState>; |
| 34 ~DCLayerOverlaySharedState() {} |
| 35 }; |
| 36 |
| 37 // Holds all information necessary to construct a DCLayer from a DrawQuad. |
| 38 class CC_EXPORT DCLayerOverlay { |
| 39 public: |
| 40 DCLayerOverlay(); |
| 41 DCLayerOverlay(const DCLayerOverlay& other); |
| 42 ~DCLayerOverlay(); |
| 43 |
| 44 // State that is frequently shared between consecutive DCLayerOverlays. |
| 45 scoped_refptr<DCLayerOverlaySharedState> shared_state; |
| 46 |
| 47 // Texture that corresponds to an IOSurface to set as the content of the |
| 48 // DCLayer. If this is 0 then the DCLayer is a solid color. |
| 49 unsigned contents_resource_id = 0; |
| 50 // The contents rect property for the DCLayer. |
| 51 gfx::RectF contents_rect; |
| 52 // The bounds for the DCLayer in pixels. |
| 53 gfx::RectF bounds_rect; |
| 54 // The background color property for the DCLayer. |
| 55 SkColor background_color = SK_ColorTRANSPARENT; |
| 56 // The edge anti-aliasing mask property for the DCLayer. |
| 57 unsigned edge_aa_mask = 0; |
| 58 // The minification and magnification filters for the DCLayer. |
| 59 unsigned filter; |
| 60 // If |rpdq| is present, then the renderer must draw the filter effects and |
| 61 // copy the result into an IOSurface. |
| 62 const RenderPassDrawQuad* rpdq = nullptr; |
| 63 }; |
| 64 |
| 65 typedef std::vector<DCLayerOverlay> DCLayerOverlayList; |
| 66 |
| 67 class DCLayerOverlayProcessor { |
| 68 public: |
| 69 enum DCLayerResult { |
| 70 DC_LAYER_SUCCESS, |
| 71 DC_LAYER_FAILED_QUAD_BLEND_MODE, |
| 72 DC_LAYER_FAILED_TEXTURE_NOT_CANDIDATE, |
| 73 DC_LAYER_FAILED_OCCLUDED, |
| 74 DC_LAYER_FAILED_UNKNOWN |
| 75 }; |
| 76 |
| 77 void Process(ResourceProvider* resource_provider, |
| 78 const gfx::RectF& display_rect, |
| 79 QuadList* quad_list, |
| 80 gfx::Rect* overlay_damage_rect, |
| 81 gfx::Rect* damage_rect, |
| 82 DCLayerOverlayList* ca_layer_overlays); |
| 83 void ClearOverlayState() { |
| 84 previous_frame_underlay_rect_ = gfx::Rect(); |
| 85 previous_occlusion_bounding_box_ = gfx::Rect(); |
| 86 } |
| 87 |
| 88 private: |
| 89 DCLayerResult FromDrawQuad(ResourceProvider* resource_provider, |
| 90 const gfx::RectF& display_rect, |
| 91 QuadList::ConstIterator quad_list_begin, |
| 92 QuadList::ConstIterator quad, |
| 93 DCLayerOverlay* ca_layer_overlay); |
| 94 |
| 95 gfx::Rect previous_frame_underlay_rect_; |
| 96 gfx::Rect previous_occlusion_bounding_box_; |
| 97 }; |
| 98 |
| 99 } // namespace cc |
| 100 |
| 101 #endif // CC_OUTPUT_DC_LAYER_OVERLAY_H_ |
OLD | NEW |