Home | History | Annotate | Download | only in test
      1 // Copyright 2013 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 CC_TEST_TEST_CONTEXT_SUPPORT_H_
      6 #define CC_TEST_TEST_CONTEXT_SUPPORT_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/memory/weak_ptr.h"
     11 #include "gpu/command_buffer/client/context_support.h"
     12 
     13 namespace cc {
     14 
     15 class TestContextSupport : public gpu::ContextSupport {
     16  public:
     17   TestContextSupport();
     18   virtual ~TestContextSupport();
     19 
     20   // gpu::ContextSupport implementation.
     21   virtual void SignalSyncPoint(uint32 sync_point,
     22                                const base::Closure& callback) OVERRIDE;
     23   virtual void SignalQuery(uint32 query,
     24                            const base::Closure& callback) OVERRIDE;
     25   virtual void SetSurfaceVisible(bool visible) OVERRIDE;
     26   virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats)
     27     OVERRIDE;
     28   virtual void Swap() OVERRIDE;
     29   virtual void PartialSwapBuffers(gfx::Rect sub_buffer) OVERRIDE;
     30   virtual void SetSwapBuffersCompleteCallback(
     31       const base::Closure& callback) OVERRIDE;
     32 
     33   void CallAllSyncPointCallbacks();
     34 
     35   typedef base::Callback<void(bool visible)> SurfaceVisibleCallback;
     36   void SetSurfaceVisibleCallback(
     37       const SurfaceVisibleCallback& set_visible_callback);
     38 
     39   enum SwapType {
     40     NO_SWAP,
     41     SWAP,
     42     PARTIAL_SWAP
     43   };
     44 
     45   SwapType last_swap_type() const { return last_swap_type_; }
     46   gfx::Rect last_partial_swap_rect() const {
     47     return last_partial_swap_rect_;
     48   }
     49 
     50  private:
     51   void OnSwapBuffersComplete();
     52 
     53   std::vector<base::Closure> sync_point_callbacks_;
     54   SurfaceVisibleCallback set_visible_callback_;
     55 
     56   base::Closure swap_buffers_complete_callback_;
     57 
     58   SwapType last_swap_type_;
     59   gfx::Rect last_partial_swap_rect_;
     60 
     61   base::WeakPtrFactory<TestContextSupport> weak_ptr_factory_;
     62 
     63   DISALLOW_COPY_AND_ASSIGN(TestContextSupport);
     64 };
     65 
     66 }  // namespace cc
     67 
     68 #endif  // CC_TEST_TEST_CONTEXT_SUPPORT_H_
     69