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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/managed_tile_state.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 "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"
12
13 namespace cc {
14
15 FilterDisplayItem::FilterDisplayItem(skia::RefPtr<SkImageFilter> filter,
16 gfx::RectF bounds)
17 : filter_(filter), bounds_(bounds) {
18 }
19
20 FilterDisplayItem::~FilterDisplayItem() {
21 }
22
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());
30
31 SkPaint paint;
32 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
33 paint.setImageFilter(filter_.get());
34 canvas->saveLayer(&boundaries, &paint);
35
36 canvas->translate(-bounds_.x(), -bounds_.y());
37 }
38
39 bool FilterDisplayItem::IsSuitableForGpuRasterization() const {
40 return true;
41 }
42
43 int FilterDisplayItem::ApproximateOpCount() const {
44 return 1;
45 }
46
47 size_t FilterDisplayItem::PictureMemoryUsage() const {
48 return sizeof(skia::RefPtr<SkImageFilter>) + sizeof(gfx::RectF);
49 }
50
51 EndFilterDisplayItem::EndFilterDisplayItem() {
52 }
53
54 EndFilterDisplayItem::~EndFilterDisplayItem() {
55 }
56
57 void EndFilterDisplayItem::Raster(SkCanvas* canvas,
58 SkDrawPictureCallback* callback) const {
59 canvas->restore();
60 canvas->restore();
61 }
62
63 bool EndFilterDisplayItem::IsSuitableForGpuRasterization() const {
64 return true;
65 }
66
67 int EndFilterDisplayItem::ApproximateOpCount() const {
68 return 0;
69 }
70
71 size_t EndFilterDisplayItem::PictureMemoryUsage() const {
72 return 0;
73 }
74
75 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/filter_display_item.h ('k') | cc/resources/managed_tile_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698