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

Unified Diff: cc/image_layer.cc

Issue 11304020: cc: Nine patch layer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix DCHECK failures and rebase to 166129 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/image_layer_updater.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/image_layer.cc
diff --git a/cc/image_layer.cc b/cc/image_layer.cc
index 51717990cc7f8b7c0e86ff6d1871a39ccbf249d9..c150c6d26773e42785b4c7588c75c9c1faef175a 100644
--- a/cc/image_layer.cc
+++ b/cc/image_layer.cc
@@ -7,77 +7,13 @@
#include "cc/image_layer.h"
#include "base/compiler_specific.h"
+#include "cc/image_layer_updater.h"
#include "cc/layer_updater.h"
#include "cc/layer_tree_host.h"
#include "cc/resource_update_queue.h"
namespace cc {
-class ImageLayerUpdater : public LayerUpdater {
-public:
- class Resource : public LayerUpdater::Resource {
- public:
- Resource(ImageLayerUpdater* updater, scoped_ptr<PrioritizedTexture> texture)
- : LayerUpdater::Resource(texture.Pass())
- , m_updater(updater)
- {
- }
-
- virtual void update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE
- {
- updater()->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate);
- }
-
- private:
- ImageLayerUpdater* updater() { return m_updater; }
-
- ImageLayerUpdater* m_updater;
- };
-
- static scoped_refptr<ImageLayerUpdater> create()
- {
- return make_scoped_refptr(new ImageLayerUpdater());
- }
-
- virtual scoped_ptr<LayerUpdater::Resource> createResource(
- PrioritizedTextureManager* manager) OVERRIDE
- {
- return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedTexture::create(manager)));
- }
-
- void updateTexture(ResourceUpdateQueue& queue, PrioritizedTexture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
- {
- // Source rect should never go outside the image pixels, even if this
- // is requested because the texture extends outside the image.
- gfx::Rect clippedSourceRect = sourceRect;
- gfx::Rect imageRect = gfx::Rect(0, 0, m_bitmap.width(), m_bitmap.height());
- clippedSourceRect.Intersect(imageRect);
-
- gfx::Vector2d clippedDestOffset = destOffset + (clippedSourceRect.origin() - sourceRect.origin());
-
- ResourceUpdate upload = ResourceUpdate::Create(texture,
- &m_bitmap,
- imageRect,
- clippedSourceRect,
- clippedDestOffset);
- if (partialUpdate)
- queue.appendPartialUpload(upload);
- else
- queue.appendFullUpload(upload);
- }
-
- void setBitmap(const SkBitmap& bitmap)
- {
- m_bitmap = bitmap;
- }
-
-private:
- ImageLayerUpdater() { }
- virtual ~ImageLayerUpdater() { }
-
- SkBitmap m_bitmap;
-};
-
scoped_refptr<ImageLayer> ImageLayer::create()
{
return make_scoped_refptr(new ImageLayer());
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/image_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698