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

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

Issue 1409713002: cc: Remove cc::ContentLayerClient::PaintContents(SkCanvas*, ...). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: restore comment Created 5 years, 2 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/layers/picture_image_layer.h ('k') | cc/layers/picture_layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/layers/picture_image_layer_impl.h" 7 #include "cc/layers/picture_image_layer_impl.h"
8 #include "cc/playback/display_item_list_settings.h" 8 #include "cc/playback/display_item_list_settings.h"
9 #include "cc/playback/drawing_display_item.h" 9 #include "cc/playback/drawing_display_item.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // affect the actual contents of the image (e.g. a CSS animation). 42 // affect the actual contents of the image (e.g. a CSS animation).
43 // With this check in place we avoid unecessary texture uploads. 43 // With this check in place we avoid unecessary texture uploads.
44 if (image_.get() == image.get()) 44 if (image_.get() == image.get())
45 return; 45 return;
46 46
47 image_ = image.Pass(); 47 image_ = image.Pass();
48 UpdateDrawsContent(HasDrawableContent()); 48 UpdateDrawsContent(HasDrawableContent());
49 SetNeedsDisplay(); 49 SetNeedsDisplay();
50 } 50 }
51 51
52 void PictureImageLayer::PaintContents( 52 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList(
53 SkCanvas* canvas,
54 const gfx::Rect& clip, 53 const gfx::Rect& clip,
55 ContentLayerClient::PaintingControlSetting painting_control) { 54 ContentLayerClient::PaintingControlSetting painting_control) {
56 DCHECK(image_); 55 DCHECK(image_);
57 DCHECK_GT(image_->width(), 0); 56 DCHECK_GT(image_->width(), 0);
58 DCHECK_GT(image_->height(), 0); 57 DCHECK_GT(image_->height(), 0);
59 58
59 // Picture image layers can be used with GatherPixelRefs, so cached SkPictures
60 // are currently required.
61 DisplayItemListSettings settings;
62 settings.use_cached_picture = true;
63 scoped_refptr<DisplayItemList> display_list =
64 DisplayItemList::Create(clip, settings);
65
66 SkPictureRecorder recorder;
67 SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip));
68
60 SkScalar content_to_layer_scale_x = 69 SkScalar content_to_layer_scale_x =
61 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width()); 70 SkFloatToScalar(static_cast<float>(bounds().width()) / image_->width());
62 SkScalar content_to_layer_scale_y = 71 SkScalar content_to_layer_scale_y =
63 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height()); 72 SkFloatToScalar(static_cast<float>(bounds().height()) / image_->height());
64 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y); 73 canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
65 74
66 // Because Android WebView resourceless software draw mode rasters directly 75 // Because Android WebView resourceless software draw mode rasters directly
67 // to the root canvas, this draw must use the kSrcOver_Mode so that 76 // to the root canvas, this draw must use the kSrcOver_Mode so that
68 // transparent images blend correctly. 77 // transparent images blend correctly.
69 canvas->drawImage(image_.get(), 0, 0); 78 canvas->drawImage(image_.get(), 0, 0);
70 }
71
72 scoped_refptr<DisplayItemList> PictureImageLayer::PaintContentsToDisplayList(
73 const gfx::Rect& clip,
74 ContentLayerClient::PaintingControlSetting painting_control) {
75 // Picture image layers can be used with GatherPixelRefs, so cached SkPictures
76 // are currently required.
77 DisplayItemListSettings settings;
78 settings.use_cached_picture = true;
79 scoped_refptr<DisplayItemList> display_list =
80 DisplayItemList::Create(clip, settings);
81
82 SkPictureRecorder recorder;
83 SkCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(clip));
84 PaintContents(canvas, clip, painting_control);
85 79
86 skia::RefPtr<SkPicture> picture = 80 skia::RefPtr<SkPicture> picture =
87 skia::AdoptRef(recorder.endRecordingAsPicture()); 81 skia::AdoptRef(recorder.endRecordingAsPicture());
88 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); 82 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>();
89 item->SetNew(picture.Pass()); 83 item->SetNew(picture.Pass());
90 84
91 display_list->Finalize(); 85 display_list->Finalize();
92 return display_list; 86 return display_list;
93 } 87 }
94 88
95 bool PictureImageLayer::FillsBoundsCompletely() const { 89 bool PictureImageLayer::FillsBoundsCompletely() const {
96 return false; 90 return false;
97 } 91 }
98 92
99 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const { 93 size_t PictureImageLayer::GetApproximateUnsharedMemoryUsage() const {
100 return 0; 94 return 0;
101 } 95 }
102 96
103 } // namespace cc 97 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_image_layer.h ('k') | cc/layers/picture_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698