OLD | NEW |
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 "services/gfx/compositor/graph/snapshot.h" | 5 #include "services/gfx/compositor/graph/snapshot.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/services/gfx/composition/cpp/formatting.h" | 8 #include "mojo/services/gfx/composition/cpp/formatting.h" |
9 #include "mojo/skia/type_converters.h" | 9 #include "mojo/skia/type_converters.h" |
10 #include "services/gfx/compositor/graph/scene_content.h" | 10 #include "services/gfx/compositor/graph/scene_content.h" |
11 #include "services/gfx/compositor/render/render_frame.h" | |
12 #include "third_party/skia/include/core/SkPictureRecorder.h" | 11 #include "third_party/skia/include/core/SkPictureRecorder.h" |
13 #include "third_party/skia/include/core/SkRect.h" | 12 #include "third_party/skia/include/core/SkRect.h" |
14 #include "third_party/skia/include/utils/SkMatrix44.h" | 13 #include "third_party/skia/include/utils/SkMatrix44.h" |
15 | 14 |
16 namespace compositor { | 15 namespace compositor { |
17 | 16 |
18 Snapshot::Snapshot() {} | 17 Snapshot::Snapshot() {} |
19 | 18 |
20 Snapshot::~Snapshot() {} | 19 Snapshot::~Snapshot() {} |
21 | 20 |
22 bool Snapshot::HasDependency( | 21 bool Snapshot::HasDependency( |
23 const mojo::gfx::composition::SceneToken& scene_token) const { | 22 const mojo::gfx::composition::SceneToken& scene_token) const { |
24 return dependencies_.find(scene_token.value) != dependencies_.end(); | 23 return dependencies_.find(scene_token.value) != dependencies_.end(); |
25 } | 24 } |
26 | 25 |
27 scoped_refptr<RenderFrame> Snapshot::CreateFrame( | 26 scoped_refptr<RenderFrame> Snapshot::Paint( |
28 const mojo::Rect& viewport, | 27 const RenderFrame::Metadata& metadata, |
29 const mojo::gfx::composition::FrameInfo& frame_info) const { | 28 const mojo::Rect& viewport) const { |
30 DCHECK(!is_blocked()); | 29 DCHECK(!is_blocked()); |
31 DCHECK(root_scene_content_); | 30 DCHECK(root_scene_content_); |
32 | 31 |
33 SkIRect sk_viewport = viewport.To<SkIRect>(); | 32 SkIRect sk_viewport = viewport.To<SkIRect>(); |
34 | 33 |
35 SkPictureRecorder recorder; | 34 SkPictureRecorder recorder; |
36 recorder.beginRecording(SkRect::Make(sk_viewport)); | 35 recorder.beginRecording(SkRect::Make(sk_viewport)); |
37 root_scene_content_->RecordPicture(this, recorder.getRecordingCanvas()); | 36 root_scene_content_->Paint(this, recorder.getRecordingCanvas()); |
38 return new RenderFrame(sk_viewport, frame_info, | 37 return new RenderFrame(metadata, sk_viewport, |
39 skia::AdoptRef(recorder.endRecordingAsPicture())); | 38 skia::AdoptRef(recorder.endRecordingAsPicture())); |
40 } | 39 } |
41 | 40 |
42 void Snapshot::HitTest(const mojo::PointF& point, | 41 void Snapshot::HitTest(const mojo::PointF& point, |
43 mojo::gfx::composition::HitTestResult* result) const { | 42 mojo::gfx::composition::HitTestResult* result) const { |
44 DCHECK(result); | 43 DCHECK(result); |
45 DCHECK(!is_blocked()); | 44 DCHECK(!is_blocked()); |
46 DCHECK(root_scene_content_); | 45 DCHECK(root_scene_content_); |
47 | 46 |
48 root_scene_content_->HitTest(this, point.To<SkPoint>(), SkMatrix44::I(), | 47 root_scene_content_->HitTest(this, point.To<SkPoint>(), SkMatrix44::I(), |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (!snapshot_->is_blocked()) { | 164 if (!snapshot_->is_blocked()) { |
166 snapshot_->root_scene_content_ = content; | 165 snapshot_->root_scene_content_ = content; |
167 } else { | 166 } else { |
168 snapshot_->resolved_scene_contents_.clear(); | 167 snapshot_->resolved_scene_contents_.clear(); |
169 snapshot_->node_dispositions_.clear(); | 168 snapshot_->node_dispositions_.clear(); |
170 } | 169 } |
171 return std::move(snapshot_); | 170 return std::move(snapshot_); |
172 } | 171 } |
173 | 172 |
174 } // namespace compositor | 173 } // namespace compositor |
OLD | NEW |