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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/transparency_display_item.h ('k') | cc/resources/video_resource_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 2014 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/transparency_display_item.h"
6
7 #include "third_party/skia/include/core/SkCanvas.h"
8 #include "third_party/skia/include/core/SkPaint.h"
9 #include "third_party/skia/include/core/SkXfermode.h"
10 #include "ui/gfx/skia_util.h"
11
12 namespace cc {
13
14 TransparencyDisplayItem::TransparencyDisplayItem(float opacity,
15 SkXfermode::Mode blend_mode)
16 : opacity_(opacity), blend_mode_(blend_mode) {
17 }
18
19 TransparencyDisplayItem::~TransparencyDisplayItem() {
20 }
21
22 void TransparencyDisplayItem::Raster(SkCanvas* canvas,
23 SkDrawPictureCallback* callback) const {
24 SkPaint paint;
25 paint.setXfermodeMode(blend_mode_);
26 paint.setAlpha(opacity_ * 255);
27 canvas->saveLayer(NULL, &paint);
28 }
29
30 bool TransparencyDisplayItem::IsSuitableForGpuRasterization() const {
31 return true;
32 }
33
34 int TransparencyDisplayItem::ApproximateOpCount() const {
35 return 1;
36 }
37
38 size_t TransparencyDisplayItem::PictureMemoryUsage() const {
39 return sizeof(float) + sizeof(SkXfermode::Mode);
40 }
41
42 EndTransparencyDisplayItem::EndTransparencyDisplayItem() {
43 }
44
45 EndTransparencyDisplayItem::~EndTransparencyDisplayItem() {
46 }
47
48 void EndTransparencyDisplayItem::Raster(SkCanvas* canvas,
49 SkDrawPictureCallback* callback) const {
50 canvas->restore();
51 }
52
53 bool EndTransparencyDisplayItem::IsSuitableForGpuRasterization() const {
54 return true;
55 }
56
57 int EndTransparencyDisplayItem::ApproximateOpCount() const {
58 return 0;
59 }
60
61 size_t EndTransparencyDisplayItem::PictureMemoryUsage() const {
62 return 0;
63 }
64
65 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/transparency_display_item.h ('k') | cc/resources/video_resource_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698