Add Sad Tab resources to the iOS build.
[chromium-blink-merge.git] / cc / image_layer_updater.cc
blob40bf4722858c319a218e4bba97bac8930a2270a4
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 "config.h"
7 #include "cc/image_layer_updater.h"
8 #include "cc/resource_update_queue.h"
10 namespace cc {
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);
17 // static
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,
40 &m_bitmap,
41 imageRect,
42 clippedSourceRect,
43 clippedDestOffset);
44 if (partialUpdate)
45 queue.appendPartialUpload(upload);
46 else
47 queue.appendFullUpload(upload);
50 void ImageLayerUpdater::setBitmap(const SkBitmap& bitmap)
52 m_bitmap = bitmap;