Commit 04424852 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Commit Bot

Extract reusable base from LaserPointerView

The new FastInkView class contains everything
required for low-latency rendering of pointer-like
objects.

Bug: 743083
Change-Id: I0d31451899078875acd906396dda945bb45f2189
Reviewed-on: https://chromium-review.googlesource.com/576389
Commit-Queue: Vladislav Kaznacheev <kaznacheev@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488020}
parent 13c0ad0b
...@@ -129,6 +129,8 @@ component("ash") { ...@@ -129,6 +129,8 @@ component("ash") {
"drag_drop/drag_drop_tracker.h", "drag_drop/drag_drop_tracker.h",
"drag_drop/drag_image_view.cc", "drag_drop/drag_image_view.cc",
"drag_drop/drag_image_view.h", "drag_drop/drag_image_view.h",
"fast_ink/fast_ink_view.cc",
"fast_ink/fast_ink_view.h",
"first_run/desktop_cleaner.cc", "first_run/desktop_cleaner.cc",
"first_run/desktop_cleaner.h", "first_run/desktop_cleaner.h",
"first_run/first_run_helper.cc", "first_run/first_run_helper.cc",
......
include_rules = [
"+cc",
"+components/viz/common/gpu",
"+gpu/command_buffer/client",
]
This diff is collapsed.
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_FAST_INK_FAST_INK_VIEW_H_
#define ASH_FAST_INK_FAST_INK_VIEW_H_
#include <memory>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "ui/views/view.h"
namespace aura {
class Window;
}
namespace cc {
struct ReturnedResource;
}
namespace gfx {
class GpuMemoryBuffer;
}
namespace views {
class Widget;
}
namespace ash {
class FastInkLayerTreeFrameSinkHolder;
struct FastInkResource;
// FastInkView is a view supporting low-latency rendering.
class FastInkView : public views::View {
public:
// Creates a FastInkView filling the bounds of |root_window|.
// If |root_window| is resized (e.g. due to a screen size change),
// a new instance of FastInkView should be created.
explicit FastInkView(aura::Window* root_window);
~FastInkView() override;
protected:
// Unions |rect| with the current damage rect.
void UpdateDamageRect(const gfx::Rect& rect);
void RequestRedraw();
// Draw the contents of the view in the provided canvas.
virtual void OnRedraw(gfx::Canvas& canvas, const gfx::Vector2d& offset) = 0;
private:
friend class FastInkLayerTreeFrameSinkHolder;
// Call this to indicate that the previous frame has been processed.
void DidReceiveCompositorFrameAck();
// Call this to return resources so they can be reused or freed.
void ReclaimResources(const std::vector<cc::ReturnedResource>& resources);
void UpdateBuffer();
void UpdateSurface();
void OnDidDrawSurface();
std::unique_ptr<views::Widget> widget_;
float scale_factor_ = 1.0f;
std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
gfx::Rect buffer_damage_rect_;
bool pending_update_buffer_ = false;
gfx::Rect surface_damage_rect_;
bool needs_update_surface_ = false;
bool pending_draw_surface_ = false;
std::unique_ptr<FastInkLayerTreeFrameSinkHolder> frame_sink_holder_;
int next_resource_id_ = 1;
base::flat_map<int, std::unique_ptr<FastInkResource>> resources_;
std::vector<std::unique_ptr<FastInkResource>> returned_resources_;
base::WeakPtrFactory<FastInkView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(FastInkView);
};
} // namespace ash
#endif // ASH_FAST_INK_FAST_INK_VIEW_H_
include_rules = [ include_rules = [
"+cc", "+cc",
"+components/viz/common/gpu", "+ash/fast_ink",
"+components/viz/common/quads",
"+gpu/command_buffer/client",
] ]
This diff is collapsed.
...@@ -5,41 +5,20 @@ ...@@ -5,41 +5,20 @@
#ifndef ASH_LASER_LASER_POINTER_VIEW_H_ #ifndef ASH_LASER_LASER_POINTER_VIEW_H_
#define ASH_LASER_LASER_POINTER_VIEW_H_ #define ASH_LASER_LASER_POINTER_VIEW_H_
#include <memory> #include "ash/fast_ink/fast_ink_view.h"
#include <vector>
#include "ash/laser/laser_pointer_points.h" #include "ash/laser/laser_pointer_points.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/views/view.h"
namespace aura {
class Window;
}
namespace cc {
struct ReturnedResource;
}
namespace gfx { namespace gfx {
class GpuMemoryBuffer;
class PointF; class PointF;
} }
namespace views {
class Widget;
}
namespace ash { namespace ash {
class LaserLayerTreeFrameSinkHolder;
struct LaserResource;
// LaserPointerView displays the palette tool laser pointer. It draws the laser, // LaserPointerView displays the palette tool laser pointer. It draws the laser,
// which consists of a point where the mouse cursor should be, as well as a // which consists of a point where the mouse cursor should be, as well as a
// trail of lines to help users track. // trail of lines to help users track.
class LaserPointerView : public views::View { class LaserPointerView : public FastInkView {
public: public:
LaserPointerView(base::TimeDelta life_duration, LaserPointerView(base::TimeDelta life_duration,
base::TimeDelta presentation_delay, base::TimeDelta presentation_delay,
...@@ -51,38 +30,16 @@ class LaserPointerView : public views::View { ...@@ -51,38 +30,16 @@ class LaserPointerView : public views::View {
void UpdateTime(); void UpdateTime();
void Stop(); void Stop();
// Call this to indicate that the previous frame has been processed.
void DidReceiveCompositorFrameAck();
// Call this to return resources so they can be reused or freed.
void ReclaimResources(const std::vector<cc::ReturnedResource>& resources);
private: private:
friend class LaserPointerControllerTestApi; friend class LaserPointerControllerTestApi;
gfx::Rect GetBoundingBox(); gfx::Rect GetBoundingBox();
void OnPointsUpdated();
void UpdateBuffer(); void OnRedraw(gfx::Canvas& canvas, const gfx::Vector2d& offset) override;
void OnBufferUpdated();
void UpdateSurface();
void OnDidDrawSurface();
LaserPointerPoints laser_points_; LaserPointerPoints laser_points_;
LaserPointerPoints predicted_laser_points_; LaserPointerPoints predicted_laser_points_;
std::unique_ptr<views::Widget> widget_;
float scale_factor_ = 1.0f;
const base::TimeDelta presentation_delay_; const base::TimeDelta presentation_delay_;
std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
gfx::Rect buffer_damage_rect_;
bool pending_update_buffer_ = false;
gfx::Rect surface_damage_rect_;
bool needs_update_surface_ = false;
bool pending_draw_surface_ = false;
std::unique_ptr<LaserLayerTreeFrameSinkHolder> frame_sink_holder_;
int next_resource_id_ = 1;
base::flat_map<int, std::unique_ptr<LaserResource>> resources_;
std::vector<std::unique_ptr<LaserResource>> returned_resources_;
base::WeakPtrFactory<LaserPointerView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(LaserPointerView); DISALLOW_COPY_AND_ASSIGN(LaserPointerView);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment