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

Unified Diff: cc/image_layer_updater.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/image_layer_updater.h ('k') | cc/nine_patch_layer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/image_layer_updater.cc
diff --git a/cc/image_layer_updater.cc b/cc/image_layer_updater.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9f73b8060175a73114652c403c3458d81963a943
--- /dev/null
+++ b/cc/image_layer_updater.cc
@@ -0,0 +1,55 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "cc/image_layer_updater.h"
+#include "cc/resource_update_queue.h"
+
+namespace cc {
+
+void ImageLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&)
+{
+ m_updater->updateTexture(queue, texture(), sourceRect, destOffset, partialUpdate);
+}
+
+// static
+scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::create()
+{
+ return make_scoped_refptr(new ImageLayerUpdater());
+}
+
+scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::createResource(
+ PrioritizedTextureManager* manager)
+{
+ return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedTexture::create(manager)));
+}
+
+void ImageLayerUpdater::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 + gfx::Vector2d(clippedSourceRect.origin() - sourceRect.origin());
+
+ ResourceUpdate upload = ResourceUpdate::Create(texture,
+ &m_bitmap,
+ imageRect,
+ clippedSourceRect,
+ clippedDestOffset);
+ if (partialUpdate)
+ queue.appendPartialUpload(upload);
+ else
+ queue.appendFullUpload(upload);
+}
+
+void ImageLayerUpdater::setBitmap(const SkBitmap& bitmap)
+{
+ m_bitmap = bitmap;
+}
+
+}
« no previous file with comments | « cc/image_layer_updater.h ('k') | cc/nine_patch_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698