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.
7 #include "cc/image_layer_updater.h"
8 #include "cc/resource_update_queue.h"
12 void ImageLayerUpdater::Resource::update(ResourceUpdateQueue
& queue
, const gfx::Rect
& sourceRect
, const gfx::Vector2d
& destOffset
, bool partialUpdate
, RenderingStats
&)
14 m_updater
->updateTexture(queue
, texture(), sourceRect
, destOffset
, partialUpdate
);
18 scoped_refptr
<ImageLayerUpdater
> ImageLayerUpdater::create()
20 return make_scoped_refptr(new ImageLayerUpdater());
23 scoped_ptr
<LayerUpdater::Resource
> ImageLayerUpdater::createResource(
24 PrioritizedResourceManager
* manager
)
26 return scoped_ptr
<LayerUpdater::Resource
>(new Resource(this, PrioritizedResource::create(manager
)));
29 void ImageLayerUpdater::updateTexture(ResourceUpdateQueue
& queue
, PrioritizedResource
* texture
, const gfx::Rect
& sourceRect
, const gfx::Vector2d
& destOffset
, bool partialUpdate
)
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
);
37 gfx::Vector2d clippedDestOffset
= destOffset
+ gfx::Vector2d(clippedSourceRect
.origin() - sourceRect
.origin());
39 ResourceUpdate upload
= ResourceUpdate::Create(texture
,
45 queue
.appendPartialUpload(upload
);
47 queue
.appendFullUpload(upload
);
50 void ImageLayerUpdater::setBitmap(const SkBitmap
& bitmap
)