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

Side by Side Diff: ui/compositor/clip_recorder.cc

Issue 2230513005: Move visual rect unioning between paired items to cc::DisplayItemList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review feedback. Created 4 years, 4 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 | « ui/compositor/clip_recorder.h ('k') | ui/compositor/compositing_recorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/clip_recorder.h" 5 #include "ui/compositor/clip_recorder.h"
6 6
7 #include "cc/playback/clip_display_item.h" 7 #include "cc/playback/clip_display_item.h"
8 #include "cc/playback/clip_path_display_item.h" 8 #include "cc/playback/clip_path_display_item.h"
9 #include "cc/playback/display_item_list.h" 9 #include "cc/playback/display_item_list.h"
10 #include "ui/compositor/paint_context.h" 10 #include "ui/compositor/paint_context.h"
11 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/geometry/rect.h" 12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/rect_conversions.h" 13 #include "ui/gfx/geometry/rect_conversions.h"
14 #include "ui/gfx/path.h" 14 #include "ui/gfx/path.h"
15 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
16 16
17 namespace ui { 17 namespace ui {
18 18
19 ClipRecorder::ClipRecorder(const PaintContext& context) 19 ClipRecorder::ClipRecorder(const PaintContext& context)
20 : context_(context), num_closers_(0) {} 20 : context_(context), num_closers_(0) {
21 }
21 22
22 ClipRecorder::~ClipRecorder() { 23 ClipRecorder::~ClipRecorder() {
23 for (int i = num_closers_ - 1; i >= 0; --i) { 24 for (int i = num_closers_ - 1; i >= 0; --i) {
24 const gfx::Rect& bounds_in_layer = bounds_in_layer_[i];
25 switch (closers_[i]) { 25 switch (closers_[i]) {
26 case CLIP_RECT: 26 case CLIP_RECT:
27 context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>( 27 context_.list_->CreateAndAppendPairedEndItem<cc::EndClipDisplayItem>();
28 bounds_in_layer);
29 break; 28 break;
30 case CLIP_PATH: 29 case CLIP_PATH:
31 context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>( 30 context_.list_
32 bounds_in_layer); 31 ->CreateAndAppendPairedEndItem<cc::EndClipPathDisplayItem>();
33 break; 32 break;
34 } 33 }
35 } 34 }
36 } 35 }
37 36
38 void ClipRecorder::RecordCloser(const gfx::Rect& bounds_in_layer, 37 void ClipRecorder::RecordCloser(Closer closer) {
39 Closer closer) {
40 DCHECK_LT(num_closers_, kMaxOpCount); 38 DCHECK_LT(num_closers_, kMaxOpCount);
41 closers_[num_closers_] = closer; 39 closers_[num_closers_++] = closer;
42 bounds_in_layer_[num_closers_++] = bounds_in_layer;
43 }
44
45 static gfx::Rect PathToEnclosingRect(const gfx::Path& path) {
46 return gfx::ToEnclosingRect(gfx::SkRectToRectF(path.getBounds()));
47 } 40 }
48 41
49 void ClipRecorder::ClipRect(const gfx::Rect& clip_rect) { 42 void ClipRecorder::ClipRect(const gfx::Rect& clip_rect) {
50 bool antialias = false; 43 bool antialias = false;
51 gfx::Rect clip_in_layer_space = context_.ToLayerSpaceRect(clip_rect); 44 context_.list_->CreateAndAppendPairedBeginItem<cc::ClipDisplayItem>(
52 context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>( 45 clip_rect, std::vector<SkRRect>(), antialias);
53 clip_in_layer_space, clip_rect, std::vector<SkRRect>(), antialias); 46 RecordCloser(CLIP_RECT);
54 RecordCloser(clip_in_layer_space, CLIP_RECT);
55 } 47 }
56 48
57 void ClipRecorder::ClipPath(const gfx::Path& clip_path) { 49 void ClipRecorder::ClipPath(const gfx::Path& clip_path) {
58 bool antialias = false; 50 bool antialias = false;
59 gfx::Rect clip_in_layer_space = 51 context_.list_->CreateAndAppendPairedBeginItem<cc::ClipPathDisplayItem>(
60 context_.ToLayerSpaceRect(PathToEnclosingRect(clip_path)); 52 clip_path, SkRegion::kIntersect_Op, antialias);
61 context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>( 53 RecordCloser(CLIP_PATH);
62 clip_in_layer_space, clip_path, SkRegion::kIntersect_Op, antialias);
63 RecordCloser(clip_in_layer_space, CLIP_PATH);
64 } 54 }
65 55
66 void ClipRecorder::ClipPathWithAntiAliasing(const gfx::Path& clip_path) { 56 void ClipRecorder::ClipPathWithAntiAliasing(const gfx::Path& clip_path) {
67 bool antialias = true; 57 bool antialias = true;
68 gfx::Rect clip_in_layer_space = 58 context_.list_->CreateAndAppendPairedBeginItem<cc::ClipPathDisplayItem>(
69 context_.ToLayerSpaceRect(PathToEnclosingRect(clip_path)); 59 clip_path, SkRegion::kIntersect_Op, antialias);
70 context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>( 60 RecordCloser(CLIP_PATH);
71 clip_in_layer_space, clip_path, SkRegion::kIntersect_Op, antialias);
72 RecordCloser(clip_in_layer_space, CLIP_PATH);
73 } 61 }
74 62
75 } // namespace ui 63 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/clip_recorder.h ('k') | ui/compositor/compositing_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698