summaryrefslogtreecommitdiffstats
path: root/cc/output
diff options
context:
space:
mode:
authorprashant.n@samsung.com <prashant.n@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 20:05:06 +0000
committerprashant.n@samsung.com <prashant.n@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 20:05:06 +0000
commit0023fc78d056556b353ee17f03760bec8c1fee49 (patch)
tree009367358a1c44b08f3142f63b087d936206ba44 /cc/output
parent37df32bd517577ac6ad20c6d76b236265caeacaf (diff)
downloadchromium_src-0023fc78d056556b353ee17f03760bec8c1fee49.zip
chromium_src-0023fc78d056556b353ee17f03760bec8c1fee49.tar.gz
chromium_src-0023fc78d056556b353ee17f03760bec8c1fee49.tar.bz2
Pass gfx::Rect and gfx::RectF by const ref.
Avoid unneccessary copy of structures gfx::Rect & gfx::RectF by passing them by const ref rather than value. Any struct of size > 4 bytes should be passed by const ref. Passing by ref for these structs is faster than passing by value, especially when invoking function has multiple parameters. Pass by value creates unneccessary overhead which should be avoided. BUG=159273 Review URL: https://codereview.chromium.org/93663004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output')
-rw-r--r--cc/output/copy_output_request.h2
-rw-r--r--cc/output/delegating_renderer.cc7
-rw-r--r--cc/output/delegating_renderer.h7
-rw-r--r--cc/output/direct_renderer.cc13
-rw-r--r--cc/output/direct_renderer.h16
-rw-r--r--cc/output/gl_renderer.cc18
-rw-r--r--cc/output/gl_renderer.h19
-rw-r--r--cc/output/gl_renderer_unittest.cc3
-rw-r--r--cc/output/output_surface.cc6
-rw-r--r--cc/output/output_surface.h6
-rw-r--r--cc/output/output_surface_client.h6
-rw-r--r--cc/output/renderer.h6
-rw-r--r--cc/output/renderer_pixeltest.cc16
-rw-r--r--cc/output/software_output_device.cc6
-rw-r--r--cc/output/software_output_device.h6
-rw-r--r--cc/output/software_renderer.cc21
-rw-r--r--cc/output/software_renderer.h11
17 files changed, 90 insertions, 79 deletions
diff --git a/cc/output/copy_output_request.h b/cc/output/copy_output_request.h
index 4b74b41..6d8870d 100644
--- a/cc/output/copy_output_request.h
+++ b/cc/output/copy_output_request.h
@@ -46,7 +46,7 @@ class CC_EXPORT CopyOutputRequest {
// By default copy requests copy the entire layer's subtree output. If an
// area is given, then the intersection of this rect (in layer space) with
// the layer's subtree output will be returned.
- void set_area(gfx::Rect area) {
+ void set_area(const gfx::Rect& area) {
has_area_ = true;
area_ = area;
}
diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc
index 3a16568..b75d097 100644
--- a/cc/output/delegating_renderer.cc
+++ b/cc/output/delegating_renderer.cc
@@ -96,8 +96,8 @@ static ResourceProvider::ResourceId AppendToArray(
void DelegatingRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
ContextProvider* offscreen_context_provider,
float device_scale_factor,
- gfx::Rect device_viewport_rect,
- gfx::Rect device_clip_rect,
+ const gfx::Rect& device_viewport_rect,
+ const gfx::Rect& device_clip_rect,
bool allow_partial_swap,
bool disable_picture_quad_image_filtering) {
TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame");
@@ -129,7 +129,8 @@ void DelegatingRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
output_surface_->SwapBuffers(&compositor_frame);
}
-void DelegatingRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
+void DelegatingRenderer::GetFramebufferPixels(void* pixels,
+ const gfx::Rect& rect) {
NOTREACHED();
}
diff --git a/cc/output/delegating_renderer.h b/cc/output/delegating_renderer.h
index c18bfa7..3de65f7 100644
--- a/cc/output/delegating_renderer.h
+++ b/cc/output/delegating_renderer.h
@@ -31,8 +31,8 @@ class CC_EXPORT DelegatingRenderer : public Renderer {
virtual void DrawFrame(RenderPassList* render_passes_in_draw_order,
ContextProvider* offscreen_context_provider,
float device_scale_factor,
- gfx::Rect device_viewport_rect,
- gfx::Rect device_clip_rect,
+ const gfx::Rect& device_viewport_rect,
+ const gfx::Rect& device_clip_rect,
bool allow_partial_swap,
bool disable_picture_quad_image_filtering) OVERRIDE;
@@ -41,7 +41,8 @@ class CC_EXPORT DelegatingRenderer : public Renderer {
virtual void SwapBuffers(const CompositorFrameMetadata& metadata) OVERRIDE;
virtual void ReceiveSwapBuffersAck(const CompositorFrameAck&) OVERRIDE;
- virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
+ virtual void GetFramebufferPixels(void* pixels,
+ const gfx::Rect& rect) OVERRIDE;
virtual bool IsContextLost() OVERRIDE;
diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc
index 84788c5..f90789d 100644
--- a/cc/output/direct_renderer.cc
+++ b/cc/output/direct_renderer.cc
@@ -81,8 +81,8 @@ void DirectRenderer::QuadRectTransform(gfx::Transform* quad_rect_transform,
}
void DirectRenderer::InitializeViewport(DrawingFrame* frame,
- gfx::Rect draw_rect,
- gfx::Rect viewport_rect,
+ const gfx::Rect& draw_rect,
+ const gfx::Rect& viewport_rect,
gfx::Size surface_size) {
bool flip_y = FlippedFramebuffer();
@@ -195,8 +195,8 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame(
void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
ContextProvider* offscreen_context_provider,
float device_scale_factor,
- gfx::Rect device_viewport_rect,
- gfx::Rect device_clip_rect,
+ const gfx::Rect& device_viewport_rect,
+ const gfx::Rect& device_clip_rect,
bool allow_partial_swap,
bool disable_picture_quad_image_filtering) {
TRACE_EVENT0("cc", "DirectRenderer::DrawFrame");
@@ -317,8 +317,9 @@ void DirectRenderer::SetScissorStateForQuadWithRenderPassScissor(
SetScissorTestRectInDrawSpace(frame, quad_scissor_rect);
}
-void DirectRenderer::SetScissorTestRectInDrawSpace(const DrawingFrame* frame,
- gfx::RectF draw_space_rect) {
+void DirectRenderer::SetScissorTestRectInDrawSpace(
+ const DrawingFrame* frame,
+ const gfx::RectF& draw_space_rect) {
gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect);
if (NeedDeviceClip(frame))
window_space_rect.Intersect(DeviceClipRectInWindowSpace(frame));
diff --git a/cc/output/direct_renderer.h b/cc/output/direct_renderer.h
index 5c4dc7e..4a447aa 100644
--- a/cc/output/direct_renderer.h
+++ b/cc/output/direct_renderer.h
@@ -34,8 +34,8 @@ class CC_EXPORT DirectRenderer : public Renderer {
virtual void DrawFrame(RenderPassList* render_passes_in_draw_order,
ContextProvider* offscreen_context_provider,
float device_scale_factor,
- gfx::Rect device_viewport_rect,
- gfx::Rect device_clip_rect,
+ const gfx::Rect& device_viewport_rect,
+ const gfx::Rect& device_clip_rect,
bool allow_partial_swap,
bool disable_picture_quad_image_filtering) OVERRIDE;
@@ -72,8 +72,8 @@ class CC_EXPORT DirectRenderer : public Renderer {
const gfx::Transform& quad_transform,
const gfx::RectF& quad_rect);
void InitializeViewport(DrawingFrame* frame,
- gfx::Rect draw_rect,
- gfx::Rect viewport_rect,
+ const gfx::Rect& draw_rect,
+ const gfx::Rect& viewport_rect,
gfx::Size surface_size);
gfx::Rect MoveFromDrawToWindowSpace(const gfx::RectF& draw_rect) const;
@@ -87,7 +87,7 @@ class CC_EXPORT DirectRenderer : public Renderer {
const gfx::RectF& render_pass_scissor,
bool* should_skip_quad);
void SetScissorTestRectInDrawSpace(const DrawingFrame* frame,
- gfx::RectF draw_space_rect);
+ const gfx::RectF& draw_space_rect);
static gfx::Size RenderPassTextureSize(const RenderPass* render_pass);
@@ -99,9 +99,9 @@ class CC_EXPORT DirectRenderer : public Renderer {
virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) = 0;
virtual bool BindFramebufferToTexture(DrawingFrame* frame,
const ScopedResource* resource,
- gfx::Rect target_rect) = 0;
- virtual void SetDrawViewport(gfx::Rect window_space_viewport) = 0;
- virtual void SetScissorTestRect(gfx::Rect scissor_rect) = 0;
+ const gfx::Rect& target_rect) = 0;
+ virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) = 0;
+ virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) = 0;
virtual void DiscardPixels(bool has_external_stencil_test,
bool draw_rect_covers_full_surface) = 0;
virtual void ClearFramebuffer(DrawingFrame* frame,
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 896028d..65dc0da 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -2061,7 +2061,7 @@ void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame,
void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame,
int texture_id,
- gfx::Rect rect,
+ const gfx::Rect& rect,
const gfx::Transform& draw_matrix,
bool flip_vertically) {
TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
@@ -2171,7 +2171,7 @@ void GLRenderer::EnsureBackbuffer() {
is_backbuffer_discarded_ = false;
}
-void GLRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
+void GLRenderer::GetFramebufferPixels(void* pixels, const gfx::Rect& rect) {
if (!pixels || rect.IsEmpty())
return;
@@ -2190,7 +2190,7 @@ void GLRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
}
void GLRenderer::GetFramebufferPixelsAsync(
- gfx::Rect rect,
+ const gfx::Rect& rect,
scoped_ptr<CopyOutputRequest> request) {
DCHECK(!request->IsEmpty());
if (request->IsEmpty())
@@ -2288,7 +2288,7 @@ void GLRenderer::GetFramebufferPixelsAsync(
void GLRenderer::DoGetFramebufferPixels(
uint8* dest_pixels,
- gfx::Rect window_rect,
+ const gfx::Rect& window_rect,
const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback) {
DCHECK_GE(window_rect.x(), 0);
DCHECK_GE(window_rect.y(), 0);
@@ -2471,7 +2471,7 @@ void GLRenderer::PassOnSkBitmap(scoped_ptr<SkBitmap> bitmap,
void GLRenderer::GetFramebufferTexture(unsigned texture_id,
ResourceFormat texture_format,
- gfx::Rect window_rect) {
+ const gfx::Rect& window_rect) {
DCHECK(texture_id);
DCHECK_GE(window_rect.x(), 0);
DCHECK_GE(window_rect.y(), 0);
@@ -2493,7 +2493,7 @@ void GLRenderer::GetFramebufferTexture(unsigned texture_id,
bool GLRenderer::UseScopedTexture(DrawingFrame* frame,
const ScopedResource* texture,
- gfx::Rect viewport_rect) {
+ const gfx::Rect& viewport_rect) {
DCHECK(texture->id());
frame->current_render_pass = NULL;
frame->current_texture = texture;
@@ -2515,7 +2515,7 @@ void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame,
const ScopedResource* texture,
- gfx::Rect target_rect) {
+ const gfx::Rect& target_rect) {
DCHECK(texture->id());
current_framebuffer_lock_.reset();
@@ -2539,7 +2539,7 @@ bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame,
return true;
}
-void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) {
+void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
EnsureScissorTestEnabled();
// Don't unnecessarily ask the context to change the scissor, because it
@@ -2558,7 +2558,7 @@ void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) {
scissor_rect_needs_reset_ = false;
}
-void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) {
+void GLRenderer::SetDrawViewport(const gfx::Rect& window_space_viewport) {
viewport_ = window_space_viewport;
GLC(gl_,
gl_->Viewport(window_space_viewport.x(),
diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h
index 0484c05..b25d672 100644
--- a/cc/output/gl_renderer.h
+++ b/cc/output/gl_renderer.h
@@ -64,7 +64,8 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
virtual void DoNoOp() OVERRIDE;
virtual void SwapBuffers(const CompositorFrameMetadata& metadata) OVERRIDE;
- virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
+ virtual void GetFramebufferPixels(void* pixels,
+ const gfx::Rect& rect) OVERRIDE;
virtual bool IsContextLost() OVERRIDE;
@@ -95,11 +96,11 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
return shared_geometry_.get();
}
- void GetFramebufferPixelsAsync(gfx::Rect rect,
+ void GetFramebufferPixelsAsync(const gfx::Rect& rect,
scoped_ptr<CopyOutputRequest> request);
void GetFramebufferTexture(unsigned texture_id,
ResourceFormat texture_format,
- gfx::Rect device_rect);
+ const gfx::Rect& device_rect);
void ReleaseRenderPassTextures();
void SetStencilEnabled(bool enabled);
@@ -110,9 +111,9 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE;
virtual bool BindFramebufferToTexture(DrawingFrame* frame,
const ScopedResource* resource,
- gfx::Rect target_rect) OVERRIDE;
- virtual void SetDrawViewport(gfx::Rect window_space_viewport) OVERRIDE;
- virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE;
+ const gfx::Rect& target_rect) OVERRIDE;
+ virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) OVERRIDE;
+ virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) OVERRIDE;
virtual void DiscardPixels(bool has_external_stencil_test,
bool draw_rect_covers_full_surface) OVERRIDE;
virtual void ClearFramebuffer(DrawingFrame* frame,
@@ -184,13 +185,13 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
void CopyTextureToFramebuffer(const DrawingFrame* frame,
int texture_id,
- gfx::Rect rect,
+ const gfx::Rect& rect,
const gfx::Transform& draw_matrix,
bool flip_vertically);
bool UseScopedTexture(DrawingFrame* frame,
const ScopedResource* resource,
- gfx::Rect viewport_rect);
+ const gfx::Rect& viewport_rect);
bool MakeContextCurrent();
@@ -202,7 +203,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
AsyncGetFramebufferPixelsCleanupCallback;
void DoGetFramebufferPixels(
uint8* pixels,
- gfx::Rect window_rect,
+ const gfx::Rect& window_rect,
const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback);
void FinishedReadback(
const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback,
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index e0dcc29..7c5741f 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -1754,7 +1754,8 @@ class MockOutputSurfaceTest : public GLRendererTest {
void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); }
- void DrawFrame(float device_scale_factor, gfx::Rect device_viewport_rect) {
+ void DrawFrame(float device_scale_factor,
+ const gfx::Rect& device_viewport_rect) {
RenderPass::Id render_pass_id(1, 0);
TestRenderPass* render_pass = AddRenderPass(&render_passes_in_draw_order_,
render_pass_id,
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
index 349cb34..f3952d5 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -136,7 +136,7 @@ void OutputSurface::FrameRateControllerTick(bool throttled,
}
// Forwarded to OutputSurfaceClient
-void OutputSurface::SetNeedsRedrawRect(gfx::Rect damage_rect) {
+void OutputSurface::SetNeedsRedrawRect(const gfx::Rect& damage_rect) {
TRACE_EVENT0("cc", "OutputSurface::SetNeedsRedrawRect");
client_->SetNeedsRedrawRect(damage_rect);
}
@@ -242,8 +242,8 @@ void OutputSurface::SetExternalStencilTest(bool enabled) {
}
void OutputSurface::SetExternalDrawConstraints(const gfx::Transform& transform,
- gfx::Rect viewport,
- gfx::Rect clip,
+ const gfx::Rect& viewport,
+ const gfx::Rect& clip,
bool valid_for_tile_management) {
client_->SetExternalDrawConstraints(
transform, viewport, clip, valid_for_tile_management);
diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h
index 0d7d4e7..aae3b8c 100644
--- a/cc/output/output_surface.h
+++ b/cc/output/output_surface.h
@@ -175,7 +175,7 @@ class CC_EXPORT OutputSurface : public FrameRateControllerClient {
// Forwarded to OutputSurfaceClient but threaded through OutputSurface
// first so OutputSurface has a chance to update the FrameRateController
- void SetNeedsRedrawRect(gfx::Rect damage_rect);
+ void SetNeedsRedrawRect(const gfx::Rect& damage_rect);
void BeginImplFrame(const BeginFrameArgs& args);
void DidSwapBuffers();
void OnSwapBuffersComplete();
@@ -183,8 +183,8 @@ class CC_EXPORT OutputSurface : public FrameRateControllerClient {
void DidLoseOutputSurface();
void SetExternalStencilTest(bool enabled);
void SetExternalDrawConstraints(const gfx::Transform& transform,
- gfx::Rect viewport,
- gfx::Rect clip,
+ const gfx::Rect& viewport,
+ const gfx::Rect& clip,
bool valid_for_tile_management);
// virtual for testing.
diff --git a/cc/output/output_surface_client.h b/cc/output/output_surface_client.h
index d82f30d..7e509a8 100644
--- a/cc/output/output_surface_client.h
+++ b/cc/output/output_surface_client.h
@@ -30,15 +30,15 @@ class CC_EXPORT OutputSurfaceClient {
virtual bool DeferredInitialize(
scoped_refptr<ContextProvider> offscreen_context_provider) = 0;
virtual void ReleaseGL() = 0;
- virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) = 0;
+ virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) = 0;
virtual void BeginImplFrame(const BeginFrameArgs& args) = 0;
virtual void DidSwapBuffers() = 0;
virtual void OnSwapBuffersComplete() = 0;
virtual void ReclaimResources(const CompositorFrameAck* ack) = 0;
virtual void DidLoseOutputSurface() = 0;
virtual void SetExternalDrawConstraints(const gfx::Transform& transform,
- gfx::Rect viewport,
- gfx::Rect clip,
+ const gfx::Rect& viewport,
+ const gfx::Rect& clip,
bool valid_for_tile_management) = 0;
virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) = 0;
// If set, |callback| will be called subsequent to each new tree activation,
diff --git a/cc/output/renderer.h b/cc/output/renderer.h
index 147b535f..412f8d1 100644
--- a/cc/output/renderer.h
+++ b/cc/output/renderer.h
@@ -41,8 +41,8 @@ class CC_EXPORT Renderer {
virtual void DrawFrame(RenderPassList* render_passes_in_draw_order,
ContextProvider* offscreen_context_provider,
float device_scale_factor,
- gfx::Rect device_viewport_rect,
- gfx::Rect device_clip_rect,
+ const gfx::Rect& device_viewport_rect,
+ const gfx::Rect& device_clip_rect,
bool allow_partial_swap,
bool disable_picture_quad_image_filtering) = 0;
@@ -55,7 +55,7 @@ class CC_EXPORT Renderer {
virtual void SwapBuffers(const CompositorFrameMetadata& metadata) = 0;
virtual void ReceiveSwapBuffersAck(const CompositorFrameAck& ack) {}
- virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) = 0;
+ virtual void GetFramebufferPixels(void* pixels, const gfx::Rect& rect) = 0;
virtual bool IsContextLost();
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
index 8ab93aa..68bd855 100644
--- a/cc/output/renderer_pixeltest.cc
+++ b/cc/output/renderer_pixeltest.cc
@@ -25,7 +25,7 @@ namespace {
#if !defined(OS_ANDROID)
scoped_ptr<RenderPass> CreateTestRootRenderPass(RenderPass::Id id,
- gfx::Rect rect) {
+ const gfx::Rect& rect) {
scoped_ptr<RenderPass> pass = RenderPass::Create();
const gfx::Rect output_rect = rect;
const gfx::RectF damage_rect = rect;
@@ -36,7 +36,7 @@ scoped_ptr<RenderPass> CreateTestRootRenderPass(RenderPass::Id id,
scoped_ptr<RenderPass> CreateTestRenderPass(
RenderPass::Id id,
- gfx::Rect rect,
+ const gfx::Rect& rect,
const gfx::Transform& transform_to_root_target) {
scoped_ptr<RenderPass> pass = RenderPass::Create();
const gfx::Rect output_rect = rect;
@@ -46,7 +46,7 @@ scoped_ptr<RenderPass> CreateTestRenderPass(
}
scoped_ptr<SharedQuadState> CreateTestSharedQuadState(
- gfx::Transform content_to_target_transform, gfx::Rect rect) {
+ gfx::Transform content_to_target_transform, const gfx::Rect& rect) {
const gfx::Size content_bounds = rect.size();
const gfx::Rect visible_content_rect = rect;
const gfx::Rect clip_rect = rect;
@@ -66,8 +66,8 @@ scoped_ptr<SharedQuadState> CreateTestSharedQuadState(
scoped_ptr<SharedQuadState> CreateTestSharedQuadStateClipped(
gfx::Transform content_to_target_transform,
- gfx::Rect rect,
- gfx::Rect clip_rect) {
+ const gfx::Rect& rect,
+ const gfx::Rect& clip_rect) {
const gfx::Size content_bounds = rect.size();
const gfx::Rect visible_content_rect = clip_rect;
const bool is_clipped = true;
@@ -85,7 +85,9 @@ scoped_ptr<SharedQuadState> CreateTestSharedQuadStateClipped(
}
scoped_ptr<DrawQuad> CreateTestRenderPassDrawQuad(
- SharedQuadState* shared_state, gfx::Rect rect, RenderPass::Id pass_id) {
+ SharedQuadState* shared_state,
+ const gfx::Rect& rect,
+ RenderPass::Id pass_id) {
scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create();
quad->SetNew(shared_state,
rect,
@@ -101,7 +103,7 @@ scoped_ptr<DrawQuad> CreateTestRenderPassDrawQuad(
}
scoped_ptr<TextureDrawQuad> CreateTestTextureDrawQuad(
- gfx::Rect rect,
+ const gfx::Rect& rect,
SkColor texel_color,
SkColor background_color,
bool premultiplied_alpha,
diff --git a/cc/output/software_output_device.cc b/cc/output/software_output_device.cc
index 17ef63f..3e75e06 100644
--- a/cc/output/software_output_device.cc
+++ b/cc/output/software_output_device.cc
@@ -27,7 +27,7 @@ void SoftwareOutputDevice::Resize(gfx::Size viewport_size) {
canvas_ = skia::AdoptRef(new SkCanvas(device_.get()));
}
-SkCanvas* SoftwareOutputDevice::BeginPaint(gfx::Rect damage_rect) {
+SkCanvas* SoftwareOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
DCHECK(device_);
damage_rect_ = damage_rect;
return canvas_.get();
@@ -42,14 +42,14 @@ void SoftwareOutputDevice::EndPaint(SoftwareFrameData* frame_data) {
}
void SoftwareOutputDevice::CopyToBitmap(
- gfx::Rect rect, SkBitmap* output) {
+ const gfx::Rect& rect, SkBitmap* output) {
DCHECK(device_);
const SkBitmap& bitmap = device_->accessBitmap(false);
bitmap.extractSubset(output, gfx::RectToSkIRect(rect));
}
void SoftwareOutputDevice::Scroll(
- gfx::Vector2d delta, gfx::Rect clip_rect) {
+ gfx::Vector2d delta, const gfx::Rect& clip_rect) {
NOTIMPLEMENTED();
}
diff --git a/cc/output/software_output_device.h b/cc/output/software_output_device.h
index 4ecf1fe..e203902 100644
--- a/cc/output/software_output_device.h
+++ b/cc/output/software_output_device.h
@@ -42,7 +42,7 @@ class CC_EXPORT SoftwareOutputDevice {
// SkCanvas. The |SoftwareOutputDevice| implementation needs to provide a
// valid SkCanvas of at least size |damage_rect|. This class retains ownership
// of the SkCanvas.
- virtual SkCanvas* BeginPaint(gfx::Rect damage_rect);
+ virtual SkCanvas* BeginPaint(const gfx::Rect& damage_rect);
// Called on FinishDrawingFrame. The compositor will no longer mutate the the
// SkCanvas instance returned by |BeginPaint| and should discard any reference
@@ -51,12 +51,12 @@ class CC_EXPORT SoftwareOutputDevice {
// Copies pixels inside |rect| from the current software framebuffer to
// |output|. Fails if there is no current softwareframebuffer.
- virtual void CopyToBitmap(gfx::Rect rect, SkBitmap* output);
+ virtual void CopyToBitmap(const gfx::Rect& rect, SkBitmap* output);
// Blit the pixel content of the SoftwareOutputDevice by |delta| with the
// write clipped to |clip_rect|.
virtual void Scroll(gfx::Vector2d delta,
- gfx::Rect clip_rect);
+ const gfx::Rect& clip_rect);
// Discard the backing buffer in the surface provided by this instance.
virtual void DiscardBackbuffer() {}
diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc
index 84f6f1e..7a0593d 100644
--- a/cc/output/software_renderer.cc
+++ b/cc/output/software_renderer.cc
@@ -157,7 +157,7 @@ void SoftwareRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
bool SoftwareRenderer::BindFramebufferToTexture(
DrawingFrame* frame,
const ScopedResource* texture,
- gfx::Rect target_rect) {
+ const gfx::Rect& target_rect) {
current_framebuffer_lock_.reset();
current_framebuffer_lock_ = make_scoped_ptr(
new ResourceProvider::ScopedWriteLockSoftware(
@@ -170,13 +170,13 @@ bool SoftwareRenderer::BindFramebufferToTexture(
return true;
}
-void SoftwareRenderer::SetScissorTestRect(gfx::Rect scissor_rect) {
+void SoftwareRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
is_scissor_enabled_ = true;
scissor_rect_ = scissor_rect;
SetClipRect(scissor_rect);
}
-void SoftwareRenderer::SetClipRect(gfx::Rect rect) {
+void SoftwareRenderer::SetClipRect(const gfx::Rect& rect) {
// Skia applies the current matrix to clip rects so we reset it temporary.
SkMatrix current_matrix = current_canvas_->getTotalMatrix();
current_canvas_->resetMatrix();
@@ -209,7 +209,8 @@ void SoftwareRenderer::ClearFramebuffer(DrawingFrame* frame,
}
}
-void SoftwareRenderer::SetDrawViewport(gfx::Rect window_space_viewport) {}
+void SoftwareRenderer::SetDrawViewport(
+ const gfx::Rect& window_space_viewport) {}
bool SoftwareRenderer::IsSoftwareResource(
ResourceProvider::ResourceId resource_id) const {
@@ -587,14 +588,16 @@ void SoftwareRenderer::EnsureBackbuffer() {
is_backbuffer_discarded_ = false;
}
-void SoftwareRenderer::GetFramebufferPixels(void* pixels, gfx::Rect rect) {
+void SoftwareRenderer::GetFramebufferPixels(void* pixels,
+ const gfx::Rect& rect) {
TRACE_EVENT0("cc", "SoftwareRenderer::GetFramebufferPixels");
SkBitmap subset_bitmap;
- rect += current_viewport_rect_.OffsetFromOrigin();
- output_device_->CopyToBitmap(rect, &subset_bitmap);
+ gfx::Rect frame_rect(rect);
+ frame_rect += current_viewport_rect_.OffsetFromOrigin();
+ output_device_->CopyToBitmap(frame_rect, &subset_bitmap);
subset_bitmap.copyPixelsTo(pixels,
- 4 * rect.width() * rect.height(),
- 4 * rect.width());
+ 4 * frame_rect.width() * frame_rect.height(),
+ 4 * frame_rect.width());
}
void SoftwareRenderer::SetVisible(bool visible) {
diff --git a/cc/output/software_renderer.h b/cc/output/software_renderer.h
index 18fb2a3..1da90ee 100644
--- a/cc/output/software_renderer.h
+++ b/cc/output/software_renderer.h
@@ -37,7 +37,8 @@ class CC_EXPORT SoftwareRenderer : public DirectRenderer {
virtual const RendererCapabilities& Capabilities() const OVERRIDE;
virtual void Finish() OVERRIDE;
virtual void SwapBuffers(const CompositorFrameMetadata& metadata) OVERRIDE;
- virtual void GetFramebufferPixels(void* pixels, gfx::Rect rect) OVERRIDE;
+ virtual void GetFramebufferPixels(void* pixels,
+ const gfx::Rect& rect) OVERRIDE;
virtual void SetVisible(bool visible) OVERRIDE;
virtual void SendManagedMemoryStats(
size_t bytes_visible,
@@ -53,9 +54,9 @@ class CC_EXPORT SoftwareRenderer : public DirectRenderer {
virtual bool BindFramebufferToTexture(
DrawingFrame* frame,
const ScopedResource* texture,
- gfx::Rect target_rect) OVERRIDE;
- virtual void SetDrawViewport(gfx::Rect window_space_viewport) OVERRIDE;
- virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE;
+ const gfx::Rect& target_rect) OVERRIDE;
+ virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) OVERRIDE;
+ virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) OVERRIDE;
virtual void DiscardPixels(bool has_external_stencil_test,
bool draw_rect_covers_full_surface) OVERRIDE;
virtual void ClearFramebuffer(DrawingFrame* frame,
@@ -77,7 +78,7 @@ class CC_EXPORT SoftwareRenderer : public DirectRenderer {
private:
void ClearCanvas(SkColor color);
- void SetClipRect(gfx::Rect rect);
+ void SetClipRect(const gfx::Rect& rect);
bool IsSoftwareResource(ResourceProvider::ResourceId resource_id) const;
void DrawCheckerboardQuad(const DrawingFrame* frame,