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

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

Issue 93663004: [#2] Pass gfx structs by const ref (gfx::Rect, gfx::RectF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT, fix builds on non-linux platforms! Created 6 years, 11 months 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/quads/checkerboard_draw_quad.h » ('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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 void SoftwareRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { 151 void SoftwareRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
152 DCHECK(!output_surface_->HasExternalStencilTest()); 152 DCHECK(!output_surface_->HasExternalStencilTest());
153 current_framebuffer_lock_.reset(); 153 current_framebuffer_lock_.reset();
154 current_canvas_ = root_canvas_; 154 current_canvas_ = root_canvas_;
155 } 155 }
156 156
157 bool SoftwareRenderer::BindFramebufferToTexture( 157 bool SoftwareRenderer::BindFramebufferToTexture(
158 DrawingFrame* frame, 158 DrawingFrame* frame,
159 const ScopedResource* texture, 159 const ScopedResource* texture,
160 gfx::Rect target_rect) { 160 const gfx::Rect& target_rect) {
161 current_framebuffer_lock_.reset(); 161 current_framebuffer_lock_.reset();
162 current_framebuffer_lock_ = make_scoped_ptr( 162 current_framebuffer_lock_ = make_scoped_ptr(
163 new ResourceProvider::ScopedWriteLockSoftware( 163 new ResourceProvider::ScopedWriteLockSoftware(
164 resource_provider_, texture->id())); 164 resource_provider_, texture->id()));
165 current_canvas_ = current_framebuffer_lock_->sk_canvas(); 165 current_canvas_ = current_framebuffer_lock_->sk_canvas();
166 InitializeViewport(frame, 166 InitializeViewport(frame,
167 target_rect, 167 target_rect,
168 gfx::Rect(target_rect.size()), 168 gfx::Rect(target_rect.size()),
169 target_rect.size()); 169 target_rect.size());
170 return true; 170 return true;
171 } 171 }
172 172
173 void SoftwareRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { 173 void SoftwareRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
174 is_scissor_enabled_ = true; 174 is_scissor_enabled_ = true;
175 scissor_rect_ = scissor_rect; 175 scissor_rect_ = scissor_rect;
176 SetClipRect(scissor_rect); 176 SetClipRect(scissor_rect);
177 } 177 }
178 178
179 void SoftwareRenderer::SetClipRect(gfx::Rect rect) { 179 void SoftwareRenderer::SetClipRect(const gfx::Rect& rect) {
180 // Skia applies the current matrix to clip rects so we reset it temporary. 180 // Skia applies the current matrix to clip rects so we reset it temporary.
181 SkMatrix current_matrix = current_canvas_->getTotalMatrix(); 181 SkMatrix current_matrix = current_canvas_->getTotalMatrix();
182 current_canvas_->resetMatrix(); 182 current_canvas_->resetMatrix();
183 current_canvas_->clipRect(gfx::RectToSkRect(rect), SkRegion::kReplace_Op); 183 current_canvas_->clipRect(gfx::RectToSkRect(rect), SkRegion::kReplace_Op);
184 current_canvas_->setMatrix(current_matrix); 184 current_canvas_->setMatrix(current_matrix);
185 } 185 }
186 186
187 void SoftwareRenderer::ClearCanvas(SkColor color) { 187 void SoftwareRenderer::ClearCanvas(SkColor color) {
188 // SkCanvas::clear doesn't respect the current clipping region 188 // SkCanvas::clear doesn't respect the current clipping region
189 // so we SkCanvas::drawColor instead if scissoring is active. 189 // so we SkCanvas::drawColor instead if scissoring is active.
(...skipping 12 matching lines...) Expand all
202 ClearCanvas(SkColorSetARGB(0, 0, 0, 0)); 202 ClearCanvas(SkColorSetARGB(0, 0, 0, 0));
203 } else { 203 } else {
204 #ifndef NDEBUG 204 #ifndef NDEBUG
205 // On DEBUG builds, opaque render passes are cleared to blue 205 // On DEBUG builds, opaque render passes are cleared to blue
206 // to easily see regions that were not drawn on the screen. 206 // to easily see regions that were not drawn on the screen.
207 ClearCanvas(SkColorSetARGB(255, 0, 0, 255)); 207 ClearCanvas(SkColorSetARGB(255, 0, 0, 255));
208 #endif 208 #endif
209 } 209 }
210 } 210 }
211 211
212 void SoftwareRenderer::SetDrawViewport(gfx::Rect window_space_viewport) {} 212 void SoftwareRenderer::SetDrawViewport(
213 const gfx::Rect& window_space_viewport) {}
213 214
214 bool SoftwareRenderer::IsSoftwareResource( 215 bool SoftwareRenderer::IsSoftwareResource(
215 ResourceProvider::ResourceId resource_id) const { 216 ResourceProvider::ResourceId resource_id) const {
216 switch (resource_provider_->GetResourceType(resource_id)) { 217 switch (resource_provider_->GetResourceType(resource_id)) {
217 case ResourceProvider::GLTexture: 218 case ResourceProvider::GLTexture:
218 return false; 219 return false;
219 case ResourceProvider::Bitmap: 220 case ResourceProvider::Bitmap:
220 return true; 221 return true;
221 case ResourceProvider::InvalidType: 222 case ResourceProvider::InvalidType:
222 break; 223 break;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } 581 }
581 582
582 void SoftwareRenderer::EnsureBackbuffer() { 583 void SoftwareRenderer::EnsureBackbuffer() {
583 if (!is_backbuffer_discarded_) 584 if (!is_backbuffer_discarded_)
584 return; 585 return;
585 586
586 output_surface_->EnsureBackbuffer(); 587 output_surface_->EnsureBackbuffer();
587 is_backbuffer_discarded_ = false; 588 is_backbuffer_discarded_ = false;
588 } 589 }
589 590
590 void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) { 591 void SoftwareRenderer::GetFramebufferPixels(void* pixels,
592 const gfx::Rect& rect) {
591 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels"); 593 TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels");
592 SkBitmap subset_bitmap; 594 SkBitmap subset_bitmap;
593 rect += current_viewport_rect_.OffsetFromOrigin(); 595 gfx::Rect frame_rect(rect);
594 output_device_->CopyToBitmap(rect, &subset_bitmap); 596 frame_rect += current_viewport_rect_.OffsetFromOrigin();
597 output_device_->CopyToBitmap(frame_rect, &subset_bitmap);
595 subset_bitmap.copyPixelsTo(pixels, 598 subset_bitmap.copyPixelsTo(pixels,
596 4 * rect.width() * rect.height(), 599 4 * frame_rect.width() * frame_rect.height(),
597 4 * rect.width()); 600 4 * frame_rect.width());
598 } 601 }
599 602
600 void SoftwareRenderer::SetVisible(bool visible) { 603 void SoftwareRenderer::SetVisible(bool visible) {
601 if (visible_ == visible) 604 if (visible_ == visible)
602 return; 605 return;
603 visible_ = visible; 606 visible_ = visible;
604 607
605 if (visible_) 608 if (visible_)
606 EnsureBackbuffer(); 609 EnsureBackbuffer();
607 else 610 else
608 DiscardBackbuffer(); 611 DiscardBackbuffer();
609 } 612 }
610 613
611 } // namespace cc 614 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/software_renderer.h ('k') | cc/quads/checkerboard_draw_quad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698