1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59

gpu / command_buffer / client / client_font_manager.h [blame]

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_COMMAND_BUFFER_CLIENT_CLIENT_FONT_MANAGER_H_
#define GPU_COMMAND_BUFFER_CLIENT_CLIENT_FONT_MANAGER_H_

#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/memory/raw_ptr.h"
#include "gpu/command_buffer/client/client_discardable_manager.h"
#include "gpu/raster_export.h"
#include "third_party/skia/include/private/chromium/SkChromeRemoteGlyphCache.h"

namespace gpu {
class CommandBuffer;

namespace raster {
class RASTER_EXPORT ClientFontManager
    : public SkStrikeServer::DiscardableHandleManager {
 public:
  class RASTER_EXPORT Client {
   public:
    virtual ~Client() {}

    virtual void* MapFontBuffer(uint32_t size) = 0;
  };

  ClientFontManager(Client* client, CommandBuffer* command_buffer);
  ~ClientFontManager() override;

  // SkStrikeServer::DiscardableHandleManager implementation.
  SkDiscardableHandleId createHandle() override;
  bool lockHandle(SkDiscardableHandleId handle_id) override;
  bool isHandleDeleted(SkDiscardableHandleId handle_id) override;

  void Serialize();
  SkStrikeServer* strike_server() { return &strike_server_; }

 private:
  static constexpr SkDiscardableHandleId kInvalidSkDiscardableHandleId = -1;

  raw_ptr<Client> client_;
  raw_ptr<CommandBuffer> command_buffer_;

  SkDiscardableHandleId last_allocated_handle_id_ = 0u;
  SkStrikeServer strike_server_;
  ClientDiscardableManager client_discardable_manager_;
  base::flat_map<SkDiscardableHandleId, ClientDiscardableHandle::Id>
      discardable_handle_map_;

  SkDiscardableHandleId last_serialized_handle_id_ = 0u;
  base::flat_set<SkDiscardableHandleId> locked_handles_;
};

}  // namespace raster
}  // namespace gpu

#endif  // GPU_COMMAND_BUFFER_CLIENT_CLIENT_FONT_MANAGER_H_