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
3 // found in the LICENSE file.
5 #ifndef CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_
6 #define CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/output/overlay_candidate.h"
10 #include "cc/output/overlay_processor.h"
13 class IOSurfaceDrawQuad
;
14 class OverlayCandidate
;
15 class OverlayCandidateValidator
;
16 class StreamVideoDrawQuad
;
17 class TextureDrawQuad
;
20 DID_NOT_CREATE_OVERLAY
,
21 CREATED_OVERLAY_STOP_LOOKING
,
22 CREATED_OVERLAY_KEEP_LOOKING
,
25 class CC_EXPORT OverlayStrategyCommonDelegate
{
27 virtual ~OverlayStrategyCommonDelegate() {}
29 // Check if |candidate| can be promoted into an overlay. If so, add it to
30 // |candidate_list| and update the quads in |render_passes_in_draw_order|
31 // as necessary. When returning CREATED_OVERLAY_KEEP_LOOKING, |iter| is
32 // updated to point to the next quad to evaluate.
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;
42 class CC_EXPORT OverlayStrategyCommon
: public OverlayProcessor::Strategy
{
44 explicit OverlayStrategyCommon(OverlayCandidateValidator
* capability_checker
,
45 OverlayStrategyCommonDelegate
* delegate
);
46 ~OverlayStrategyCommon() override
;
48 bool Attempt(RenderPassList
* render_passes_in_draw_order
,
49 OverlayCandidateList
* candidate_list
,
50 float device_scale_factor
) override
;
52 // Returns true if |draw_quad| will not block quads underneath from becoming
54 static bool IsInvisibleQuad(const DrawQuad
* draw_quad
);
57 // Returns true if |draw_quad| is of a known quad type and contains an
58 // overlayable resource.
59 bool GetCandidateQuadInfo(const DrawQuad
& draw_quad
,
60 OverlayCandidate
* quad_info
);
61 bool GetTextureQuadInfo(const TextureDrawQuad
& quad
,
62 OverlayCandidate
* quad_info
);
63 bool GetVideoQuadInfo(const StreamVideoDrawQuad
& quad
,
64 OverlayCandidate
* quad_info
);
65 bool GetIOSurfaceQuadInfo(const IOSurfaceDrawQuad
& quad
,
66 OverlayCandidate
* quad_info
);
69 OverlayCandidateValidator
* capability_checker_
;
70 scoped_ptr
<OverlayStrategyCommonDelegate
> delegate_
;
72 DISALLOW_COPY_AND_ASSIGN(OverlayStrategyCommon
);
76 #endif // CC_OUTPUT_OVERLAY_STRATEGY_COMMON_H_