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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 private: | 179 private: |
180 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); | 180 DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter); |
181 }; | 181 }; |
182 | 182 |
183 } // namespace | 183 } // namespace |
184 | 184 |
185 //////////////////////////////////////////////////////////////////////////////// | 185 //////////////////////////////////////////////////////////////////////////////// |
186 // Surface, public: | 186 // Surface, public: |
187 | 187 |
188 // TODO(fsamuel): exo should not use context_factory_private. Instead, we should | |
189 // request a CompositorFrameSink from the aura::Window. Setting up the | |
190 // BeginFrame hierarchy should be an internal implementation detail of aura or | |
191 // mus in aura-mus. | |
192 Surface::Surface() : window_(new aura::Window(new CustomWindowDelegate(this))) { | 188 Surface::Surface() : window_(new aura::Window(new CustomWindowDelegate(this))) { |
193 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); | 189 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); |
194 window_->SetName("ExoSurface"); | 190 window_->SetName("ExoSurface"); |
195 window_->SetProperty(kSurfaceKey, this); | 191 window_->SetProperty(kSurfaceKey, this); |
196 window_->Init(ui::LAYER_SOLID_COLOR); | 192 window_->Init(ui::LAYER_SOLID_COLOR); |
197 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); | 193 window_->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter)); |
198 window_->set_owned_by_parent(false); | 194 window_->set_owned_by_parent(false); |
199 window_->AddObserver(this); | 195 window_->AddObserver(this); |
200 aura::Env::GetInstance()->context_factory()->AddObserver(this); | 196 aura::Env::GetInstance()->context_factory()->AddObserver(this); |
201 compositor_frame_sink_holder_ = base::MakeUnique<CompositorFrameSinkHolder>( | 197 compositor_frame_sink_holder_ = base::MakeUnique<CompositorFrameSinkHolder>( |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 DLOG_IF(WARNING, !gfx::IsExpressibleAsInt(state_.crop.width()) || | 797 DLOG_IF(WARNING, !gfx::IsExpressibleAsInt(state_.crop.width()) || |
802 !gfx::IsExpressibleAsInt(state_.crop.height())) | 798 !gfx::IsExpressibleAsInt(state_.crop.height())) |
803 << "Crop rectangle size (" << state_.crop.size().ToString() | 799 << "Crop rectangle size (" << state_.crop.size().ToString() |
804 << ") most be expressible using integers when viewport is not set"; | 800 << ") most be expressible using integers when viewport is not set"; |
805 layer_size = gfx::ToCeiledSize(state_.crop.size()); | 801 layer_size = gfx::ToCeiledSize(state_.crop.size()); |
806 } else { | 802 } else { |
807 layer_size = gfx::ToCeiledSize(scaled_buffer_size); | 803 layer_size = gfx::ToCeiledSize(scaled_buffer_size); |
808 } | 804 } |
809 | 805 |
810 content_size_ = layer_size; | 806 content_size_ = layer_size; |
| 807 // We need update window_'s bounds with content size, because the |
| 808 // CompositorFrameSink may not update the window's size base the size of |
| 809 // the lastest submitted CompositorFrame. |
| 810 window_->SetBounds(gfx::Rect(window_->bounds().origin(), content_size_)); |
811 // TODO(jbauman): Figure out how this interacts with the pixel size of | 811 // TODO(jbauman): Figure out how this interacts with the pixel size of |
812 // CopyOutputRequests on the layer. | 812 // CopyOutputRequests on the layer. |
813 gfx::Size contents_surface_size = layer_size; | 813 gfx::Size contents_surface_size = layer_size; |
814 | 814 |
815 gfx::PointF uv_top_left(0.f, 0.f); | 815 gfx::PointF uv_top_left(0.f, 0.f); |
816 gfx::PointF uv_bottom_right(1.f, 1.f); | 816 gfx::PointF uv_bottom_right(1.f, 1.f); |
817 if (!state_.crop.IsEmpty()) { | 817 if (!state_.crop.IsEmpty()) { |
818 uv_top_left = state_.crop.origin(); | 818 uv_top_left = state_.crop.origin(); |
819 | 819 |
820 uv_top_left.Scale(1.f / scaled_buffer_size.width(), | 820 uv_top_left.Scale(1.f / scaled_buffer_size.width(), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 886 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
887 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 887 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); |
888 } | 888 } |
889 | 889 |
890 frame.render_pass_list.push_back(std::move(render_pass)); | 890 frame.render_pass_list.push_back(std::move(render_pass)); |
891 compositor_frame_sink_holder_->GetCompositorFrameSink() | 891 compositor_frame_sink_holder_->GetCompositorFrameSink() |
892 ->SubmitCompositorFrame(std::move(frame)); | 892 ->SubmitCompositorFrame(std::move(frame)); |
893 } | 893 } |
894 | 894 |
895 } // namespace exo | 895 } // namespace exo |
OLD | NEW |