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

Side by Side Diff: cc/layers/picture_image_layer.cc

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Clean up comments, fix mac build Created 3 years, 11 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
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/picture_image_layer.h" 5 #include "cc/layers/picture_image_layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/layers/picture_layer_impl.h" 9 #include "cc/layers/picture_layer_impl.h"
10 #include "cc/paint/paint_canvas.h"
11 #include "cc/paint/paint_recorder.h"
10 #include "cc/playback/display_item_list_settings.h" 12 #include "cc/playback/display_item_list_settings.h"
11 #include "cc/playback/drawing_display_item.h" 13 #include "cc/playback/drawing_display_item.h"
12 #include "cc/trees/layer_tree_host.h" 14 #include "cc/trees/layer_tree_host.h"
13 #include "cc/trees/layer_tree_settings.h" 15 #include "cc/trees/layer_tree_settings.h"
14 #include "third_party/skia/include/core/SkCanvas.h"
15 #include "third_party/skia/include/core/SkImage.h"
16 #include "third_party/skia/include/core/SkPictureRecorder.h"
17 #include "ui/gfx/skia_util.h"
18 16
19 namespace cc { 17 namespace cc {
20 18
21 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() { 19 scoped_refptr<PictureImageLayer> PictureImageLayer::Create() {
22 return make_scoped_refptr(new PictureImageLayer()); 20 return make_scoped_refptr(new PictureImageLayer());
23 } 21 }
24 22
25 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {} 23 PictureImageLayer::PictureImageLayer() : PictureLayer(this) {}
26 24
27 PictureImageLayer::~PictureImageLayer() { 25 PictureImageLayer::~PictureImageLayer() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DCHECK_GT(image_->width(), 0); 60 DCHECK_GT(image_->width(), 0);
63 DCHECK_GT(image_->height(), 0); 61 DCHECK_GT(image_->height(), 0);
64 DCHECK(layer_tree_host()); 62 DCHECK(layer_tree_host());
65 63
66 DisplayItemListSettings settings; 64 DisplayItemListSettings settings;
67 settings.use_cached_picture = 65 settings.use_cached_picture =
68 layer_tree_host()->GetSettings().use_cached_picture_raster; 66 layer_tree_host()->GetSettings().use_cached_picture_raster;
69 scoped_refptr<DisplayItemList> display_list = 67 scoped_refptr<DisplayItemList> display_list =
70 DisplayItemList::Create(settings); 68 DisplayItemList::Create(settings);
71 69
72 SkPictureRecorder recorder; 70 PaintRecorder recorder;
73 SkCanvas* canvas = 71 PaintCanvas* canvas =
74 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); 72 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion()));
75 73
76 SkScalar content_to_layer_scale_x = 74 SkScalar content_to_layer_scale_x =
77 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); 75 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width());
78 SkScalar content_to_layer_scale_y = 76 SkScalar content_to_layer_scale_y =
79 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); 77 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height());
80 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); 78 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
81 79
82 // Because Android WebView resourceless software draw mode rasters directly 80 // Because Android WebView resourceless software draw mode rasters directly
83 // to the root canvas, this draw must use the kSrcOver_Mode so that 81 // to the root canvas, this draw must use the kSrcOver_Mode so that
84 // transparent images blend correctly. 82 // transparent images blend correctly.
85 canvas->drawImage(image_.get(), 0, 0); 83 canvas->drawImage(image_.get(), 0, 0);
86 84
87 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 85 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
88 PaintableRegion(), recorder.finishRecordingAsPicture()); 86 PaintableRegion(), recorder.finishRecordingAsPicture());
89 87
90 display_list->Finalize(); 88 display_list->Finalize();
91 return display_list; 89 return display_list;
92 } 90 }
93 91
94 bool PictureImageLayer::FillsBoundsCompletely() const { 92 bool PictureImageLayer::FillsBoundsCompletely() const {
95 return false; 93 return false;
96 } 94 }
97 95
98 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { 96 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const {
99 return 0; 97 return 0;
100 } 98 }
101 99
102 } // namespace cc 100 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698