gfx/angle/src/libGLESv2/renderer/Fence11.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 #include "precompiled.h"
michael@0 2 //
michael@0 3 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
michael@0 4 // Use of this source code is governed by a BSD-style license that can be
michael@0 5 // found in the LICENSE file.
michael@0 6 //
michael@0 7
michael@0 8 // Fence11.cpp: Defines the rx::Fence11 class which implements rx::FenceImpl.
michael@0 9
michael@0 10 #include "libGLESv2/renderer/Fence11.h"
michael@0 11 #include "libGLESv2/main.h"
michael@0 12 #include "libGLESv2/renderer/Renderer11.h"
michael@0 13
michael@0 14 namespace rx
michael@0 15 {
michael@0 16
michael@0 17 Fence11::Fence11(rx::Renderer11 *renderer)
michael@0 18 {
michael@0 19 mRenderer = renderer;
michael@0 20 mQuery = NULL;
michael@0 21 }
michael@0 22
michael@0 23 Fence11::~Fence11()
michael@0 24 {
michael@0 25 if (mQuery)
michael@0 26 {
michael@0 27 mQuery->Release();
michael@0 28 mQuery = NULL;
michael@0 29 }
michael@0 30 }
michael@0 31
michael@0 32 GLboolean Fence11::isFence()
michael@0 33 {
michael@0 34 // GL_NV_fence spec:
michael@0 35 // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
michael@0 36 return mQuery != NULL;
michael@0 37 }
michael@0 38
michael@0 39 void Fence11::setFence(GLenum condition)
michael@0 40 {
michael@0 41 if (!mQuery)
michael@0 42 {
michael@0 43 D3D11_QUERY_DESC queryDesc;
michael@0 44 queryDesc.Query = D3D11_QUERY_EVENT;
michael@0 45 queryDesc.MiscFlags = 0;
michael@0 46
michael@0 47 if (FAILED(mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery)))
michael@0 48 {
michael@0 49 return gl::error(GL_OUT_OF_MEMORY);
michael@0 50 }
michael@0 51 }
michael@0 52
michael@0 53 mRenderer->getDeviceContext()->End(mQuery);
michael@0 54
michael@0 55 setCondition(condition);
michael@0 56 setStatus(GL_FALSE);
michael@0 57 }
michael@0 58
michael@0 59 GLboolean Fence11::testFence()
michael@0 60 {
michael@0 61 if (mQuery == NULL)
michael@0 62 {
michael@0 63 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
michael@0 64 }
michael@0 65
michael@0 66 HRESULT result = mRenderer->getDeviceContext()->GetData(mQuery, NULL, 0, 0);
michael@0 67
michael@0 68 if (mRenderer->isDeviceLost())
michael@0 69 {
michael@0 70 return gl::error(GL_OUT_OF_MEMORY, GL_TRUE);
michael@0 71 }
michael@0 72
michael@0 73 ASSERT(result == S_OK || result == S_FALSE);
michael@0 74 setStatus(result == S_OK);
michael@0 75 return getStatus();
michael@0 76 }
michael@0 77
michael@0 78 void Fence11::finishFence()
michael@0 79 {
michael@0 80 if (mQuery == NULL)
michael@0 81 {
michael@0 82 return gl::error(GL_INVALID_OPERATION);
michael@0 83 }
michael@0 84
michael@0 85 while (!testFence())
michael@0 86 {
michael@0 87 Sleep(0);
michael@0 88 }
michael@0 89 }
michael@0 90
michael@0 91 void Fence11::getFenceiv(GLenum pname, GLint *params)
michael@0 92 {
michael@0 93 if (mQuery == NULL)
michael@0 94 {
michael@0 95 return gl::error(GL_INVALID_OPERATION);
michael@0 96 }
michael@0 97
michael@0 98 switch (pname)
michael@0 99 {
michael@0 100 case GL_FENCE_STATUS_NV:
michael@0 101 {
michael@0 102 // GL_NV_fence spec:
michael@0 103 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
michael@0 104 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
michael@0 105 if (getStatus())
michael@0 106 {
michael@0 107 params[0] = GL_TRUE;
michael@0 108 return;
michael@0 109 }
michael@0 110
michael@0 111 HRESULT result = mRenderer->getDeviceContext()->GetData(mQuery, NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH);
michael@0 112
michael@0 113 if (mRenderer->isDeviceLost())
michael@0 114 {
michael@0 115 params[0] = GL_TRUE;
michael@0 116 return gl::error(GL_OUT_OF_MEMORY);
michael@0 117 }
michael@0 118
michael@0 119 ASSERT(result == S_OK || result == S_FALSE);
michael@0 120 setStatus(result == S_OK);
michael@0 121 params[0] = getStatus();
michael@0 122
michael@0 123 break;
michael@0 124 }
michael@0 125 case GL_FENCE_CONDITION_NV:
michael@0 126 params[0] = getCondition();
michael@0 127 break;
michael@0 128 default:
michael@0 129 return gl::error(GL_INVALID_ENUM);
michael@0 130 break;
michael@0 131 }
michael@0 132 }
michael@0 133
michael@0 134 }

mercurial