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