| 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" | 
| 11 #include "base/macros.h" | 11 #include "base/macros.h" | 
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" | 
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" | 
| 14 #include "base/trace_event/trace_event_argument.h" | 14 #include "base/trace_event/trace_event_argument.h" | 
| 15 #include "cc/output/compositor_frame_sink.h" | 15 #include "cc/output/compositor_frame_sink.h" | 
| 16 #include "cc/quads/render_pass.h" | 16 #include "cc/quads/render_pass.h" | 
| 17 #include "cc/quads/shared_quad_state.h" | 17 #include "cc/quads/shared_quad_state.h" | 
| 18 #include "cc/quads/solid_color_draw_quad.h" | 18 #include "cc/quads/solid_color_draw_quad.h" | 
| 19 #include "cc/quads/texture_draw_quad.h" | 19 #include "cc/quads/texture_draw_quad.h" | 
| 20 #include "cc/resources/single_release_callback.h" | 20 #include "cc/resources/single_release_callback.h" | 
| 21 #include "cc/surfaces/sequence_surface_reference_factory.h" | 21 #include "cc/surfaces/sequence_surface_reference_factory.h" | 
| 22 #include "cc/surfaces/surface.h" | 22 #include "cc/surfaces/surface.h" | 
| 23 #include "cc/surfaces/surface_manager.h" | 23 #include "cc/surfaces/surface_manager.h" | 
| 24 #include "components/exo/buffer.h" | 24 #include "components/exo/buffer.h" | 
| 25 #include "components/exo/pointer.h" | 25 #include "components/exo/pointer.h" | 
| 26 #include "components/exo/surface_delegate.h" | 26 #include "components/exo/surface_delegate.h" | 
| 27 #include "components/exo/surface_observer.h" | 27 #include "components/exo/surface_observer.h" | 
| 28 #include "third_party/khronos/GLES2/gl2.h" | 28 #include "third_party/khronos/GLES2/gl2.h" | 
|  | 29 #include "ui/aura/client/aura_constants.h" | 
| 29 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" | 
| 30 #include "ui/aura/window_delegate.h" | 31 #include "ui/aura/window_delegate.h" | 
| 31 #include "ui/aura/window_targeter.h" | 32 #include "ui/aura/window_targeter.h" | 
| 32 #include "ui/base/class_property.h" | 33 #include "ui/base/class_property.h" | 
| 33 #include "ui/base/cursor/cursor.h" | 34 #include "ui/base/cursor/cursor.h" | 
| 34 #include "ui/base/hit_test.h" | 35 #include "ui/base/hit_test.h" | 
| 35 #include "ui/compositor/layer.h" | 36 #include "ui/compositor/layer.h" | 
| 36 #include "ui/events/event.h" | 37 #include "ui/events/event.h" | 
| 37 #include "ui/gfx/buffer_format_util.h" | 38 #include "ui/gfx/buffer_format_util.h" | 
| 38 #include "ui/gfx/geometry/safe_integer_conversions.h" | 39 #include "ui/gfx/geometry/safe_integer_conversions.h" | 
| 39 #include "ui/gfx/geometry/size_conversions.h" | 40 #include "ui/gfx/geometry/size_conversions.h" | 
| 40 #include "ui/gfx/gpu_memory_buffer.h" | 41 #include "ui/gfx/gpu_memory_buffer.h" | 
| 41 #include "ui/gfx/path.h" | 42 #include "ui/gfx/path.h" | 
| 42 #include "ui/gfx/skia_util.h" | 43 #include "ui/gfx/skia_util.h" | 
| 43 #include "ui/gfx/transform_util.h" | 44 #include "ui/gfx/transform_util.h" | 
| 44 #include "ui/views/widget/widget.h" | 45 #include "ui/views/widget/widget.h" | 
| 45 | 46 | 
| 46 DECLARE_UI_CLASS_PROPERTY_TYPE(exo::Surface*); | 47 DECLARE_UI_CLASS_PROPERTY_TYPE(exo::Surface*); | 
| 47 | 48 | 
| 48 namespace exo { | 49 namespace exo { | 
| 49 namespace { | 50 namespace { | 
| 50 | 51 | 
| 51 // A property key containing the surface that is associated with | 52 // A property key containing the surface that is associated with | 
| 52 // window. If unset, no surface is associated with window. | 53 // window. If unset, no surface is associated with window. | 
| 53 DEFINE_UI_CLASS_PROPERTY_KEY(Surface*, kSurfaceKey, nullptr); | 54 DEFINE_UI_CLASS_PROPERTY_KEY(Surface*, kSurfaceKey, nullptr); | 
| 54 | 55 | 
|  | 56 // A property key to store whether the surface should only consume | 
|  | 57 // stylus input events. | 
|  | 58 DEFINE_UI_CLASS_PROPERTY_KEY(bool, kStylusOnlyKey, false); | 
|  | 59 | 
| 55 // Helper function that returns an iterator to the first entry in |list| | 60 // Helper function that returns an iterator to the first entry in |list| | 
| 56 // with |key|. | 61 // with |key|. | 
| 57 template <typename T, typename U> | 62 template <typename T, typename U> | 
| 58 typename T::iterator FindListEntry(T& list, U key) { | 63 typename T::iterator FindListEntry(T& list, U key) { | 
| 59   return std::find_if(list.begin(), list.end(), | 64   return std::find_if(list.begin(), list.end(), | 
| 60                       [key](const typename T::value_type& entry) { | 65                       [key](const typename T::value_type& entry) { | 
| 61                         return entry.first == key; | 66                         return entry.first == key; | 
| 62                       }); | 67                       }); | 
| 63 } | 68 } | 
| 64 | 69 | 
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 627     active_frame_callbacks_.pop_front(); | 632     active_frame_callbacks_.pop_front(); | 
| 628   } | 633   } | 
| 629   return true; | 634   return true; | 
| 630 } | 635 } | 
| 631 | 636 | 
| 632 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { | 637 void Surface::CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces() { | 
| 633   if (HasLayerHierarchyChanged()) | 638   if (HasLayerHierarchyChanged()) | 
| 634     SetSurfaceHierarchyNeedsCommitToNewSurfaces(); | 639     SetSurfaceHierarchyNeedsCommitToNewSurfaces(); | 
| 635 } | 640 } | 
| 636 | 641 | 
|  | 642 bool Surface::IsStylusOnly() { | 
|  | 643   return window_->GetProperty(kStylusOnlyKey); | 
|  | 644 } | 
|  | 645 | 
|  | 646 void Surface::SetStylusOnly() { | 
|  | 647   window_->SetProperty(kStylusOnlyKey, true); | 
|  | 648 } | 
|  | 649 | 
| 637 //////////////////////////////////////////////////////////////////////////////// | 650 //////////////////////////////////////////////////////////////////////////////// | 
| 638 // ui::ContextFactoryObserver overrides: | 651 // ui::ContextFactoryObserver overrides: | 
| 639 | 652 | 
| 640 void Surface::OnLostResources() { | 653 void Surface::OnLostResources() { | 
| 641   if (!window_->GetSurfaceId().is_valid()) | 654   if (!window_->GetSurfaceId().is_valid()) | 
| 642     return; | 655     return; | 
| 643   UpdateResource(false); | 656   UpdateResource(false); | 
| 644   UpdateSurface(true); | 657   UpdateSurface(true); | 
| 645 } | 658 } | 
| 646 | 659 | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 855         render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 868         render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 
| 856     solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 869     solid_quad->SetNew(quad_state, quad_rect, quad_rect, SK_ColorBLACK, false); | 
| 857   } | 870   } | 
| 858 | 871 | 
| 859   frame.render_pass_list.push_back(std::move(render_pass)); | 872   frame.render_pass_list.push_back(std::move(render_pass)); | 
| 860   compositor_frame_sink_holder_->GetCompositorFrameSink() | 873   compositor_frame_sink_holder_->GetCompositorFrameSink() | 
| 861       ->SubmitCompositorFrame(std::move(frame)); | 874       ->SubmitCompositorFrame(std::move(frame)); | 
| 862 } | 875 } | 
| 863 | 876 | 
| 864 }  // namespace exo | 877 }  // namespace exo | 
| OLD | NEW | 
|---|