Add iOS bots to 10% CQ experiment
[chromium-blink-merge.git] / cc / resources / transparency_display_item.cc
blob1c37b738eecaf1454105029d6363e123d27cfec5
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.
5 #include "cc/resources/transparency_display_item.h"
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"
14 namespace cc {
16 TransparencyDisplayItem::TransparencyDisplayItem(float opacity,
17 SkXfermode::Mode blend_mode)
18 : opacity_(opacity), blend_mode_(blend_mode) {
21 TransparencyDisplayItem::~TransparencyDisplayItem() {
24 void TransparencyDisplayItem::Raster(SkCanvas* canvas,
25 SkDrawPictureCallback* callback) const {
26 SkPaint paint;
27 paint.setXfermodeMode(blend_mode_);
28 paint.setAlpha(opacity_ * 255);
29 canvas->saveLayer(NULL, &paint);
32 bool TransparencyDisplayItem::IsSuitableForGpuRasterization() const {
33 return true;
36 int TransparencyDisplayItem::ApproximateOpCount() const {
37 return 1;
40 size_t TransparencyDisplayItem::PictureMemoryUsage() const {
41 return sizeof(float) + sizeof(SkXfermode::Mode);
44 void TransparencyDisplayItem::AsValueInto(
45 base::trace_event::TracedValue* array) const {
46 array->AppendString(
47 base::StringPrintf("TransparencyDisplayItem opacity: %f, blend_mode: %d",
48 opacity_, blend_mode_));
51 EndTransparencyDisplayItem::EndTransparencyDisplayItem() {
54 EndTransparencyDisplayItem::~EndTransparencyDisplayItem() {
57 void EndTransparencyDisplayItem::Raster(SkCanvas* canvas,
58 SkDrawPictureCallback* callback) const {
59 canvas->restore();
62 bool EndTransparencyDisplayItem::IsSuitableForGpuRasterization() const {
63 return true;
66 int EndTransparencyDisplayItem::ApproximateOpCount() const {
67 return 0;
70 size_t EndTransparencyDisplayItem::PictureMemoryUsage() const {
71 return 0;
74 void EndTransparencyDisplayItem::AsValueInto(
75 base::trace_event::TracedValue* array) const {
76 array->AppendString("EndTransparencyDisplayItem");
79 } // namespace cc