blob: 150ac05da426da0cd694bb980566cd2e73a9e752 [file] [log] [blame]
Jonathan Backer7f90dfb662017-12-18 16:52:041// Copyright (c) 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef GPU_COMMAND_BUFFER_SERVICE_RASTER_DECODER_H_
6#define GPU_COMMAND_BUFFER_SERVICE_RASTER_DECODER_H_
7
Jonathan Backer7f90dfb662017-12-18 16:52:048#include "base/macros.h"
Jonathan Backer1d807a42018-01-08 20:45:549#include "gpu/command_buffer/service/common_decoder.h"
Jonathan Backer1d807a42018-01-08 20:45:5410#include "gpu/command_buffer/service/decoder_context.h"
Antoine Labour83a0aed12018-01-10 04:52:3811#include "gpu/gpu_gles2_export.h"
Jonathan Backer7f90dfb662017-12-18 16:52:0412
13namespace gpu {
Antoine Labour40b0ca42018-01-03 20:15:3414
Jonathan Backer1d807a42018-01-08 20:45:5415class DecoderClient;
Jonathan Backer862b08d2018-05-10 15:37:0416class ServiceTransferCache;
Antoine Labour40b0ca42018-01-03 20:15:3417
Jonathan Backer7471b2782018-01-25 18:14:1918namespace gles2 {
Jonathan Backer10821a82018-04-04 23:56:0319class CopyTextureCHROMIUMResourceManager;
Jonathan Backera4568da12018-01-31 16:25:0420class GLES2Util;
Jonathan Backerac62dde2018-03-27 21:26:0921class ImageManager;
Jonathan Backera4568da12018-01-31 16:25:0422class Logger;
Jonathan Backer7471b2782018-01-25 18:14:1923class Outputter;
24} // namespace gles2
25
Jonathan Backer7f90dfb662017-12-18 16:52:0426namespace raster {
Khushaldb2d4ad72018-07-03 22:36:2727struct RasterDecoderContextState;
Jonathan Backer7f90dfb662017-12-18 16:52:0428
29// This class implements the AsyncAPIInterface interface, decoding
30// RasterInterface commands and calling GL.
Antoine Labour83a0aed12018-01-10 04:52:3831class GPU_GLES2_EXPORT RasterDecoder : public DecoderContext,
Jonathan Backer7471b2782018-01-25 18:14:1932 public CommonDecoder {
Jonathan Backer7f90dfb662017-12-18 16:52:0433 public:
Khushaldb2d4ad72018-07-03 22:36:2734 static RasterDecoder* Create(
35 DecoderClient* client,
36 CommandBufferServiceBase* command_buffer_service,
37 gles2::Outputter* outputter,
38 gles2::ContextGroup* group,
39 scoped_refptr<RasterDecoderContextState> raster_decoder_context_state);
Jonathan Backer7f90dfb662017-12-18 16:52:0440
41 ~RasterDecoder() override;
42
Jonathan Backera4568da12018-01-31 16:25:0443 // DecoderContext implementation.
44 bool initialized() const override;
45 TextureBase* GetTextureBase(uint32_t client_id) override;
Julien Isorcefd6c15f2018-03-15 16:51:1746 void SetLevelInfo(uint32_t client_id,
47 int level,
48 unsigned internal_format,
49 unsigned width,
50 unsigned height,
51 unsigned depth,
52 unsigned format,
53 unsigned type,
54 const gfx::Rect& cleared_rect) override;
Jonathan Backera4568da12018-01-31 16:25:0455 void BeginDecoding() override;
56 void EndDecoding() override;
57 base::StringPiece GetLogPrefix() override;
58
59 virtual gles2::GLES2Util* GetGLES2Util() = 0;
60 virtual gles2::Logger* GetLogger() = 0;
61 virtual void SetIgnoreCachedStateForTest(bool ignore) = 0;
62
Jonathan Backerac62dde2018-03-27 21:26:0963 // Gets the ImageManager for this context.
64 virtual gles2::ImageManager* GetImageManagerForTest() = 0;
65
Jonathan Backera4568da12018-01-31 16:25:0466 void set_initialized() { initialized_ = true; }
Jonathan Backer1d807a42018-01-08 20:45:5467
68 // Set to true to call glGetError after every command.
69 void set_debug(bool debug) { debug_ = debug; }
Jonathan Backera4568da12018-01-31 16:25:0470 bool debug() const { return debug_; }
Jonathan Backer1d807a42018-01-08 20:45:5471
72 // Set to true to LOG every command.
Jonathan Backer0cd1c4322018-04-17 16:57:1073 void SetLogCommands(bool log_commands) override;
Jonathan Backere26739c2018-05-15 13:27:0774 gles2::Outputter* outputter() const override;
Jonathan Backera4568da12018-01-31 16:25:0475 bool log_commands() const { return log_commands_; }
Jonathan Backer1d807a42018-01-08 20:45:5476
Jonathan Backer10821a82018-04-04 23:56:0377 virtual void SetCopyTextureResourceManagerForTest(
78 gles2::CopyTextureCHROMIUMResourceManager*
79 copy_texture_resource_manager) = 0;
80
Jonathan Backer862b08d2018-05-10 15:37:0481 virtual ServiceTransferCache* GetTransferCacheForTest() = 0;
82
Khushal15b6abb2018-06-28 00:16:2583 virtual void SetUpForRasterCHROMIUMForTest() = 0;
84
Jonathan Backer7471b2782018-01-25 18:14:1985 protected:
Jonathan Backere26739c2018-05-15 13:27:0786 RasterDecoder(CommandBufferServiceBase* command_buffer_service,
87 gles2::Outputter* outputter);
Jonathan Backer7471b2782018-01-25 18:14:1988
Jonathan Backer7f90dfb662017-12-18 16:52:0489 private:
Jonathan Backere26739c2018-05-15 13:27:0790 bool initialized_ = false;
91 bool debug_ = false;
92 bool log_commands_ = false;
93 gles2::Outputter* outputter_ = nullptr;
Jonathan Backer7f90dfb662017-12-18 16:52:0494
95 DISALLOW_COPY_AND_ASSIGN(RasterDecoder);
96};
97
98} // namespace raster
99} // namespace gpu
100
101#endif // GPU_COMMAND_BUFFER_SERVICE_RASTER_DECODER_H_