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

Side by Side Diff: cc/resources/bitmap_content_layer_updater.cc

Issue 1194743002: cc: Remove ResourceUpdateQueue and ResourceUpdateController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resourcequeue: header Created 5 years, 6 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
« no previous file with comments | « cc/resources/bitmap_content_layer_updater.h ('k') | cc/resources/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/resources/bitmap_content_layer_updater.h"
6
7 #include "cc/debug/devtools_instrumentation.h"
8 #include "cc/debug/rendering_stats_instrumentation.h"
9 #include "cc/resources/layer_painter.h"
10 #include "cc/resources/prioritized_resource.h"
11 #include "cc/resources/resource_update.h"
12 #include "cc/resources/resource_update_queue.h"
13 #include "skia/ext/platform_canvas.h"
14
15 namespace cc {
16
17 BitmapContentLayerUpdater::Resource::Resource(
18 BitmapContentLayerUpdater* updater,
19 scoped_ptr<PrioritizedResource> texture)
20 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {}
21
22 BitmapContentLayerUpdater::Resource::~Resource() {}
23
24 void BitmapContentLayerUpdater::Resource::Update(
25 ResourceUpdateQueue* queue,
26 const gfx::Rect& source_rect,
27 const gfx::Vector2d& dest_offset,
28 bool partial_update) {
29 updater_->UpdateTexture(
30 queue, texture(), source_rect, dest_offset, partial_update);
31 }
32
33 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create(
34 scoped_ptr<LayerPainter> painter,
35 int layer_id) {
36 return make_scoped_refptr(
37 new BitmapContentLayerUpdater(painter.Pass(),
38 layer_id));
39 }
40
41 BitmapContentLayerUpdater::BitmapContentLayerUpdater(
42 scoped_ptr<LayerPainter> painter,
43 int layer_id)
44 : ContentLayerUpdater(painter.Pass(), layer_id) {
45 }
46
47 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {}
48
49 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource(
50 PrioritizedResourceManager* manager) {
51 return make_scoped_ptr(
52 new Resource(this, PrioritizedResource::Create(manager)));
53 }
54
55 void BitmapContentLayerUpdater::PrepareToUpdate(const gfx::Size& content_size,
56 const gfx::Rect& paint_rect,
57 const gfx::Size& tile_size,
58 float contents_width_scale,
59 float contents_height_scale) {
60 if (canvas_size_ != paint_rect.size()) {
61 devtools_instrumentation::ScopedLayerTask paint_setup(
62 devtools_instrumentation::kPaintSetup, layer_id_);
63 canvas_size_ = paint_rect.size();
64 bitmap_backing_.allocN32Pixels(
65 canvas_size_.width(), canvas_size_.height(), layer_is_opaque_);
66 // TODO(danak): Remove when skia does the check for us: crbug.com/360384
67 canvas_ = skia::AdoptRef(new SkCanvas(bitmap_backing_));
68 DCHECK_EQ(paint_rect.width(), canvas_->getBaseLayerSize().width());
69 DCHECK_EQ(paint_rect.height(), canvas_->getBaseLayerSize().height());
70 }
71
72 PaintContents(canvas_.get(),
73 content_size,
74 paint_rect,
75 contents_width_scale,
76 contents_height_scale);
77 }
78
79 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
80 PrioritizedResource* texture,
81 const gfx::Rect& source_rect,
82 const gfx::Vector2d& dest_offset,
83 bool partial_update) {
84 CHECK(canvas_);
85 ResourceUpdate upload = ResourceUpdate::Create(
86 texture, &bitmap_backing_, paint_rect(), source_rect, dest_offset);
87 if (partial_update)
88 queue->AppendPartialUpload(upload);
89 else
90 queue->AppendFullUpload(upload);
91 }
92
93 void BitmapContentLayerUpdater::ReduceMemoryUsage() {
94 canvas_.clear();
95 canvas_size_ = gfx::Size();
96 }
97
98 void BitmapContentLayerUpdater::SetOpaque(bool opaque) {
99 if (opaque != layer_is_opaque_) {
100 canvas_.clear();
101 canvas_size_ = gfx::Size();
102 }
103
104 ContentLayerUpdater::SetOpaque(opaque);
105 }
106
107 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/bitmap_content_layer_updater.h ('k') | cc/resources/content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698