Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / cc / resources / filter_display_item.cc
blob63bfeee9d85d40c14054cc89772c249edd51b2ef
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/filter_display_item.h"
7 #include "third_party/skia/include/core/SkCanvas.h"
8 #include "third_party/skia/include/core/SkImageFilter.h"
9 #include "third_party/skia/include/core/SkPaint.h"
10 #include "third_party/skia/include/core/SkXfermode.h"
11 #include "ui/gfx/skia_util.h"
13 namespace cc {
15 FilterDisplayItem::FilterDisplayItem(skia::RefPtr<SkImageFilter> filter,
16 gfx::RectF bounds)
17 : filter_(filter), bounds_(bounds) {
20 FilterDisplayItem::~FilterDisplayItem() {
23 void FilterDisplayItem::Raster(SkCanvas* canvas,
24 SkDrawPictureCallback* callback) const {
25 canvas->save();
26 SkRect boundaries;
27 filter_->computeFastBounds(gfx::RectFToSkRect(bounds_), &boundaries);
28 canvas->translate(bounds_.x(), bounds_.y());
29 boundaries.offset(-bounds_.x(), -bounds_.y());
31 SkPaint paint;
32 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
33 paint.setImageFilter(filter_.get());
34 canvas->saveLayer(&boundaries, &paint);
36 canvas->translate(-bounds_.x(), -bounds_.y());
39 bool FilterDisplayItem::IsSuitableForGpuRasterization() const {
40 return true;
43 int FilterDisplayItem::ApproximateOpCount() const {
44 return 1;
47 size_t FilterDisplayItem::PictureMemoryUsage() const {
48 return sizeof(skia::RefPtr<SkImageFilter>) + sizeof(gfx::RectF);
51 EndFilterDisplayItem::EndFilterDisplayItem() {
54 EndFilterDisplayItem::~EndFilterDisplayItem() {
57 void EndFilterDisplayItem::Raster(SkCanvas* canvas,
58 SkDrawPictureCallback* callback) const {
59 canvas->restore();
60 canvas->restore();
63 bool EndFilterDisplayItem::IsSuitableForGpuRasterization() const {
64 return true;
67 int EndFilterDisplayItem::ApproximateOpCount() const {
68 return 0;
71 size_t EndFilterDisplayItem::PictureMemoryUsage() const {
72 return 0;
75 } // namespace cc