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.
5 #include "cc/image_layer_updater.h"
6 #include "cc/resource_update_queue.h"
10 void ImageLayerUpdater::Resource::update(ResourceUpdateQueue
& queue
, const gfx::Rect
& sourceRect
, const gfx::Vector2d
& destOffset
, bool partialUpdate
, RenderingStats
&)
12 m_updater
->updateTexture(queue
, texture(), sourceRect
, destOffset
, partialUpdate
);
16 scoped_refptr
<ImageLayerUpdater
> ImageLayerUpdater::create()
18 return make_scoped_refptr(new ImageLayerUpdater());
21 scoped_ptr
<LayerUpdater::Resource
> ImageLayerUpdater::createResource(
22 PrioritizedResourceManager
* manager
)
24 return scoped_ptr
<LayerUpdater::Resource
>(new Resource(this, PrioritizedResource::create(manager
)));
27 void ImageLayerUpdater::updateTexture(ResourceUpdateQueue
& queue
, PrioritizedResource
* texture
, const gfx::Rect
& sourceRect
, const gfx::Vector2d
& destOffset
, bool partialUpdate
)
29 // Source rect should never go outside the image pixels, even if this
30 // is requested because the texture extends outside the image.
31 gfx::Rect clippedSourceRect
= sourceRect
;
32 gfx::Rect imageRect
= gfx::Rect(0, 0, m_bitmap
.width(), m_bitmap
.height());
33 clippedSourceRect
.Intersect(imageRect
);
35 gfx::Vector2d clippedDestOffset
= destOffset
+ gfx::Vector2d(clippedSourceRect
.origin() - sourceRect
.origin());
37 ResourceUpdate upload
= ResourceUpdate::Create(texture
,
43 queue
.appendPartialUpload(upload
);
45 queue
.appendFullUpload(upload
);
48 void ImageLayerUpdater::setBitmap(const SkBitmap
& bitmap
)