Don't add extra app list launcher page webviews.
[chromium-blink-merge.git] / cc / resources / filter_display_item.cc
blob31abf282a9a643c1dcf94bc4d359313551ab6a9f
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 "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "cc/output/render_surface_filters.h"
10 #include "skia/ext/refptr.h"
11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "third_party/skia/include/core/SkImageFilter.h"
13 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkXfermode.h"
15 #include "ui/gfx/skia_util.h"
17 namespace cc {
19 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters,
20 gfx::RectF bounds)
21 : filters_(filters), bounds_(bounds) {
24 FilterDisplayItem::~FilterDisplayItem() {
27 void FilterDisplayItem::Raster(SkCanvas* canvas,
28 SkDrawPictureCallback* callback) const {
29 canvas->save();
30 canvas->translate(bounds_.x(), bounds_.y());
32 skia::RefPtr<SkImageFilter> image_filter =
33 RenderSurfaceFilters::BuildImageFilter(
34 filters_, gfx::SizeF(bounds_.width(), bounds_.height()));
35 SkRect boundaries;
36 image_filter->computeFastBounds(
37 SkRect::MakeWH(bounds_.width(), bounds_.height()), &boundaries);
39 SkPaint paint;
40 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
41 paint.setImageFilter(image_filter.get());
42 canvas->saveLayer(&boundaries, &paint);
44 canvas->translate(-bounds_.x(), -bounds_.y());
47 bool FilterDisplayItem::IsSuitableForGpuRasterization() const {
48 return true;
51 int FilterDisplayItem::ApproximateOpCount() const {
52 return 1;
55 size_t FilterDisplayItem::PictureMemoryUsage() const {
56 return sizeof(skia::RefPtr<SkImageFilter>) + sizeof(gfx::RectF);
59 void FilterDisplayItem::AsValueInto(
60 base::trace_event::TracedValue* array) const {
61 array->AppendString(base::StringPrintf("FilterDisplayItem bounds: [%s]",
62 bounds_.ToString().c_str()));
65 EndFilterDisplayItem::EndFilterDisplayItem() {
68 EndFilterDisplayItem::~EndFilterDisplayItem() {
71 void EndFilterDisplayItem::Raster(SkCanvas* canvas,
72 SkDrawPictureCallback* callback) const {
73 canvas->restore();
74 canvas->restore();
77 bool EndFilterDisplayItem::IsSuitableForGpuRasterization() const {
78 return true;
81 int EndFilterDisplayItem::ApproximateOpCount() const {
82 return 0;
85 size_t EndFilterDisplayItem::PictureMemoryUsage() const {
86 return 0;
89 void EndFilterDisplayItem::AsValueInto(
90 base::trace_event::TracedValue* array) const {
91 array->AppendString("EndFilterDisplayItem");
94 } // namespace cc