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 "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"
14 TransparencyDisplayItem::TransparencyDisplayItem(float opacity
,
15 SkXfermode::Mode blend_mode
)
16 : opacity_(opacity
), blend_mode_(blend_mode
) {
19 TransparencyDisplayItem::~TransparencyDisplayItem() {
22 void TransparencyDisplayItem::Raster(SkCanvas
* canvas
,
23 SkDrawPictureCallback
* callback
) const {
25 paint
.setXfermodeMode(blend_mode_
);
26 paint
.setAlpha(opacity_
* 255);
27 canvas
->saveLayer(NULL
, &paint
);
30 bool TransparencyDisplayItem::IsSuitableForGpuRasterization() const {
34 int TransparencyDisplayItem::ApproximateOpCount() const {
38 size_t TransparencyDisplayItem::PictureMemoryUsage() const {
39 return sizeof(float) + sizeof(SkXfermode::Mode
);
42 EndTransparencyDisplayItem::EndTransparencyDisplayItem() {
45 EndTransparencyDisplayItem::~EndTransparencyDisplayItem() {
48 void EndTransparencyDisplayItem::Raster(SkCanvas
* canvas
,
49 SkDrawPictureCallback
* callback
) const {
53 bool EndTransparencyDisplayItem::IsSuitableForGpuRasterization() const {
57 int EndTransparencyDisplayItem::ApproximateOpCount() const {
61 size_t EndTransparencyDisplayItem::PictureMemoryUsage() const {