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

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

Issue 942403002: Add a compositing display item which replaces transparency display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forward decls and imports oh my 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') | no next file » | 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 skia::RefPtr<SkColorFilter> cf)
19 : opacity_(opacity), xfermode_(xfermode), color_filter_(cf) {
20 }
21
22 CompositingDisplayItem::~CompositingDisplayItem() {
23 }
24
25 void CompositingDisplayItem::Raster(SkCanvas* canvas,
26 SkDrawPictureCallback* callback) const {
27 SkPaint paint;
28 paint.setXfermodeMode(xfermode_);
29 paint.setAlpha(opacity_ * 255);
30 paint.setColorFilter(color_filter_.get());
31 canvas->saveLayer(NULL, &paint);
32 }
33
34 bool CompositingDisplayItem::IsSuitableForGpuRasterization() const {
35 return true;
36 }
37
38 int CompositingDisplayItem::ApproximateOpCount() const {
39 return 1;
40 }
41
42 size_t CompositingDisplayItem::PictureMemoryUsage() const {
43 // TODO(pdr): Include color_filter's memory here.
44 return sizeof(float) + sizeof(SkXfermode::Mode);
45 }
46
47 void CompositingDisplayItem::AsValueInto(
48 base::trace_event::TracedValue* array) const {
49 array->AppendString(base::StringPrintf(
50 "CompositingDisplayItem opacity: %f, xfermode: %d", opacity_, xfermode_));
51 }
52
53 EndCompositingDisplayItem::EndCompositingDisplayItem() {
54 }
55
56 EndCompositingDisplayItem::~EndCompositingDisplayItem() {
57 }
58
59 void EndCompositingDisplayItem::Raster(SkCanvas* canvas,
60 SkDrawPictureCallback* callback) const {
61 canvas->restore();
62 }
63
64 bool EndCompositingDisplayItem::IsSuitableForGpuRasterization() const {
65 return true;
66 }
67
68 int EndCompositingDisplayItem::ApproximateOpCount() const {
69 return 0;
70 }
71
72 size_t EndCompositingDisplayItem::PictureMemoryUsage() const {
73 return 0;
74 }
75
76 void EndCompositingDisplayItem::AsValueInto(
77 base::trace_event::TracedValue* array) const {
78 array->AppendString("EndCompositingDisplayItem");
79 }
80
81 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/compositing_display_item.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698