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

Side by Side Diff: cc/resources/image_layer_updater.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/resources/image_layer_updater.h ('k') | cc/resources/layer_painter.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/resources/image_layer_updater.h" 5 #include "cc/resources/image_layer_updater.h"
6 #include "cc/resources/prioritized_resource.h" 6 #include "cc/resources/prioritized_resource.h"
7 #include "cc/resources/resource_update_queue.h" 7 #include "cc/resources/resource_update_queue.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 ImageLayerUpdater::Resource::Resource(ImageLayerUpdater* updater, 11 ImageLayerUpdater::Resource::Resource(ImageLayerUpdater* updater,
12 scoped_ptr<PrioritizedResource> texture) 12 scoped_ptr<PrioritizedResource> texture)
13 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {} 13 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {}
14 14
15 ImageLayerUpdater::Resource::~Resource() {} 15 ImageLayerUpdater::Resource::~Resource() {}
16 16
17 void ImageLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, 17 void ImageLayerUpdater::Resource::Update(ResourceUpdateQueue* queue,
18 gfx::Rect source_rect, 18 const gfx::Rect& source_rect,
19 gfx::Vector2d dest_offset, 19 gfx::Vector2d dest_offset,
20 bool partial_update) { 20 bool partial_update) {
21 updater_->UpdateTexture( 21 updater_->UpdateTexture(
22 queue, texture(), source_rect, dest_offset, partial_update); 22 queue, texture(), source_rect, dest_offset, partial_update);
23 } 23 }
24 24
25 // static 25 // static
26 scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::Create() { 26 scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::Create() {
27 return make_scoped_refptr(new ImageLayerUpdater()); 27 return make_scoped_refptr(new ImageLayerUpdater());
28 } 28 }
29 29
30 scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::CreateResource( 30 scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::CreateResource(
31 PrioritizedResourceManager* manager) { 31 PrioritizedResourceManager* manager) {
32 return scoped_ptr<LayerUpdater::Resource>( 32 return scoped_ptr<LayerUpdater::Resource>(
33 new Resource(this, PrioritizedResource::Create(manager))); 33 new Resource(this, PrioritizedResource::Create(manager)));
34 } 34 }
35 35
36 void ImageLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, 36 void ImageLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
37 PrioritizedResource* texture, 37 PrioritizedResource* texture,
38 gfx::Rect source_rect, 38 const gfx::Rect& source_rect,
39 gfx::Vector2d dest_offset, 39 gfx::Vector2d dest_offset,
40 bool partial_update) { 40 bool partial_update) {
41 // Source rect should never go outside the image pixels, even if this 41 // Source rect should never go outside the image pixels, even if this
42 // is requested because the texture extends outside the image. 42 // is requested because the texture extends outside the image.
43 gfx::Rect clipped_source_rect = source_rect; 43 gfx::Rect clipped_source_rect = source_rect;
44 gfx::Rect image_rect = gfx::Rect(0, 0, bitmap_.width(), bitmap_.height()); 44 gfx::Rect image_rect = gfx::Rect(0, 0, bitmap_.width(), bitmap_.height());
45 clipped_source_rect.Intersect(image_rect); 45 clipped_source_rect.Intersect(image_rect);
46 46
47 gfx::Vector2d clipped_dest_offset = 47 gfx::Vector2d clipped_dest_offset =
48 dest_offset + 48 dest_offset +
(...skipping 10 matching lines...) Expand all
59 void ImageLayerUpdater::SetBitmap(const SkBitmap& bitmap) { 59 void ImageLayerUpdater::SetBitmap(const SkBitmap& bitmap) {
60 DCHECK(bitmap.pixelRef()); 60 DCHECK(bitmap.pixelRef());
61 bitmap_ = bitmap; 61 bitmap_ = bitmap;
62 } 62 }
63 63
64 bool ImageLayerUpdater::UsingBitmap(const SkBitmap& bitmap) const { 64 bool ImageLayerUpdater::UsingBitmap(const SkBitmap& bitmap) const {
65 return bitmap.pixelRef() == bitmap_.pixelRef(); 65 return bitmap.pixelRef() == bitmap_.pixelRef();
66 } 66 }
67 67
68 } // namespace cc 68 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/image_layer_updater.h ('k') | cc/resources/layer_painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698