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

Side by Side Diff: cc/bitmap_content_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/bitmap_content_layer_updater.h ('k') | cc/bitmap_skpicture_content_layer_updater.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 2011 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/bitmap_content_layer_updater.h"
6
7 #include "cc/debug/rendering_stats.h"
8 #include "cc/layer_painter.h"
9 #include "cc/prioritized_resource.h"
10 #include "cc/resource_update.h"
11 #include "cc/resource_update_queue.h"
12 #include "skia/ext/platform_canvas.h"
13
14 namespace cc {
15
16 BitmapContentLayerUpdater::Resource::Resource(
17 BitmapContentLayerUpdater* updater,
18 scoped_ptr<PrioritizedResource> texture)
19 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {}
20
21 BitmapContentLayerUpdater::Resource::~Resource() {}
22
23 void BitmapContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue,
24 gfx::Rect source_rect,
25 gfx::Vector2d dest_offset,
26 bool partial_update,
27 RenderingStats* stats) {
28 updater_->UpdateTexture(
29 queue, texture(), source_rect, dest_offset, partial_update);
30 }
31
32 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create(
33 scoped_ptr<LayerPainter> painter) {
34 return make_scoped_refptr(new BitmapContentLayerUpdater(painter.Pass()));
35 }
36
37 BitmapContentLayerUpdater::BitmapContentLayerUpdater(
38 scoped_ptr<LayerPainter> painter)
39 : ContentLayerUpdater(painter.Pass()), opaque_(false) {}
40
41 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {}
42
43 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource(
44 PrioritizedResourceManager* manager) {
45 return scoped_ptr<LayerUpdater::Resource>(
46 new Resource(this, PrioritizedResource::create(manager)));
47 }
48
49 void BitmapContentLayerUpdater::PrepareToUpdate(
50 gfx::Rect content_rect,
51 gfx::Size tile_size,
52 float contents_width_scale,
53 float contents_height_scale,
54 gfx::Rect* resulting_opaque_rect,
55 RenderingStats* stats) {
56 if (canvas_size_ != content_rect.size()) {
57 canvas_size_ = content_rect.size();
58 canvas_ = make_scoped_ptr(skia::CreateBitmapCanvas(
59 canvas_size_.width(), canvas_size_.height(), opaque_));
60 }
61
62 if (stats) {
63 stats->totalPixelsRasterized +=
64 content_rect.width() * content_rect.height();
65 }
66
67 PaintContents(canvas_.get(),
68 content_rect,
69 contents_width_scale,
70 contents_height_scale,
71 resulting_opaque_rect,
72 stats);
73 }
74
75 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
76 PrioritizedResource* texture,
77 gfx::Rect source_rect,
78 gfx::Vector2d dest_offset,
79 bool partial_update) {
80 ResourceUpdate upload =
81 ResourceUpdate::Create(texture,
82 &canvas_->getDevice()->accessBitmap(false),
83 content_rect(),
84 source_rect,
85 dest_offset);
86 if (partial_update)
87 queue->appendPartialUpload(upload);
88 else
89 queue->appendFullUpload(upload);
90 }
91
92 void BitmapContentLayerUpdater::SetOpaque(bool opaque) {
93 if (opaque != opaque_) {
94 canvas_.reset();
95 canvas_size_ = gfx::Size();
96 }
97 opaque_ = opaque;
98 }
99
100 } // namespace cc
OLDNEW
« no previous file with comments | « cc/bitmap_content_layer_updater.h ('k') | cc/bitmap_skpicture_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698