Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: components/exo/surface.cc

Issue 2843723003: Make exo::Surface set device_scale_factor. (Closed)
Patch Set: Get device_scale_factor from aura::Window. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« components/exo/surface.h ('K') | « components/exo/surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return HTNOWHERE; 101 return HTNOWHERE;
102 } 102 }
103 bool ShouldDescendIntoChildForEventHandling( 103 bool ShouldDescendIntoChildForEventHandling(
104 aura::Window* child, 104 aura::Window* child,
105 const gfx::Point& location) override { 105 const gfx::Point& location) override {
106 return true; 106 return true;
107 } 107 }
108 bool CanFocus() override { return true; } 108 bool CanFocus() override { return true; }
109 void OnCaptureLost() override {} 109 void OnCaptureLost() override {}
110 void OnPaint(const ui::PaintContext& context) override {} 110 void OnPaint(const ui::PaintContext& context) override {}
111 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} 111 void OnDeviceScaleFactorChanged(float device_scale_factor) override {
112 surface_->SetDeviceScaleFactor(device_scale_factor);
113 }
112 void OnWindowDestroying(aura::Window* window) override {} 114 void OnWindowDestroying(aura::Window* window) override {}
113 void OnWindowDestroyed(aura::Window* window) override { delete this; } 115 void OnWindowDestroyed(aura::Window* window) override { delete this; }
114 void OnWindowTargetVisibilityChanged(bool visible) override {} 116 void OnWindowTargetVisibilityChanged(bool visible) override {}
115 bool HasHitTestMask() const override { return surface_->HasHitTestMask(); } 117 bool HasHitTestMask() const override { return surface_->HasHitTestMask(); }
116 void GetHitTestMask(gfx::Path* mask) const override { 118 void GetHitTestMask(gfx::Path* mask) const override {
117 surface_->GetHitTestMask(mask); 119 surface_->GetHitTestMask(mask);
118 } 120 }
119 void OnKeyEvent(ui::KeyEvent* event) override { 121 void OnKeyEvent(ui::KeyEvent* event) override {
120 // Propagates the key event upto the top-level views Widget so that we can 122 // Propagates the key event upto the top-level views Widget so that we can
121 // trigger proper events in the views/ash level there. Event handling for 123 // trigger proper events in the views/ash level there. Event handling for
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 400
399 pending_state_.blend_mode = blend_mode; 401 pending_state_.blend_mode = blend_mode;
400 } 402 }
401 403
402 void Surface::SetAlpha(float alpha) { 404 void Surface::SetAlpha(float alpha) {
403 TRACE_EVENT1("exo", "Surface::SetAlpha", "alpha", alpha); 405 TRACE_EVENT1("exo", "Surface::SetAlpha", "alpha", alpha);
404 406
405 pending_state_.alpha = alpha; 407 pending_state_.alpha = alpha;
406 } 408 }
407 409
410 void Surface::SetDeviceScaleFactor(float device_scale_factor) {
411 device_scale_factor_ = device_scale_factor;
412 }
413
408 void Surface::Commit() { 414 void Surface::Commit() {
409 TRACE_EVENT0("exo", "Surface::Commit"); 415 TRACE_EVENT0("exo", "Surface::Commit");
410 416
411 needs_commit_surface_hierarchy_ = true; 417 needs_commit_surface_hierarchy_ = true;
412 418
413 if (state_ != pending_state_) 419 if (state_ != pending_state_)
414 has_pending_layer_changes_ = true; 420 has_pending_layer_changes_ = true;
415 421
416 if (has_pending_contents_) { 422 if (has_pending_contents_) {
417 if (pending_buffer_.buffer()) { 423 if (pending_buffer_.buffer()) {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 cc::CompositorFrame frame; 846 cc::CompositorFrame frame;
841 // If we commit while we don't have an active BeginFrame, we acknowledge a 847 // If we commit while we don't have an active BeginFrame, we acknowledge a
842 // manual one. 848 // manual one.
843 if (current_begin_frame_ack_.sequence_number == 849 if (current_begin_frame_ack_.sequence_number ==
844 cc::BeginFrameArgs::kInvalidFrameNumber) { 850 cc::BeginFrameArgs::kInvalidFrameNumber) {
845 current_begin_frame_ack_ = cc::BeginFrameAck::CreateManualAckWithDamage(); 851 current_begin_frame_ack_ = cc::BeginFrameAck::CreateManualAckWithDamage();
846 } else { 852 } else {
847 current_begin_frame_ack_.has_damage = true; 853 current_begin_frame_ack_.has_damage = true;
848 } 854 }
849 frame.metadata.begin_frame_ack = current_begin_frame_ack_; 855 frame.metadata.begin_frame_ack = current_begin_frame_ack_;
856 frame.metadata.device_scale_factor = device_scale_factor_;
850 857
851 if (current_resource_.id) { 858 if (current_resource_.id) {
852 // Texture quad is only needed if buffer is not fully transparent. 859 // Texture quad is only needed if buffer is not fully transparent.
853 if (state_.alpha) { 860 if (state_.alpha) {
854 cc::TextureDrawQuad* texture_quad = 861 cc::TextureDrawQuad* texture_quad =
855 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); 862 render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
856 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0}; 863 float vertex_opacity[4] = {1.0, 1.0, 1.0, 1.0};
857 gfx::Rect opaque_rect; 864 gfx::Rect opaque_rect;
858 if (!current_resource_has_alpha_ || 865 if (!current_resource_has_alpha_ ||
859 state_.blend_mode == SkBlendMode::kSrc || 866 state_.blend_mode == SkBlendMode::kSrc ||
(...skipping 16 matching lines...) Expand all
876 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); 883 render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
877 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); 884 solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false);
878 } 885 }
879 886
880 frame.render_pass_list.push_back(std::move(render_pass)); 887 frame.render_pass_list.push_back(std::move(render_pass));
881 compositor_frame_sink_holder_->GetCompositorFrameSink() 888 compositor_frame_sink_holder_->GetCompositorFrameSink()
882 ->SubmitCompositorFrame(local_surface_id_, std::move(frame)); 889 ->SubmitCompositorFrame(local_surface_id_, std::move(frame));
883 } 890 }
884 891
885 } // namespace exo 892 } // namespace exo
OLDNEW
« components/exo/surface.h ('K') | « components/exo/surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698