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 "services/gfx/compositor/renderer_state.h" |
| 6 |
| 7 #include <sstream> |
| 8 |
| 9 #include "base/logging.h" |
| 10 |
| 11 namespace compositor { |
| 12 |
| 13 RendererState::RendererState(uint32_t id, const std::string& label) |
| 14 : id_(id), label_(label), weak_factory_(this) {} |
| 15 |
| 16 RendererState::~RendererState() {} |
| 17 |
| 18 bool RendererState::SetRootScene(SceneState* scene, |
| 19 uint32_t version, |
| 20 const mojo::Rect& viewport) { |
| 21 DCHECK(scene); |
| 22 DCHECK(version); |
| 23 |
| 24 if (root_scene_ != scene || root_scene_version_ != version || |
| 25 !root_scene_viewport_.Equals(viewport)) { |
| 26 root_scene_ = scene; |
| 27 root_scene_version_ = version; |
| 28 root_scene_viewport_ = viewport; |
| 29 SetSnapshot(nullptr); |
| 30 return true; |
| 31 } |
| 32 return false; |
| 33 } |
| 34 |
| 35 bool RendererState::SetSnapshot(std::unique_ptr<Snapshot> snapshot) { |
| 36 snapshot_ = std::move(snapshot); |
| 37 if (snapshot_ && snapshot_->valid()) { |
| 38 frame_ = snapshot_->frame(); |
| 39 DCHECK(frame_); |
| 40 return true; |
| 41 } |
| 42 return false; |
| 43 } |
| 44 |
| 45 std::string RendererState::FormattedLabel() { |
| 46 if (formatted_label_cache_.empty()) { |
| 47 std::ostringstream s; |
| 48 s << "<" << id_; |
| 49 if (!label_.empty()) |
| 50 s << ":" << label_; |
| 51 s << ">"; |
| 52 formatted_label_cache_ = s.str(); |
| 53 } |
| 54 return formatted_label_cache_; |
| 55 } |
| 56 |
| 57 std::ostream& operator<<(std::ostream& os, RendererState* renderer_state) { |
| 58 if (!renderer_state) |
| 59 return os << "null"; |
| 60 return os << renderer_state->FormattedLabel(); |
| 61 } |
| 62 |
| 63 } // namespace compositor |
OLD | NEW |