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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return make_scoped_ptr( | 60 return make_scoped_ptr( |
61 new SoftwareRenderer(client, output_surface, resource_provider)); | 61 new SoftwareRenderer(client, output_surface, resource_provider)); |
62 } | 62 } |
63 | 63 |
64 SoftwareRenderer::SoftwareRenderer(RendererClient* client, | 64 SoftwareRenderer::SoftwareRenderer(RendererClient* client, |
65 OutputSurface* output_surface, | 65 OutputSurface* output_surface, |
66 ResourceProvider* resource_provider) | 66 ResourceProvider* resource_provider) |
67 : DirectRenderer(client, resource_provider), | 67 : DirectRenderer(client, resource_provider), |
68 visible_(true), | 68 visible_(true), |
69 is_scissor_enabled_(false), | 69 is_scissor_enabled_(false), |
| 70 is_viewport_changed_(true), |
70 output_surface_(output_surface), | 71 output_surface_(output_surface), |
71 output_device_(output_surface->software_device()), | 72 output_device_(output_surface->software_device()), |
72 current_canvas_(NULL) { | 73 current_canvas_(NULL) { |
73 resource_provider_->set_default_resource_type(ResourceProvider::Bitmap); | 74 resource_provider_->set_default_resource_type(ResourceProvider::Bitmap); |
74 | 75 |
75 capabilities_.max_texture_size = resource_provider_->max_texture_size(); | 76 capabilities_.max_texture_size = resource_provider_->max_texture_size(); |
76 capabilities_.best_texture_format = resource_provider_->best_texture_format(); | 77 capabilities_.best_texture_format = resource_provider_->best_texture_format(); |
77 capabilities_.using_set_visibility = true; | 78 capabilities_.using_set_visibility = true; |
78 // The updater can access bitmaps while the SoftwareRenderer is using them. | 79 // The updater can access bitmaps while the SoftwareRenderer is using them. |
79 capabilities_.allow_partial_texture_updates = true; | 80 capabilities_.allow_partial_texture_updates = true; |
80 capabilities_.using_partial_swap = true; | 81 capabilities_.using_partial_swap = true; |
81 if (Settings().compositor_frame_message && client_->HasImplThread()) | 82 if (Settings().compositor_frame_message && client_->HasImplThread()) |
82 capabilities_.using_swap_complete_callback = true; | 83 capabilities_.using_swap_complete_callback = true; |
83 compositor_frame_.software_frame_data.reset(new SoftwareFrameData()); | 84 compositor_frame_.software_frame_data.reset(new SoftwareFrameData()); |
84 | |
85 ViewportChanged(); | |
86 } | 85 } |
87 | 86 |
88 SoftwareRenderer::~SoftwareRenderer() {} | 87 SoftwareRenderer::~SoftwareRenderer() {} |
89 | 88 |
90 const RendererCapabilities& SoftwareRenderer::Capabilities() const { | 89 const RendererCapabilities& SoftwareRenderer::Capabilities() const { |
91 return capabilities_; | 90 return capabilities_; |
92 } | 91 } |
93 | 92 |
94 void SoftwareRenderer::ViewportChanged() { | 93 void SoftwareRenderer::ViewportChanged() { |
95 output_device_->Resize(ViewportSize()); | 94 is_viewport_changed_ = true; |
96 } | 95 } |
97 | 96 |
98 void SoftwareRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 97 void SoftwareRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
99 TRACE_EVENT0("cc", "SoftwareRenderer::BeginDrawingFrame"); | 98 TRACE_EVENT0("cc", "SoftwareRenderer::BeginDrawingFrame"); |
| 99 if (is_viewport_changed_) { |
| 100 is_viewport_changed_ = false; |
| 101 output_device_->Resize(ViewportSize()); |
| 102 } |
100 root_canvas_ = output_device_->BeginPaint( | 103 root_canvas_ = output_device_->BeginPaint( |
101 gfx::ToEnclosingRect(frame->root_damage_rect)); | 104 gfx::ToEnclosingRect(frame->root_damage_rect)); |
102 } | 105 } |
103 | 106 |
104 void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 107 void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
105 TRACE_EVENT0("cc", "SoftwareRenderer::FinishDrawingFrame"); | 108 TRACE_EVENT0("cc", "SoftwareRenderer::FinishDrawingFrame"); |
106 current_framebuffer_lock_.reset(); | 109 current_framebuffer_lock_.reset(); |
107 current_canvas_ = NULL; | 110 current_canvas_ = NULL; |
108 root_canvas_ = NULL; | 111 root_canvas_ = NULL; |
109 if (Settings().compositor_frame_message) { | 112 if (Settings().compositor_frame_message) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 4 * rect.width()); | 418 4 * rect.width()); |
416 } | 419 } |
417 | 420 |
418 void SoftwareRenderer::SetVisible(bool visible) { | 421 void SoftwareRenderer::SetVisible(bool visible) { |
419 if (visible_ == visible) | 422 if (visible_ == visible) |
420 return; | 423 return; |
421 visible_ = visible; | 424 visible_ = visible; |
422 } | 425 } |
423 | 426 |
424 } // namespace cc | 427 } // namespace cc |
OLD | NEW |