Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: cc/output/software_renderer.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/software_renderer.h ('k') | cc/output/software_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return SkShader::kClamp_TileMode; 56 return SkShader::kClamp_TileMode;
57 } 57 }
58 NOTREACHED(); 58 NOTREACHED();
59 return SkShader::kClamp_TileMode; 59 return SkShader::kClamp_TileMode;
60 } 60 }
61 61
62 } // anonymous namespace 62 } // anonymous namespace
63 63
64 scoped_ptr<SoftwareRenderer> SoftwareRenderer::Create( 64 scoped_ptr<SoftwareRenderer> SoftwareRenderer::Create(
65 RendererClient* client, 65 RendererClient* client,
66 const LayerTreeSettings* settings, 66 const RendererSettings* settings,
67 OutputSurface* output_surface, 67 OutputSurface* output_surface,
68 ResourceProvider* resource_provider) { 68 ResourceProvider* resource_provider) {
69 return make_scoped_ptr(new SoftwareRenderer( 69 return make_scoped_ptr(new SoftwareRenderer(
70 client, settings, output_surface, resource_provider)); 70 client, settings, output_surface, resource_provider));
71 } 71 }
72 72
73 SoftwareRenderer::SoftwareRenderer(RendererClient* client, 73 SoftwareRenderer::SoftwareRenderer(RendererClient* client,
74 const LayerTreeSettings* settings, 74 const RendererSettings* settings,
75 OutputSurface* output_surface, 75 OutputSurface* output_surface,
76 ResourceProvider* resource_provider) 76 ResourceProvider* resource_provider)
77 : DirectRenderer(client, settings, output_surface, resource_provider), 77 : DirectRenderer(client, settings, output_surface, resource_provider),
78 is_scissor_enabled_(false), 78 is_scissor_enabled_(false),
79 is_backbuffer_discarded_(false), 79 is_backbuffer_discarded_(false),
80 output_device_(output_surface->software_device()), 80 output_device_(output_surface->software_device()),
81 current_canvas_(NULL) { 81 current_canvas_(NULL) {
82 if (resource_provider_) { 82 if (resource_provider_) {
83 capabilities_.max_texture_size = resource_provider_->max_texture_size(); 83 capabilities_.max_texture_size = resource_provider_->max_texture_size();
84 capabilities_.best_texture_format = 84 capabilities_.best_texture_format =
(...skipping 16 matching lines...) Expand all
101 101
102 void SoftwareRenderer::BeginDrawingFrame(DrawingFrame* frame) { 102 void SoftwareRenderer::BeginDrawingFrame(DrawingFrame* frame) {
103 TRACE_EVENT0("cc", "SoftwareRenderer::BeginDrawingFrame"); 103 TRACE_EVENT0("cc", "SoftwareRenderer::BeginDrawingFrame");
104 root_canvas_ = output_device_->BeginPaint( 104 root_canvas_ = output_device_->BeginPaint(
105 gfx::ToEnclosingRect(frame->root_damage_rect)); 105 gfx::ToEnclosingRect(frame->root_damage_rect));
106 } 106 }
107 107
108 void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) { 108 void SoftwareRenderer::FinishDrawingFrame(DrawingFrame* frame) {
109 TRACE_EVENT0("cc", "SoftwareRenderer::FinishDrawingFrame"); 109 TRACE_EVENT0("cc", "SoftwareRenderer::FinishDrawingFrame");
110 current_framebuffer_lock_ = nullptr; 110 current_framebuffer_lock_ = nullptr;
111 current_framebuffer_canvas_.clear();
111 current_canvas_ = NULL; 112 current_canvas_ = NULL;
112 root_canvas_ = NULL; 113 root_canvas_ = NULL;
113 114
114 current_frame_data_.reset(new SoftwareFrameData); 115 current_frame_data_.reset(new SoftwareFrameData);
115 output_device_->EndPaint(current_frame_data_.get()); 116 output_device_->EndPaint(current_frame_data_.get());
116 } 117 }
117 118
118 void SoftwareRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { 119 void SoftwareRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
119 TRACE_EVENT0("cc,benchmark", "SoftwareRenderer::SwapBuffers"); 120 TRACE_EVENT0("cc,benchmark", "SoftwareRenderer::SwapBuffers");
120 CompositorFrame compositor_frame; 121 CompositorFrame compositor_frame;
(...skipping 23 matching lines...) Expand all
144 is_scissor_enabled_ = false; 145 is_scissor_enabled_ = false;
145 SkISize size = current_canvas_->getDeviceSize(); 146 SkISize size = current_canvas_->getDeviceSize();
146 SetClipRect(gfx::Rect(size.width(), size.height())); 147 SetClipRect(gfx::Rect(size.width(), size.height()));
147 } 148 }
148 149
149 void SoftwareRenderer::Finish() {} 150 void SoftwareRenderer::Finish() {}
150 151
151 void SoftwareRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { 152 void SoftwareRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
152 DCHECK(!output_surface_->HasExternalStencilTest()); 153 DCHECK(!output_surface_->HasExternalStencilTest());
153 current_framebuffer_lock_ = nullptr; 154 current_framebuffer_lock_ = nullptr;
155 current_framebuffer_canvas_.clear();
154 current_canvas_ = root_canvas_; 156 current_canvas_ = root_canvas_;
155 } 157 }
156 158
157 bool SoftwareRenderer::BindFramebufferToTexture( 159 bool SoftwareRenderer::BindFramebufferToTexture(
158 DrawingFrame* frame, 160 DrawingFrame* frame,
159 const ScopedResource* texture, 161 const ScopedResource* texture,
160 const gfx::Rect& target_rect) { 162 const gfx::Rect& target_rect) {
161 current_framebuffer_lock_ = make_scoped_ptr( 163 current_framebuffer_lock_ = make_scoped_ptr(
162 new ResourceProvider::ScopedWriteLockSoftware( 164 new ResourceProvider::ScopedWriteLockSoftware(
163 resource_provider_, texture->id())); 165 resource_provider_, texture->id()));
164 current_canvas_ = current_framebuffer_lock_->sk_canvas(); 166 current_framebuffer_canvas_ =
167 skia::AdoptRef(new SkCanvas(current_framebuffer_lock_->sk_bitmap()));
168 current_canvas_ = current_framebuffer_canvas_.get();
165 InitializeViewport(frame, 169 InitializeViewport(frame,
166 target_rect, 170 target_rect,
167 gfx::Rect(target_rect.size()), 171 gfx::Rect(target_rect.size()),
168 target_rect.size()); 172 target_rect.size());
169 return true; 173 return true;
170 } 174 }
171 175
172 void SoftwareRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { 176 void SoftwareRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
173 is_scissor_enabled_ = true; 177 is_scissor_enabled_ = true;
174 scissor_rect_ = scissor_rect; 178 scissor_rect_ = scissor_rect;
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 604 }
601 605
602 void SoftwareRenderer::DidChangeVisibility() { 606 void SoftwareRenderer::DidChangeVisibility() {
603 if (visible()) 607 if (visible())
604 EnsureBackbuffer(); 608 EnsureBackbuffer();
605 else 609 else
606 DiscardBackbuffer(); 610 DiscardBackbuffer();
607 } 611 }
608 612
609 } // namespace cc 613 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/software_renderer.h ('k') | cc/output/software_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698