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

Side by Side Diff: cc/image_layer_updater.cc

Issue 12471007: Part 8 of cc/ directory shuffles: resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/image_layer_updater.h ('k') | cc/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/image_layer_updater.h"
6 #include "cc/prioritized_resource.h"
7 #include "cc/resource_update_queue.h"
8
9 namespace cc {
10
11 ImageLayerUpdater::Resource::Resource(ImageLayerUpdater* updater,
12 scoped_ptr<PrioritizedResource> texture)
13 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {}
14
15 ImageLayerUpdater::Resource::~Resource() {}
16
17 void ImageLayerUpdater::Resource::Update(ResourceUpdateQueue* queue,
18 gfx::Rect source_rect,
19 gfx::Vector2d dest_offset,
20 bool partial_update,
21 RenderingStats*) {
22 updater_->UpdateTexture(
23 queue, texture(), source_rect, dest_offset, partial_update);
24 }
25
26 // static
27 scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::Create() {
28 return make_scoped_refptr(new ImageLayerUpdater());
29 }
30
31 scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::CreateResource(
32 PrioritizedResourceManager* manager) {
33 return scoped_ptr<LayerUpdater::Resource>(
34 new Resource(this, PrioritizedResource::create(manager)));
35 }
36
37 void ImageLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
38 PrioritizedResource* texture,
39 gfx::Rect source_rect,
40 gfx::Vector2d dest_offset,
41 bool partial_update) {
42 // Source rect should never go outside the image pixels, even if this
43 // is requested because the texture extends outside the image.
44 gfx::Rect clipped_source_rect = source_rect;
45 gfx::Rect image_rect = gfx::Rect(0, 0, bitmap_.width(), bitmap_.height());
46 clipped_source_rect.Intersect(image_rect);
47
48 gfx::Vector2d clipped_dest_offset =
49 dest_offset +
50 gfx::Vector2d(clipped_source_rect.origin() - source_rect.origin());
51
52 ResourceUpdate upload = ResourceUpdate::Create(
53 texture, &bitmap_, image_rect, clipped_source_rect, clipped_dest_offset);
54 if (partial_update)
55 queue->appendPartialUpload(upload);
56 else
57 queue->appendFullUpload(upload);
58 }
59
60 }
OLDNEW
« no previous file with comments | « cc/image_layer_updater.h ('k') | cc/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698