OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_DIRECT_RENDERER_H_ | 5 #ifndef CC_OUTPUT_DIRECT_RENDERER_H_ |
6 #define CC_OUTPUT_DIRECT_RENDERER_H_ | 6 #define CC_OUTPUT_DIRECT_RENDERER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 gfx::RectF root_damage_rect; | 43 gfx::RectF root_damage_rect; |
44 | 44 |
45 gfx::Transform projection_matrix; | 45 gfx::Transform projection_matrix; |
46 gfx::Transform window_matrix; | 46 gfx::Transform window_matrix; |
47 bool flipped_y; | 47 bool flipped_y; |
48 }; | 48 }; |
49 | 49 |
50 void SetEnlargePassTextureAmountForTesting(gfx::Vector2d amount); | 50 void SetEnlargePassTextureAmountForTesting(gfx::Vector2d amount); |
51 | 51 |
52 protected: | 52 protected: |
53 DirectRenderer(RendererClient* client, ResourceProvider* resource_provider); | 53 DirectRenderer(RendererClient* client, |
| 54 OutputSurface* output_surface, |
| 55 ResourceProvider* resource_provider); |
54 | 56 |
55 class CachedResource : public ScopedResource { | 57 class CachedResource : public ScopedResource { |
56 public: | 58 public: |
57 static scoped_ptr<CachedResource> Create( | 59 static scoped_ptr<CachedResource> Create( |
58 ResourceProvider* resource_provider) { | 60 ResourceProvider* resource_provider) { |
59 return make_scoped_ptr(new CachedResource(resource_provider)); | 61 return make_scoped_ptr(new CachedResource(resource_provider)); |
60 } | 62 } |
61 virtual ~CachedResource() {} | 63 virtual ~CachedResource() {} |
62 | 64 |
63 bool is_complete() const { return is_complete_; } | 65 bool is_complete() const { return is_complete_; } |
64 void set_is_complete(bool is_complete) { is_complete_ = is_complete; } | 66 void set_is_complete(bool is_complete) { is_complete_ = is_complete; } |
65 | 67 |
66 protected: | 68 protected: |
67 explicit CachedResource(ResourceProvider* resource_provider) | 69 explicit CachedResource(ResourceProvider* resource_provider) |
68 : ScopedResource(resource_provider), | 70 : ScopedResource(resource_provider), |
69 is_complete_(false) {} | 71 is_complete_(false) {} |
70 | 72 |
71 private: | 73 private: |
72 bool is_complete_; | 74 bool is_complete_; |
73 | 75 |
74 DISALLOW_COPY_AND_ASSIGN(CachedResource); | 76 DISALLOW_COPY_AND_ASSIGN(CachedResource); |
75 }; | 77 }; |
76 | 78 |
77 static gfx::RectF QuadVertexRect(); | 79 static gfx::RectF QuadVertexRect(); |
78 static void QuadRectTransform(gfx::Transform* quad_rect_transform, | 80 static void QuadRectTransform(gfx::Transform* quad_rect_transform, |
79 const gfx::Transform& quad_transform, | 81 const gfx::Transform& quad_transform, |
80 const gfx::RectF& quad_rect); | 82 const gfx::RectF& quad_rect); |
81 static void InitializeMatrices(DrawingFrame* frame, | 83 void InitializeViewport(DrawingFrame* frame, |
82 gfx::Rect draw_rect, | 84 gfx::Rect draw_rect, |
83 bool flip_y); | 85 gfx::Rect viewport_rect, |
84 static gfx::Rect MoveScissorToWindowSpace(const DrawingFrame* frame, | 86 gfx::Size surface_size, |
85 const gfx::RectF& scissor_rect); | 87 bool flip_y); |
| 88 gfx::Rect MoveFromDrawToWindowSpace(const gfx::RectF& draw_rect, |
| 89 bool flip_y) const; |
| 90 |
86 static gfx::RectF ComputeScissorRectForRenderPass(const DrawingFrame* frame); | 91 static gfx::RectF ComputeScissorRectForRenderPass(const DrawingFrame* frame); |
87 void SetScissorStateForQuad(const DrawingFrame* frame, const DrawQuad& quad); | 92 void SetScissorStateForQuad(const DrawingFrame* frame, const DrawQuad& quad); |
88 void SetScissorStateForQuadWithRenderPassScissor( | 93 void SetScissorStateForQuadWithRenderPassScissor( |
89 const DrawingFrame* frame, | 94 const DrawingFrame* frame, |
90 const DrawQuad& quad, | 95 const DrawQuad& quad, |
91 const gfx::RectF& render_pass_scissor, | 96 const gfx::RectF& render_pass_scissor, |
92 bool* should_skip_quad); | 97 bool* should_skip_quad); |
93 | 98 |
94 static gfx::Size RenderPassTextureSize(const RenderPass* render_pass); | 99 static gfx::Size RenderPassTextureSize(const RenderPass* render_pass); |
95 static GLenum RenderPassTextureFormat(const RenderPass* render_pass); | 100 static GLenum RenderPassTextureFormat(const RenderPass* render_pass); |
96 | 101 |
97 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 102 void DrawRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
98 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); | 103 bool UseRenderPass(DrawingFrame* frame, const RenderPass* render_pass); |
99 | 104 |
100 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; | 105 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0; |
101 virtual bool BindFramebufferToTexture(DrawingFrame* frame, | 106 virtual bool BindFramebufferToTexture(DrawingFrame* frame, |
102 const ScopedResource* resource, | 107 const ScopedResource* resource, |
103 gfx::Rect framebuffer_rect) = 0; | 108 gfx::Rect target_rect) = 0; |
104 virtual void SetDrawViewportSize(gfx::Size viewport_size) = 0; | 109 virtual void SetDrawViewport(gfx::Rect window_space_viewport) = 0; |
105 virtual void SetScissorTestRect(gfx::Rect scissor_rect) = 0; | 110 virtual void SetScissorTestRect(gfx::Rect scissor_rect) = 0; |
106 virtual void ClearFramebuffer(DrawingFrame* frame) = 0; | 111 virtual void ClearFramebuffer(DrawingFrame* frame) = 0; |
107 virtual void DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) = 0; | 112 virtual void DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) = 0; |
108 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0; | 113 virtual void BeginDrawingFrame(DrawingFrame* frame) = 0; |
109 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0; | 114 virtual void FinishDrawingFrame(DrawingFrame* frame) = 0; |
110 virtual void FinishDrawingQuadList(); | 115 virtual void FinishDrawingQuadList(); |
111 virtual bool FlippedFramebuffer() const = 0; | 116 virtual bool FlippedFramebuffer() const = 0; |
112 virtual void EnsureScissorTestEnabled() = 0; | 117 virtual void EnsureScissorTestEnabled() = 0; |
113 virtual void EnsureScissorTestDisabled() = 0; | 118 virtual void EnsureScissorTestDisabled() = 0; |
114 | 119 |
115 virtual void CopyCurrentRenderPassToBitmap( | 120 virtual void CopyCurrentRenderPassToBitmap( |
116 DrawingFrame* frame, | 121 DrawingFrame* frame, |
117 scoped_ptr<CopyOutputRequest> request) = 0; | 122 scoped_ptr<CopyOutputRequest> request) = 0; |
118 | 123 |
119 ScopedPtrHashMap<RenderPass::Id, CachedResource> render_pass_textures_; | 124 ScopedPtrHashMap<RenderPass::Id, CachedResource> render_pass_textures_; |
| 125 OutputSurface* output_surface_; |
120 ResourceProvider* resource_provider_; | 126 ResourceProvider* resource_provider_; |
121 | 127 |
| 128 // For use in coordinate conversion, this stores the output rect, viewport |
| 129 // rect (= unflipped version of glViewport rect), and the size of target |
| 130 // framebuffer. During a draw, this stores the values for the current render |
| 131 // pass; in between draws, they retain the values for the root render pass of |
| 132 // the last draw. |
| 133 gfx::Rect current_draw_rect_; |
| 134 gfx::Rect current_viewport_rect_; |
| 135 gfx::Size current_surface_size_; |
| 136 |
122 private: | 137 private: |
123 gfx::Vector2d enlarge_pass_texture_amount_; | 138 gfx::Vector2d enlarge_pass_texture_amount_; |
124 | 139 |
125 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); | 140 DISALLOW_COPY_AND_ASSIGN(DirectRenderer); |
126 }; | 141 }; |
127 | 142 |
128 } // namespace cc | 143 } // namespace cc |
129 | 144 |
130 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ | 145 #endif // CC_OUTPUT_DIRECT_RENDERER_H_ |
OLD | NEW |