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 "components/exo/surface.h" | 5 #include "components/exo/surface.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 private: | 161 private: |
162 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); | 162 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); |
163 }; | 163 }; |
164 | 164 |
165 } // namespace | 165 } // namespace |
166 | 166 |
167 //////////////////////////////////////////////////////////////////////////////// | 167 //////////////////////////////////////////////////////////////////////////////// |
168 // Surface, public: | 168 // Surface, public: |
169 | 169 |
170 // TODO(fsamuel): exo should not use context_factory_private. Instead, we should | |
171 // request a CompositorFrameSink from the aura::Window. Setting up the | |
172 // BeginFrame hierarchy should be an internal implementation detail of aura or | |
173 // mus in aura-mus. | |
174 Surface::Surface() : window_(new aura::Window(new CustomWindowDelegate(this))) { | 170 Surface::Surface() : window_(new aura::Window(new CustomWindowDelegate(this))) { |
175 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); | 171 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); |
176 window_->SetName("ExoSurface"); | 172 window_->SetName("ExoSurface"); |
177 window_->SetProperty(kSurfaceKey, this); | 173 window_->SetProperty(kSurfaceKey, this); |
178 window_->Init(ui::LAYER_SOLID_COLOR); | 174 window_->Init(ui::LAYER_SOLID_COLOR); |
179 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); | 175 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); |
180 window_->set_owned_by_parent(false); | 176 window_->set_owned_by_parent(false); |
181 window_->AddObserver(this); | 177 window_->AddObserver(this); |
182 aura::Env::GetInstance()->context_factory()->AddObserver(this); | 178 aura::Env::GetInstance()->context_factory()->AddObserver(this); |
183 compositor_frame_sink_holder_ = base::MakeUnique<CompositorFrameSinkHolder>( | 179 compositor_frame_sink_holder_ = base::MakeUnique<CompositorFrameSinkHolder>( |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 DLOG_IF(WARNING, !gfx::IsExpressibleAsInt(state_.crop.width()) || | 779 DLOG_IF(WARNING, !gfx::IsExpressibleAsInt(state_.crop.width()) || |
784 !gfx::IsExpressibleAsInt(state_.crop.height())) | 780 !gfx::IsExpressibleAsInt(state_.crop.height())) |
785 << "Crop rectangle size (" << state_.crop.size().ToString() | 781 << "Crop rectangle size (" << state_.crop.size().ToString() |
786 << ") most be expressible using integers when viewport is not set"; | 782 << ") most be expressible using integers when viewport is not set"; |
787 layer_size = gfx::ToCeiledSize(state_.crop.size()); | 783 layer_size = gfx::ToCeiledSize(state_.crop.size()); |
788 } else { | 784 } else { |
789 layer_size = gfx::ToCeiledSize(scaled_buffer_size); | 785 layer_size = gfx::ToCeiledSize(scaled_buffer_size); |
790 } | 786 } |
791 | 787 |
792 content_size_ = layer_size; | 788 content_size_ = layer_size; |
| 789 window_->SetBounds(gfx::Rect(window_->bounds().origin(), content_size_)); |
793 // TODO(jbauman): Figure out how this interacts with the pixel size of | 790 // TODO(jbauman): Figure out how this interacts with the pixel size of |
794 // CopyOutputRequests on the layer. | 791 // CopyOutputRequests on the layer. |
795 gfx::Size contents_surface_size = layer_size; | 792 gfx::Size contents_surface_size = layer_size; |
796 | 793 |
797 gfx::PointF uv_top_left(0.f, 0.f); | 794 gfx::PointF uv_top_left(0.f, 0.f); |
798 gfx::PointF uv_bottom_right(1.f, 1.f); | 795 gfx::PointF uv_bottom_right(1.f, 1.f); |
799 if (!state_.crop.IsEmpty()) { | 796 if (!state_.crop.IsEmpty()) { |
800 uv_top_left = state_.crop.origin(); | 797 uv_top_left = state_.crop.origin(); |
801 | 798 |
802 uv_top_left.Scale(1.f / scaled_buffer_size.width(), | 799 uv_top_left.Scale(1.f / scaled_buffer_size.width(), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 865 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
869 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 866 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); |
870 } | 867 } |
871 | 868 |
872 frame.render_pass_list.push_back(std::move(render_pass)); | 869 frame.render_pass_list.push_back(std::move(render_pass)); |
873 compositor_frame_sink_holder_->GetCompositorFrameSink() | 870 compositor_frame_sink_holder_->GetCompositorFrameSink() |
874 ->SubmitCompositorFrame(std::move(frame)); | 871 ->SubmitCompositorFrame(std::move(frame)); |
875 } | 872 } |
876 | 873 |
877 } // namespace exo | 874 } // namespace exo |
OLD | NEW |