1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/d3d10/ReadbackManagerD3D10.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_READBACKMANAGERD3D10_H 1.10 +#define GFX_READBACKMANAGERD3D10_H 1.11 + 1.12 +#include <windows.h> 1.13 +#include <d3d10_1.h> 1.14 + 1.15 +#include "nsTArray.h" 1.16 +#include "nsAutoPtr.h" 1.17 +#include "gfxPoint.h" 1.18 + 1.19 +namespace mozilla { 1.20 +namespace layers { 1.21 + 1.22 +DWORD WINAPI StartTaskThread(void *aManager); 1.23 + 1.24 +struct ReadbackTask; 1.25 + 1.26 +class ReadbackManagerD3D10 MOZ_FINAL : public IUnknown 1.27 +{ 1.28 +public: 1.29 + ReadbackManagerD3D10(); 1.30 + ~ReadbackManagerD3D10(); 1.31 + 1.32 + /** 1.33 + * Tell the readback manager to post a readback task. 1.34 + * 1.35 + * @param aTexture D3D10_USAGE_STAGING texture that will contain the data that 1.36 + * was readback. 1.37 + * @param aUpdate ReadbackProcessor::Update object. This is a void pointer 1.38 + * since we cannot forward declare a nested class, and do not 1.39 + * export ReadbackProcessor.h 1.40 + * @param aOrigin Origin of the aTexture surface in the ThebesLayer 1.41 + * coordinate system. 1.42 + */ 1.43 + void PostTask(ID3D10Texture2D *aTexture, void *aUpdate, const gfxPoint &aOrigin); 1.44 + 1.45 + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, 1.46 + void **ppvObject); 1.47 + virtual ULONG STDMETHODCALLTYPE AddRef(void); 1.48 + virtual ULONG STDMETHODCALLTYPE Release(void); 1.49 + 1.50 +private: 1.51 + friend DWORD WINAPI StartTaskThread(void *aManager); 1.52 + 1.53 + void ProcessTasks(); 1.54 + 1.55 + // The invariant maintained by |mTaskSemaphore| is that the readback thread 1.56 + // will awaken from WaitForMultipleObjects() at least once per readback 1.57 + // task enqueued by the main thread. Since the readback thread processes 1.58 + // exactly one task per wakeup (with one exception), no tasks are lost. The 1.59 + // exception is when the readback thread is shut down, which orphans the 1.60 + // remaining tasks, on purpose. 1.61 + HANDLE mTaskSemaphore; 1.62 + // Event signaled when the task thread should shutdown 1.63 + HANDLE mShutdownEvent; 1.64 + // Handle to the task thread 1.65 + HANDLE mTaskThread; 1.66 + 1.67 + // FiFo list of readback tasks that are to be executed. Access is synchronized 1.68 + // by mTaskMutex. 1.69 + CRITICAL_SECTION mTaskMutex; 1.70 + nsTArray<nsAutoPtr<ReadbackTask>> mPendingReadbackTasks; 1.71 + 1.72 + ULONG mRefCnt; 1.73 +}; 1.74 + 1.75 +} 1.76 +} 1.77 + 1.78 +#endif /* GFX_READBACKMANAGERD3D10_H */