| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/compositor/clip_transform_recorder.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "cc/playback/clip_display_item.h" | |
| 9 #include "cc/playback/clip_path_display_item.h" | |
| 10 #include "cc/playback/display_item_list.h" | |
| 11 #include "cc/playback/transform_display_item.h" | |
| 12 #include "ui/compositor/paint_context.h" | |
| 13 #include "ui/gfx/canvas.h" | |
| 14 #include "ui/gfx/path.h" | |
| 15 | |
| 16 namespace ui { | |
| 17 | |
| 18 ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context) | |
| 19 : context_(context), num_closers_(0) { | |
| 20 } | |
| 21 | |
| 22 ClipTransformRecorder::~ClipTransformRecorder() { | |
| 23 for (size_t i = num_closers_; i > 0; --i) { | |
| 24 switch (closers_[i - 1]) { | |
| 25 case CLIP_RECT: | |
| 26 context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>(); | |
| 27 break; | |
| 28 case CLIP_PATH: | |
| 29 context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>(); | |
| 30 break; | |
| 31 case TRANSFORM: | |
| 32 context_.list_->CreateAndAppendItem<cc::EndTransformDisplayItem>(); | |
| 33 break; | |
| 34 } | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) { | |
| 39 auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>(); | |
| 40 item->SetNew(clip_rect, std::vector<SkRRect>()); | |
| 41 DCHECK_LT(num_closers_, arraysize(closers_)); | |
| 42 closers_[num_closers_++] = CLIP_RECT; | |
| 43 } | |
| 44 | |
| 45 void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) { | |
| 46 bool anti_alias = false; | |
| 47 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>(); | |
| 48 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias); | |
| 49 DCHECK_LT(num_closers_, arraysize(closers_)); | |
| 50 closers_[num_closers_++] = CLIP_PATH; | |
| 51 } | |
| 52 | |
| 53 void ClipTransformRecorder::ClipPathWithAntiAliasing( | |
| 54 const gfx::Path& clip_path) { | |
| 55 bool anti_alias = true; | |
| 56 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>(); | |
| 57 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias); | |
| 58 DCHECK_LT(num_closers_, arraysize(closers_)); | |
| 59 closers_[num_closers_++] = CLIP_PATH; | |
| 60 } | |
| 61 | |
| 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 | |
| OLD | NEW |