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

Side by Side 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: Fixed rebase to 165291 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6
7 #include "cc/image_layer_updater.h"
8 #include "cc/resource_update_queue.h"
9
10 namespace cc {
11
12 void ImageLayerUpdater::Resource::update(ResourceUpdateQueue& queue, const gfx:: Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, Rendering Stats&)
13 {
14 m_updater->updateTexture(queue, texture(), sourceRect, destOffset, partialUp date);
15 }
16
17 // static
18 scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::create()
19 {
20 return make_scoped_refptr(new ImageLayerUpdater());
21 }
22
23 scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::createResource(
24 PrioritizedTextureManager* manager)
25 {
26 return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedText ure::create(manager)));
27 }
28
29 void ImageLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedTex ture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, boo l partialUpdate)
30 {
31 // Source rect should never go outside the image pixels, even if this
32 // is requested because the texture extends outside the image.
33 gfx::Rect clippedSourceRect = sourceRect;
34 gfx::Rect imageRect = gfx::Rect(0, 0, m_bitmap.width(), m_bitmap.height());
35 clippedSourceRect.Intersect(imageRect);
36
37 gfx::Vector2d clippedDestOffset = destOffset + gfx::Vector2d(clippedSourceRe ct.origin() - sourceRect.origin());
38
39 ResourceUpdate upload = ResourceUpdate::Create(texture,
40 &m_bitmap,
41 imageRect,
42 clippedSourceRect,
43 clippedDestOffset);
44 if (partialUpdate)
45 queue.appendPartialUpload(upload);
46 else
47 queue.appendFullUpload(upload);
48 }
49
50 void ImageLayerUpdater::setBitmap(const SkBitmap& bitmap)
51 {
52 m_bitmap = bitmap;
53 }
54
55 }
OLDNEW
« no previous file with comments | « cc/image_layer_updater.h ('k') | cc/nine_patch_layer.h » ('j') | cc/nine_patch_layer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698