12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h" 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/synchronization/lock.h" 11fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch#include "base/threading/thread_checker.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "webkit/common/gpu/context_provider_web_context.h" 133551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "webkit/common/gpu/webkit_gpu_export.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace blink { class WebGraphicsContext3D; } 17eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace webkit { 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace gpu { 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class GrContextForWebGraphicsContext3D; 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WEBKIT_GPU_EXPORT ContextProviderInProcess 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : NON_EXPORTED_BASE(public ContextProviderWebContext) { 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 253551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) static scoped_refptr<ContextProviderInProcess> Create( 26d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, 27d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const std::string& debug_name); 283551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 29e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // Uses default attributes for creating an offscreen context. 30e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch static scoped_refptr<ContextProviderInProcess> CreateOffscreen( 31e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch bool lose_context_when_out_of_memory); 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual blink::WebGraphicsContext3D* WebContext3D() OVERRIDE; 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual bool BindToCurrentThread() OVERRIDE; 36424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) virtual Capabilities ContextCapabilities() OVERRIDE; 37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual ::gpu::gles2::GLES2Interface* ContextGL() OVERRIDE; 388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual ::gpu::ContextSupport* ContextSupport() OVERRIDE; 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual class GrContext* GrContext() OVERRIDE; 40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual bool IsContextLost() OVERRIDE; 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void VerifyContexts() OVERRIDE; 425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual void DeleteCachedResources() OVERRIDE; 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual bool DestroyedOnMainThread() OVERRIDE; 44fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch virtual void SetLostContextCallback( 45fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch const LostContextCallback& lost_context_callback) OVERRIDE; 463551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) virtual void SetMemoryPolicyChangedCallback( 473551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) const MemoryPolicyChangedCallback& memory_policy_changed_callback) 483551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) OVERRIDE; 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected: 513551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) ContextProviderInProcess( 52d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, 53d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const std::string& debug_name); 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual ~ContextProviderInProcess(); 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 56fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch void OnLostContext(); 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private: 59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void InitializeCapabilities(); 60a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 61fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch base::ThreadChecker main_thread_checker_; 62fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch base::ThreadChecker context_thread_checker_; 63fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch 643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> 653551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) context3d_; 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_; 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 68fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch LostContextCallback lost_context_callback_; 69fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::Lock destroyed_lock_; 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool destroyed_; 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 73d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) std::string debug_name_; 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) class LostContextCallbackProxy; 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) cc::ContextProvider::Capabilities capabilities_; 783551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace gpu 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace webkit 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ 86