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

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

Issue 1144693002: cc: Move files out of cc/resources/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resources: android Created 5 years, 7 months 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/filter_display_item.h ('k') | cc/resources/float_clip_display_item.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/filter_display_item.h"
6
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"
16
17 namespace cc {
18
19 FilterDisplayItem::FilterDisplayItem() {
20 }
21
22 FilterDisplayItem::~FilterDisplayItem() {
23 }
24
25 void FilterDisplayItem::SetNew(const FilterOperations& filters,
26 const gfx::RectF& bounds) {
27 filters_ = filters;
28 bounds_ = bounds;
29
30 size_t memory_usage =
31 sizeof(skia::RefPtr<SkImageFilter>) + sizeof(gfx::RectF);
32 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
33 memory_usage);
34 }
35
36 void FilterDisplayItem::Raster(SkCanvas* canvas,
37 SkDrawPictureCallback* callback) const {
38 canvas->save();
39 canvas->translate(bounds_.x(), bounds_.y());
40
41 skia::RefPtr<SkImageFilter> image_filter =
42 RenderSurfaceFilters::BuildImageFilter(
43 filters_, gfx::SizeF(bounds_.width(), bounds_.height()));
44 SkRect boundaries;
45 image_filter->computeFastBounds(
46 SkRect::MakeWH(bounds_.width(), bounds_.height()), &boundaries);
47
48 SkPaint paint;
49 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
50 paint.setImageFilter(image_filter.get());
51 canvas->saveLayer(&boundaries, &paint);
52
53 canvas->translate(-bounds_.x(), -bounds_.y());
54 }
55
56 void FilterDisplayItem::AsValueInto(
57 base::trace_event::TracedValue* array) const {
58 array->AppendString(base::StringPrintf("FilterDisplayItem bounds: [%s]",
59 bounds_.ToString().c_str()));
60 }
61
62 EndFilterDisplayItem::EndFilterDisplayItem() {
63 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
64 0 /* memory_usage */);
65 }
66
67 EndFilterDisplayItem::~EndFilterDisplayItem() {
68 }
69
70 void EndFilterDisplayItem::Raster(SkCanvas* canvas,
71 SkDrawPictureCallback* callback) const {
72 canvas->restore();
73 canvas->restore();
74 }
75
76 void EndFilterDisplayItem::AsValueInto(
77 base::trace_event::TracedValue* array) const {
78 array->AppendString("EndFilterDisplayItem");
79 }
80
81 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/filter_display_item.h ('k') | cc/resources/float_clip_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698