summaryrefslogtreecommitdiffstats
path: root/cc/resources/gpu_rasterizer.h
blob: 79a05969543b11b207964b58f52cef13cf3d82dc (plain)
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
60
61
62
63
64
65
66
67
// Copyright 2015 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 CC_RESOURCES_GPU_RASTERIZER_H_
#define CC_RESOURCES_GPU_RASTERIZER_H_

#include <vector>

#include "cc/base/cc_export.h"
#include "cc/resources/rasterizer.h"
#include "cc/resources/resource_pool.h"
#include "cc/resources/tile.h"
#include "third_party/skia/include/core/SkMultiPictureDraw.h"

namespace cc {

class ContextProvider;
class ResourceProvider;

class CC_EXPORT GpuRasterizer : public Rasterizer {
 public:
  ~GpuRasterizer() override;

  static scoped_ptr<GpuRasterizer> Create(
      ContextProvider* context_provider,
      ResourceProvider* resource_provider,
      bool use_distance_field_text,
      bool threaded_gpu_rasterization_enabled,
      int msaa_sample_count);
  PrepareTilesMode GetPrepareTilesMode() override;
  void RasterizeTiles(
      const TileVector& tiles,
      ResourcePool* resource_pool,
      ResourceFormat resource_format,
      const UpdateTileDrawInfoCallback& update_tile_draw_info) override;

 private:
  GpuRasterizer(ContextProvider* context_provider,
                ResourceProvider* resource_provider,
                bool use_distance_filed_text,
                bool threaded_gpu_rasterization_enabled,
                int msaa_sample_count);

  using ScopedResourceWriteLocks =
      ScopedPtrVector<ResourceProvider::ScopedWriteLockGr>;

  void PerformSolidColorAnalysis(const Tile* tile,
                                 RasterSource::SolidColorAnalysis* analysis);
  void AddToMultiPictureDraw(const Tile* tile,
                             const ScopedResource* resource,
                             ScopedResourceWriteLocks* locks);

  ContextProvider* context_provider_;
  ResourceProvider* resource_provider_;
  SkMultiPictureDraw multi_picture_draw_;

  bool use_distance_field_text_;
  bool threaded_gpu_rasterization_enabled_;
  int msaa_sample_count_;

  DISALLOW_COPY_AND_ASSIGN(GpuRasterizer);
};

}  // namespace cc

#endif  // CC_RESOURCES_GPU_RASTERIZER_H_