OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_ | 5 #ifndef CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_ |
6 #define CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_ | 6 #define CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_ |
7 | 7 |
8 #include "cc/base/cc_export.h" | 8 #include "cc/base/cc_export.h" |
9 #include "cc/output/overlay_candidate.h" | 9 #include "cc/output/overlay_candidate.h" |
10 #include "cc/output/overlay_processor.h" | 10 #include "cc/output/overlay_processor.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 class IOSurfaceDrawQuad; | 13 class IOSurfaceDrawQuad; |
14 class OverlayCandidate; | 14 class OverlayCandidate; |
15 class OverlayCandidateValidator; | 15 class OverlayCandidateValidator; |
16 class StreamVideoDrawQuad; | 16 class StreamVideoDrawQuad; |
17 class TextureDrawQuad; | 17 class TextureDrawQuad; |
18 | 18 |
| 19 enum OverlayResult { |
| 20 DID_NOT_CREATE_OVERLAY, |
| 21 CREATED_OVERLAY_STOP_LOOKING, |
| 22 CREATED_OVERLAY_KEEP_LOOKING, |
| 23 }; |
| 24 |
19 class CC_EXPORT OverlayStrategyCommonDelegate { | 25 class CC_EXPORT OverlayStrategyCommonDelegate { |
20 public: | 26 public: |
21 virtual ~OverlayStrategyCommonDelegate() {} | 27 virtual ~OverlayStrategyCommonDelegate() {} |
22 virtual bool TryOverlay(OverlayCandidateValidator* capability_checker, | 28 |
23 RenderPassList* render_passes_in_draw_order, | 29 // Check if |candidate| can be promoted into an overlay. If so, add it to |
24 OverlayCandidateList* candidate_list, | 30 // |candidate_list| and update the quads in |render_passes_in_draw_order| |
25 const OverlayCandidate& candidate, | 31 // as necessary. When returning CREATED_OVERLAY_KEEP_LOOKING, |iter| is |
26 QuadList::Iterator iter, | 32 // updated to point to the next quad to evaluate. |
27 float device_scale_factor) = 0; | 33 virtual OverlayResult TryOverlay( |
| 34 OverlayCandidateValidator* capability_checker, |
| 35 RenderPassList* render_passes_in_draw_order, |
| 36 OverlayCandidateList* candidate_list, |
| 37 const OverlayCandidate& candidate, |
| 38 QuadList::Iterator* iter, |
| 39 float device_scale_factor) = 0; |
28 }; | 40 }; |
29 | 41 |
30 class CC_EXPORT OverlayStrategyCommon : public OverlayProcessor::Strategy { | 42 class CC_EXPORT OverlayStrategyCommon : public OverlayProcessor::Strategy { |
31 public: | 43 public: |
32 explicit OverlayStrategyCommon(OverlayCandidateValidator* capability_checker, | 44 explicit OverlayStrategyCommon(OverlayCandidateValidator* capability_checker, |
33 OverlayStrategyCommonDelegate* delegate); | 45 OverlayStrategyCommonDelegate* delegate); |
34 ~OverlayStrategyCommon() override; | 46 ~OverlayStrategyCommon() override; |
35 | 47 |
36 bool Attempt(RenderPassList* render_passes_in_draw_order, | 48 bool Attempt(RenderPassList* render_passes_in_draw_order, |
37 OverlayCandidateList* candidate_list, | 49 OverlayCandidateList* candidate_list, |
38 float device_scale_factor) override; | 50 float device_scale_factor) override; |
39 | 51 |
40 // Returns true if |draw_quad| will not block quads underneath from becoming | 52 // Returns true if |draw_quad| will not block quads underneath from becoming |
41 // an overlay. | 53 // an overlay. |
42 static bool IsInvisibleQuad(const DrawQuad* draw_quad); | 54 static bool IsInvisibleQuad(const DrawQuad* draw_quad); |
43 | 55 |
44 protected: | 56 protected: |
| 57 // Returns true if |draw_quad| is of a known quad type and contains an |
| 58 // overlayable resource. |
45 bool GetCandidateQuadInfo(const DrawQuad& draw_quad, | 59 bool GetCandidateQuadInfo(const DrawQuad& draw_quad, |
46 OverlayCandidate* quad_info); | 60 OverlayCandidate* quad_info); |
47 | |
48 // Returns true if |draw_quad| is of a known quad type and contains an | |
49 // overlayable resource. | |
50 bool IsOverlayQuad(const DrawQuad* draw_quad); | |
51 | |
52 bool GetTextureQuadInfo(const TextureDrawQuad& quad, | 61 bool GetTextureQuadInfo(const TextureDrawQuad& quad, |
53 OverlayCandidate* quad_info); | 62 OverlayCandidate* quad_info); |
54 bool GetVideoQuadInfo(const StreamVideoDrawQuad& quad, | 63 bool GetVideoQuadInfo(const StreamVideoDrawQuad& quad, |
55 OverlayCandidate* quad_info); | 64 OverlayCandidate* quad_info); |
56 bool GetIOSurfaceQuadInfo(const IOSurfaceDrawQuad& quad, | 65 bool GetIOSurfaceQuadInfo(const IOSurfaceDrawQuad& quad, |
57 OverlayCandidate* quad_info); | 66 OverlayCandidate* quad_info); |
58 | 67 |
59 private: | 68 private: |
60 OverlayCandidateValidator* capability_checker_; | 69 OverlayCandidateValidator* capability_checker_; |
61 scoped_ptr<OverlayStrategyCommonDelegate> delegate_; | 70 scoped_ptr<OverlayStrategyCommonDelegate> delegate_; |
62 | 71 |
63 DISALLOW_COPY_AND_ASSIGN(OverlayStrategyCommon); | 72 DISALLOW_COPY_AND_ASSIGN(OverlayStrategyCommon); |
64 }; | 73 }; |
65 } // namespace cc | 74 } // namespace cc |
66 | 75 |
67 #endif // CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_ | 76 #endif // CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_ |
OLD | NEW |