1 // Copyright 2018 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_VALIDATING_ABSTRACT_TEXTURE_IMPL_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_VALIDATING_ABSTRACT_TEXTURE_IMPL_H_ 7 8 #include "base/callback.h" 9 #include "base/memory/scoped_refptr.h" 10 #include "gpu/command_buffer/service/abstract_texture.h" 11 #include "gpu/gpu_gles2_export.h" 12 13 namespace gpu { 14 class DecoderContext; 15 16 namespace gles2 { 17 18 class ContextGroup; 19 class ErrorState; 20 class TextureManager; 21 class TextureRef; 22 23 // Implementation of AbstractTexture used by the validating command decoder. 24 class GPU_GLES2_EXPORT ValidatingAbstractTextureImpl : public AbstractTexture { 25 public: 26 using DestructionCB = base::OnceCallback<void(ValidatingAbstractTextureImpl*, 27 scoped_refptr<TextureRef>)>; 28 29 ValidatingAbstractTextureImpl(scoped_refptr<TextureRef> texture_ref, 30 DecoderContext* DecoderContext, 31 DestructionCB destruction_cb); 32 ~ValidatingAbstractTextureImpl() override; 33 34 // AbstractTexture 35 TextureBase* GetTextureBase() const override; 36 void SetParameteri(GLenum pname, GLint param) override; 37 void BindStreamTextureImage(gl::GLImage* image, GLuint service_id) override; 38 void BindImage(gl::GLImage* image, bool client_managed) override; 39 gl::GLImage* GetImage() const override; 40 void SetCleared() override; 41 void SetCleanupCallback(CleanupCallback cb) override; 42 43 // Called when our decoder is going away, so that we can try to clean up. 44 void OnDecoderWillDestroy(bool have_context); 45 46 // Testing methods 47 TextureRef* GetTextureRefForTesting(); 48 49 private: 50 TextureManager* GetTextureManager() const; 51 ContextGroup* GetContextGroup() const; 52 ErrorState* GetErrorState() const; 53 54 // Reset our level (0) info to be what we were given during construction. 55 void SetLevelInfo(); 56 57 scoped_refptr<TextureRef> texture_ref_; 58 bool decoder_managed_image_ = false; 59 60 DecoderContext* decoder_context_ = nullptr; 61 DestructionCB destruction_cb_; 62 CleanupCallback cleanup_cb_; 63 }; 64 65 } // namespace gles2 66 } // namespace gpu 67 68 #endif // GPU_COMMAND_BUFFER_SERVICE_VALIDATING_ABSTRACT_TEXTURE_IMPL_H_ 69