File: gpu_benchmarking_extension.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (123 lines) | stat: -rw-r--r-- 4,319 bytes parent folder | download | duplicates (11)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_RENDERER_GPU_BENCHMARKING_EXTENSION_H_
#define CONTENT_RENDERER_GPU_BENCHMARKING_EXTENSION_H_

#include "base/memory/weak_ptr.h"
#include "content/common/input/input_injector.mojom.h"
#include "gin/wrappable.h"
#include "mojo/public/cpp/bindings/remote.h"

namespace gin {
class Arguments;
}

namespace v8 {
class Isolate;
class Object;
}  // namespace v8

namespace content {

class RenderFrameImpl;

// gin class for gpu benchmarking
class GpuBenchmarking : public gin::Wrappable<GpuBenchmarking> {
 public:
  static gin::WrapperInfo kWrapperInfo;

  GpuBenchmarking(const GpuBenchmarking&) = delete;
  GpuBenchmarking& operator=(const GpuBenchmarking&) = delete;

  static void Install(base::WeakPtr<RenderFrameImpl> frame);

 private:
  explicit GpuBenchmarking(base::WeakPtr<RenderFrameImpl> frame);
  ~GpuBenchmarking() override;
  void EnsureRemoteInterface();

  // gin::Wrappable.
  gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
      v8::Isolate* isolate) override;

  // JavaScript handlers.
  void SetNeedsDisplayOnAllLayers();
  void SetRasterizeOnlyVisibleContent();
  void PrintToSkPicture(v8::Isolate* isolate, const std::string& dirname);
  void PrintPagesToSkPictures(v8::Isolate* isolate,
                              const std::string& filename);
  void PrintPagesToXPS(v8::Isolate* isolate, const std::string& filename);
  bool GestureSourceTypeSupported(int gesture_source_type);

  // All arguments in these methods are in visual viewport coordinates.
  bool SmoothScrollBy(gin::Arguments* args);
  bool SmoothScrollByXY(gin::Arguments* args);
  bool SmoothDrag(gin::Arguments* args);
  bool Swipe(gin::Arguments* args);
  bool ScrollBounce(gin::Arguments* args);
  bool PinchBy(gin::Arguments* args);
  bool Tap(gin::Arguments* args);

  bool PointerActionSequence(gin::Arguments* args);

  // The offset of the visual viewport *within* the layout viewport, in CSS
  // pixels. i.e. As the user zooms in, these values don't change.
  float VisualViewportX();
  float VisualViewportY();

  // The width and height of the visual viewport in CSS pixels. i.e. As the
  // user zooms in, these get smaller (since the physical viewport is a fixed
  // size, fewer CSS pixels fit into it).
  float VisualViewportHeight();
  float VisualViewportWidth();

  // Returns the page scale factor applied as a result of pinch-zoom.
  float PageScaleFactor();
  // Sets the page scale factor applied as a result of pinch-zoom.
  void SetPageScaleFactor(float scale);

  void SetBrowserControlsShown(bool shown);

  void ClearImageCache();
  int RunMicroBenchmark(gin::Arguments* args);
  bool SendMessageToMicroBenchmark(int id, v8::Local<v8::Object> message);
  bool HasGpuChannel();
  bool HasGpuProcess();
  void CrashGpuProcess();
  void TerminateGpuProcessNormally();
  void GetGpuDriverBugWorkarounds(gin::Arguments* args);

  // Starts/stops the sampling profiler. StartProfiling takes one optional
  // argument, which is a file name for saving the data (relative to `pwd`
  // or %USERDIR%); if omitted, it defaults to "profile.pb".
  //
  // DO NOT USE THIS IN CHROMIUM TESTS -- we don't want to fill up the bots'
  // hard drives with profile data.
  void StartProfiling(gin::Arguments* args);
  void StopProfiling();

  // Freezes a page, used to transition the page to the FROZEN lifecycle state.
  void Freeze();

  // Register a callback that should be fired when the next swap completes.
  // The callback is removed once it's executed.
  bool AddSwapCompletionEventListener(gin::Arguments* args);

  // For Mac only, returns the error code why CoreAnimation Renderer is not used
  // in the requested frame. It's less efficient when this path is not hit.
  // See "ui/gfx/ca_layer_result.h" for error codes.
  int AddCoreAnimationStatusEventListener(gin::Arguments* args);

  // Returns true if the argument is a CanvasImageSource whose image data is
  // stored on the GPU.
  bool IsAcceleratedCanvasImageSource(gin::Arguments* args);

  base::WeakPtr<RenderFrameImpl> render_frame_;
  mojo::Remote<mojom::InputInjector> input_injector_;
};

}  // namespace content

#endif  // CONTENT_RENDERER_GPU_BENCHMARKING_EXTENSION_H_