blob: 499ad190a5880c1c128fd77a657e9c949f5356bd [file] [log] [blame]
// 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.
#include <memory>
#include <vector>
#include "ash/fast_ink/fast_ink_host.h"
#include "base/containers/flat_map.h"
#include "ui/gfx/canvas.h"
#include "ui/views/view.h"
namespace aura {
class Window;
namespace gfx {
class GpuMemoryBuffer;
} // namespace gfx
namespace views {
class Widget;
namespace fast_ink {
// FastInkView is a view supporting low-latency rendering by using FastInkHost.
// THe view's widget must have the same bounds as a root window (covers the
// entire display). FastInkHost for more details.
class FastInkView : public views::View {
// 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.
FastInkView(aura::Window* container,
const FastInkHost::PresentationCallback& presentation_callback);
~FastInkView() override;
FastInkView(const FastInkView&) = delete;
FastInkView& operator=(const FastInkView&) = delete;
// Update content and damage rectangles for surface. See
// FastInkHost::UpdateSurface for more detials.
void UpdateSurface(const gfx::Rect& content_rect,
const gfx::Rect& damage_rect,
bool auto_refresh);
// Helper class that provides flicker free painting to a GPU memory buffer.
class ScopedPaint {
ScopedPaint(FastInkView* view, const gfx::Rect& damage_rect_in_window);
gfx::Canvas& canvas() { return canvas_; }
gfx::GpuMemoryBuffer* const gpu_memory_buffer_;
// Damage rect in the buffer coordinates.
const gfx::Rect damage_rect_;
gfx::Canvas canvas_;
FastInkHost* host() { return host_.get(); }
std::unique_ptr<views::Widget> widget_;
std::unique_ptr<FastInkHost> host_;
} // namespace fast_ink