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

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

Issue 1470123002: Split ClipTransformRecorder into {Clip,Transform}Recorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize transformed to false. Created 5 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 | « ui/compositor/clip_recorder.h ('k') | ui/compositor/clip_transform_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_transform_recorder.h" 5 #include "ui/compositor/clip_recorder.h"
6 6
7 #include "base/logging.h"
8 #include "cc/playback/clip_display_item.h" 7 #include "cc/playback/clip_display_item.h"
9 #include "cc/playback/clip_path_display_item.h" 8 #include "cc/playback/clip_path_display_item.h"
10 #include "cc/playback/display_item_list.h" 9 #include "cc/playback/display_item_list.h"
11 #include "cc/playback/transform_display_item.h"
12 #include "ui/compositor/paint_context.h" 10 #include "ui/compositor/paint_context.h"
13 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/path.h" 12 #include "ui/gfx/path.h"
15 13
16 namespace ui { 14 namespace ui {
17 15
18 ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context) 16 ClipRecorder::ClipRecorder(const PaintContext& context)
19 : context_(context), num_closers_(0) { 17 : context_(context), num_closers_(0) {
20 } 18 }
21 19
22 ClipTransformRecorder::~ClipTransformRecorder() { 20 ClipRecorder::~ClipRecorder() {
23 for (size_t i = num_closers_; i > 0; --i) { 21 for (size_t i = num_closers_; i > 0; --i) {
24 switch (closers_[i - 1]) { 22 switch (closers_[i - 1]) {
25 case CLIP_RECT: 23 case CLIP_RECT:
26 context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>(); 24 context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>();
27 break; 25 break;
28 case CLIP_PATH: 26 case CLIP_PATH:
29 context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>(); 27 context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>();
30 break; 28 break;
31 case TRANSFORM:
32 context_.list_->CreateAndAppendItem<cc::EndTransformDisplayItem>();
33 break;
34 } 29 }
35 } 30 }
36 } 31 }
37 32
38 void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) { 33 void ClipRecorder::ClipRect(const gfx::Rect& clip_rect) {
39 auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>(); 34 auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>();
40 item->SetNew(clip_rect, std::vector<SkRRect>()); 35 item->SetNew(clip_rect, std::vector<SkRRect>());
41 DCHECK_LT(num_closers_, arraysize(closers_)); 36 DCHECK_LT(num_closers_, arraysize(closers_));
42 closers_[num_closers_++] = CLIP_RECT; 37 closers_[num_closers_++] = CLIP_RECT;
43 } 38 }
44 39
45 void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) { 40 void ClipRecorder::ClipPath(const gfx::Path& clip_path) {
46 bool anti_alias = false; 41 bool anti_alias = false;
47 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>(); 42 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
48 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias); 43 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
49 DCHECK_LT(num_closers_, arraysize(closers_)); 44 DCHECK_LT(num_closers_, arraysize(closers_));
50 closers_[num_closers_++] = CLIP_PATH; 45 closers_[num_closers_++] = CLIP_PATH;
51 } 46 }
52 47
53 void ClipTransformRecorder::ClipPathWithAntiAliasing( 48 void ClipRecorder::ClipPathWithAntiAliasing(
54 const gfx::Path& clip_path) { 49 const gfx::Path& clip_path) {
55 bool anti_alias = true; 50 bool anti_alias = true;
56 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>(); 51 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
57 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias); 52 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
58 DCHECK_LT(num_closers_, arraysize(closers_)); 53 DCHECK_LT(num_closers_, arraysize(closers_));
59 closers_[num_closers_++] = CLIP_PATH; 54 closers_[num_closers_++] = CLIP_PATH;
60 } 55 }
61 56
62 void ClipTransformRecorder::Transform(const gfx::Transform& transform) {
63 auto* item = context_.list_->CreateAndAppendItem<cc::TransformDisplayItem>();
64 item->SetNew(transform);
65 DCHECK_LT(num_closers_, arraysize(closers_));
66 closers_[num_closers_++] = TRANSFORM;
67 }
68
69 } // namespace ui 57 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/clip_recorder.h ('k') | ui/compositor/clip_transform_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698