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

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

Issue 960873002: Update from https://crrev.com/318214 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/compositing_display_item.h ('k') | cc/resources/one_copy_tile_task_worker_pool.cc » ('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 2015 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/compositing_display_item.h"
6
7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkPaint.h"
11 #include "third_party/skia/include/core/SkXfermode.h"
12 #include "ui/gfx/skia_util.h"
13
14 namespace cc {
15
16 CompositingDisplayItem::CompositingDisplayItem(float opacity,
17 SkXfermode::Mode xfermode,
18 SkRect* bounds,
19 skia::RefPtr<SkColorFilter> cf)
20 : opacity_(opacity),
21 xfermode_(xfermode),
22 has_bounds_(!!bounds),
23 color_filter_(cf) {
24 if (bounds)
25 bounds_ = SkRect(*bounds);
26 }
27
28 CompositingDisplayItem::~CompositingDisplayItem() {
29 }
30
31 void CompositingDisplayItem::Raster(SkCanvas* canvas,
32 SkDrawPictureCallback* callback) const {
33 SkPaint paint;
34 paint.setXfermodeMode(xfermode_);
35 paint.setAlpha(opacity_ * 255);
36 paint.setColorFilter(color_filter_.get());
37 canvas->saveLayer(has_bounds_ ? &bounds_ : nullptr, &paint);
38 }
39
40 bool CompositingDisplayItem::IsSuitableForGpuRasterization() const {
41 return true;
42 }
43
44 int CompositingDisplayItem::ApproximateOpCount() const {
45 return 1;
46 }
47
48 size_t CompositingDisplayItem::PictureMemoryUsage() const {
49 // TODO(pdr): Include color_filter's memory here.
50 return sizeof(float) + sizeof(bool) + sizeof(SkRect) +
51 sizeof(SkXfermode::Mode);
52 }
53
54 void CompositingDisplayItem::AsValueInto(
55 base::trace_event::TracedValue* array) const {
56 array->AppendString(base::StringPrintf(
57 "CompositingDisplayItem opacity: %f, xfermode: %d", opacity_, xfermode_));
58 if (has_bounds_)
59 array->AppendString(base::StringPrintf(
60 ", bounds: [%f, %f, %f, %f]", static_cast<float>(bounds_.x()),
61 static_cast<float>(bounds_.y()), static_cast<float>(bounds_.width()),
62 static_cast<float>(bounds_.height())));
63 }
64
65 EndCompositingDisplayItem::EndCompositingDisplayItem() {
66 }
67
68 EndCompositingDisplayItem::~EndCompositingDisplayItem() {
69 }
70
71 void EndCompositingDisplayItem::Raster(SkCanvas* canvas,
72 SkDrawPictureCallback* callback) const {
73 canvas->restore();
74 }
75
76 bool EndCompositingDisplayItem::IsSuitableForGpuRasterization() const {
77 return true;
78 }
79
80 int EndCompositingDisplayItem::ApproximateOpCount() const {
81 return 0;
82 }
83
84 size_t EndCompositingDisplayItem::PictureMemoryUsage() const {
85 return 0;
86 }
87
88 void EndCompositingDisplayItem::AsValueInto(
89 base::trace_event::TracedValue* array) const {
90 array->AppendString("EndCompositingDisplayItem");
91 }
92
93 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/compositing_display_item.h ('k') | cc/resources/one_copy_tile_task_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698