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

Side by Side Diff: cc/image_layer.cc

Issue 11266030: Use gfx:: Geometry types for the resource provider and layer updater classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uint8 Created 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/heads_up_display_layer_impl.cc ('k') | cc/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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/image_layer.h" 7 #include "cc/image_layer.h"
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "cc/layer_updater.h" 10 #include "cc/layer_updater.h"
11 #include "cc/layer_tree_host.h" 11 #include "cc/layer_tree_host.h"
12 #include "cc/resource_update_queue.h" 12 #include "cc/resource_update_queue.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 class ImageLayerUpdater : public LayerUpdater { 16 class ImageLayerUpdater : public LayerUpdater {
17 public: 17 public:
18 class Resource : public LayerUpdater::Resource { 18 class Resource : public LayerUpdater::Resource {
19 public: 19 public:
20 Resource(ImageLayerUpdater* updater, scoped_ptr<PrioritizedTexture> text ure) 20 Resource(ImageLayerUpdater* updater, scoped_ptr<PrioritizedTexture> text ure)
21 : LayerUpdater::Resource(texture.Pass()) 21 : LayerUpdater::Resource(texture.Pass())
22 , m_updater(updater) 22 , m_updater(updater)
23 { 23 {
24 } 24 }
25 25
26 virtual void update(ResourceUpdateQueue& queue, const IntRect& sourceRec t, const IntSize& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE 26 virtual void update(ResourceUpdateQueue& queue, const gfx::Rect& sourceR ect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERR IDE
27 { 27 {
28 updater()->updateTexture(queue, texture(), sourceRect, destOffset, p artialUpdate); 28 updater()->updateTexture(queue, texture(), sourceRect, destOffset, p artialUpdate);
29 } 29 }
30 30
31 private: 31 private:
32 ImageLayerUpdater* updater() { return m_updater; } 32 ImageLayerUpdater* updater() { return m_updater; }
33 33
34 ImageLayerUpdater* m_updater; 34 ImageLayerUpdater* m_updater;
35 }; 35 };
36 36
37 static scoped_refptr<ImageLayerUpdater> create() 37 static scoped_refptr<ImageLayerUpdater> create()
38 { 38 {
39 return make_scoped_refptr(new ImageLayerUpdater()); 39 return make_scoped_refptr(new ImageLayerUpdater());
40 } 40 }
41 41
42 virtual scoped_ptr<LayerUpdater::Resource> createResource( 42 virtual scoped_ptr<LayerUpdater::Resource> createResource(
43 PrioritizedTextureManager* manager) OVERRIDE 43 PrioritizedTextureManager* manager) OVERRIDE
44 { 44 {
45 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, Prioritized Texture::create(manager))); 45 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, Prioritized Texture::create(manager)));
46 } 46 }
47 47
48 void updateTexture(ResourceUpdateQueue& queue, PrioritizedTexture* texture, const IntRect& sourceRect, const IntSize& destOffset, bool partialUpdate) 48 void updateTexture(ResourceUpdateQueue& queue, PrioritizedTexture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate )
49 { 49 {
50 // Source rect should never go outside the image pixels, even if this 50 // Source rect should never go outside the image pixels, even if this
51 // is requested because the texture extends outside the image. 51 // is requested because the texture extends outside the image.
52 IntRect clippedSourceRect = sourceRect; 52 gfx::Rect clippedSourceRect = sourceRect;
53 IntRect imageRect = IntRect(0, 0, m_bitmap.width(), m_bitmap.height()); 53 gfx::Rect imageRect = gfx::Rect(0, 0, m_bitmap.width(), m_bitmap.height( ));
54 clippedSourceRect.intersect(imageRect); 54 clippedSourceRect.Intersect(imageRect);
55 55
56 IntSize clippedDestOffset = destOffset + IntSize(clippedSourceRect.locat ion() - sourceRect.location()); 56 gfx::Vector2d clippedDestOffset = destOffset + (clippedSourceRect.origin () - sourceRect.origin());
57 57
58 ResourceUpdate upload = ResourceUpdate::Create(texture, 58 ResourceUpdate upload = ResourceUpdate::Create(texture,
59 &m_bitmap, 59 &m_bitmap,
60 imageRect, 60 imageRect,
61 clippedSourceRect, 61 clippedSourceRect,
62 clippedDestOffset); 62 clippedDestOffset);
63 if (partialUpdate) 63 if (partialUpdate)
64 queue.appendPartialUpload(upload); 64 queue.appendPartialUpload(upload);
65 else 65 else
66 queue.appendFullUpload(upload); 66 queue.appendFullUpload(upload);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return !m_bitmap.isNull() && TiledLayer::drawsContent(); 150 return !m_bitmap.isNull() && TiledLayer::drawsContent();
151 } 151 }
152 152
153 bool ImageLayer::needsContentsScale() const 153 bool ImageLayer::needsContentsScale() const
154 { 154 {
155 // Contents scale is not need for image layer because this can be done in co mpositor more efficiently. 155 // Contents scale is not need for image layer because this can be done in co mpositor more efficiently.
156 return false; 156 return false;
157 } 157 }
158 158
159 } 159 }
OLDNEW
« no previous file with comments | « cc/heads_up_display_layer_impl.cc ('k') | cc/layer_painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698