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 #include "cc/output/software_renderer.h" | 5 #include "cc/output/software_renderer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 RendererClient* client, | 46 RendererClient* client, |
47 OutputSurface* output_surface, | 47 OutputSurface* output_surface, |
48 ResourceProvider* resource_provider) { | 48 ResourceProvider* resource_provider) { |
49 return make_scoped_ptr( | 49 return make_scoped_ptr( |
50 new SoftwareRenderer(client, output_surface, resource_provider)); | 50 new SoftwareRenderer(client, output_surface, resource_provider)); |
51 } | 51 } |
52 | 52 |
53 SoftwareRenderer::SoftwareRenderer(RendererClient* client, | 53 SoftwareRenderer::SoftwareRenderer(RendererClient* client, |
54 OutputSurface* output_surface, | 54 OutputSurface* output_surface, |
55 ResourceProvider* resource_provider) | 55 ResourceProvider* resource_provider) |
56 : DirectRenderer(client, resource_provider), | 56 : DirectRenderer(client, output_surface, resource_provider), |
57 visible_(true), | 57 visible_(true), |
58 is_scissor_enabled_(false), | 58 is_scissor_enabled_(false), |
59 is_viewport_changed_(true), | 59 is_viewport_changed_(true), |
60 output_surface_(output_surface), | |
61 output_device_(output_surface->software_device()), | 60 output_device_(output_surface->software_device()), |
62 current_canvas_(NULL) { | 61 current_canvas_(NULL) { |
63 if (resource_provider_) { | 62 if (resource_provider_) { |
64 capabilities_.max_texture_size = resource_provider_->max_texture_size(); | 63 capabilities_.max_texture_size = resource_provider_->max_texture_size(); |
65 capabilities_.best_texture_format = | 64 capabilities_.best_texture_format = |
66 resource_provider_->best_texture_format(); | 65 resource_provider_->best_texture_format(); |
67 } | 66 } |
68 capabilities_.using_set_visibility = true; | 67 capabilities_.using_set_visibility = true; |
69 // The updater can access bitmaps while the SoftwareRenderer is using them. | 68 // The updater can access bitmaps while the SoftwareRenderer is using them. |
70 capabilities_.allow_partial_texture_updates = true; | 69 capabilities_.allow_partial_texture_updates = true; |
(...skipping 10 matching lines...) Expand all Loading... | |
81 } | 80 } |
82 | 81 |
83 void SoftwareRenderer::ViewportChanged() { | 82 void SoftwareRenderer::ViewportChanged() { |
84 is_viewport_changed_ = true; | 83 is_viewport_changed_ = true; |
85 } | 84 } |
86 | 85 |
87 void SoftwareRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 86 void SoftwareRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
88 TRACE_EVENT0("cc", "SoftwareRenderer::BeginDrawingFrame"); | 87 TRACE_EVENT0("cc", "SoftwareRenderer::BeginDrawingFrame"); |
89 if (is_viewport_changed_) { | 88 if (is_viewport_changed_) { |
90 is_viewport_changed_ = false; | 89 is_viewport_changed_ = false; |
91 output_device_->Resize(ViewportSize()); | 90 output_device_->Resize(client_->DeviceViewport().size()); |
92 } | 91 } |
93 root_canvas_ = output_device_->BeginPaint( | 92 root_canvas_ = output_device_->BeginPaint( |
94 gfx::ToEnclosingRect(frame->root_damage_rect)); | 93 gfx::ToEnclosingRect(frame->root_damage_rect)); |
95 } | 94 } |
96 | 95 |
97 void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 96 void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
98 TRACE_EVENT0("cc", "SoftwareRenderer::FinishDrawingFrame"); | 97 TRACE_EVENT0("cc", "SoftwareRenderer::FinishDrawingFrame"); |
99 current_framebuffer_lock_.reset(); | 98 current_framebuffer_lock_.reset(); |
100 current_canvas_ = NULL; | 99 current_canvas_ = NULL; |
101 root_canvas_ = NULL; | 100 root_canvas_ = NULL; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 | 144 |
146 bool SoftwareRenderer::BindFramebufferToTexture( | 145 bool SoftwareRenderer::BindFramebufferToTexture( |
147 DrawingFrame* frame, | 146 DrawingFrame* frame, |
148 const ScopedResource* texture, | 147 const ScopedResource* texture, |
149 gfx::Rect framebuffer_rect) { | 148 gfx::Rect framebuffer_rect) { |
150 current_framebuffer_lock_.reset(); | 149 current_framebuffer_lock_.reset(); |
151 current_framebuffer_lock_ = make_scoped_ptr( | 150 current_framebuffer_lock_ = make_scoped_ptr( |
152 new ResourceProvider::ScopedWriteLockSoftware( | 151 new ResourceProvider::ScopedWriteLockSoftware( |
153 resource_provider_, texture->id())); | 152 resource_provider_, texture->id())); |
154 current_canvas_ = current_framebuffer_lock_->sk_canvas(); | 153 current_canvas_ = current_framebuffer_lock_->sk_canvas(); |
155 InitializeMatrices(frame, framebuffer_rect, false); | 154 InitializeMatrices( |
156 SetDrawViewportSize(framebuffer_rect.size()); | 155 frame, framebuffer_rect, gfx::Rect(framebuffer_rect.size()), false); |
enne (OOO)
2013/06/04 17:26:03
I'm a little curious about this change. When does
aelias_OOO_until_Jul13
2013/06/04 17:54:20
I'll investigate and consider changing the argumen
aelias_OOO_until_Jul13
2013/06/04 22:18:27
It needs to be a rect since framebuffer_rect is se
| |
156 SetDrawViewport(gfx::Rect(framebuffer_rect.size())); | |
157 | 157 |
158 return true; | 158 return true; |
159 } | 159 } |
160 | 160 |
161 void SoftwareRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { | 161 void SoftwareRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { |
162 is_scissor_enabled_ = true; | 162 is_scissor_enabled_ = true; |
163 scissor_rect_ = scissor_rect; | 163 scissor_rect_ = scissor_rect; |
164 SetClipRect(scissor_rect); | 164 SetClipRect(scissor_rect); |
165 } | 165 } |
166 | 166 |
(...skipping 19 matching lines...) Expand all Loading... | |
186 ClearCanvas(SkColorSetARGB(0, 0, 0, 0)); | 186 ClearCanvas(SkColorSetARGB(0, 0, 0, 0)); |
187 } else { | 187 } else { |
188 #ifndef NDEBUG | 188 #ifndef NDEBUG |
189 // On DEBUG builds, opaque render passes are cleared to blue | 189 // On DEBUG builds, opaque render passes are cleared to blue |
190 // to easily see regions that were not drawn on the screen. | 190 // to easily see regions that were not drawn on the screen. |
191 ClearCanvas(SkColorSetARGB(255, 0, 0, 255)); | 191 ClearCanvas(SkColorSetARGB(255, 0, 0, 255)); |
192 #endif | 192 #endif |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void SoftwareRenderer::SetDrawViewportSize(gfx::Size viewport_size) {} | 196 void SoftwareRenderer::SetDrawViewport(gfx::Rect viewport) {} |
enne (OOO)
2013/06/04 17:26:03
How does the software renderer get away with ignor
aelias_OOO_until_Jul13
2013/06/04 17:54:20
The software renderer applies the window_matrix di
| |
197 | 197 |
198 bool SoftwareRenderer::IsSoftwareResource( | 198 bool SoftwareRenderer::IsSoftwareResource( |
199 ResourceProvider::ResourceId resource_id) const { | 199 ResourceProvider::ResourceId resource_id) const { |
200 switch (resource_provider_->GetResourceType(resource_id)) { | 200 switch (resource_provider_->GetResourceType(resource_id)) { |
201 case ResourceProvider::GLTexture: | 201 case ResourceProvider::GLTexture: |
202 return false; | 202 return false; |
203 case ResourceProvider::Bitmap: | 203 case ResourceProvider::Bitmap: |
204 return true; | 204 return true; |
205 } | 205 } |
206 | 206 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 4 * rect.width()); | 457 4 * rect.width()); |
458 } | 458 } |
459 | 459 |
460 void SoftwareRenderer::SetVisible(bool visible) { | 460 void SoftwareRenderer::SetVisible(bool visible) { |
461 if (visible_ == visible) | 461 if (visible_ == visible) |
462 return; | 462 return; |
463 visible_ = visible; | 463 visible_ = visible; |
464 } | 464 } |
465 | 465 |
466 } // namespace cc | 466 } // namespace cc |
OLD | NEW |