Sat, 03 Jan 2015 20:18:00 +0100
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 | // Query11.cpp: Defines the rx::Query11 class which implements rx::QueryImpl. |
michael@0 | 9 | |
michael@0 | 10 | #include "libGLESv2/renderer/Query11.h" |
michael@0 | 11 | #include "libGLESv2/renderer/Renderer11.h" |
michael@0 | 12 | #include "libGLESv2/main.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace rx |
michael@0 | 15 | { |
michael@0 | 16 | |
michael@0 | 17 | Query11::Query11(rx::Renderer11 *renderer, GLenum type) : QueryImpl(type) |
michael@0 | 18 | { |
michael@0 | 19 | mRenderer = renderer; |
michael@0 | 20 | mQuery = NULL; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | Query11::~Query11() |
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 | void Query11::begin() |
michael@0 | 33 | { |
michael@0 | 34 | if (mQuery == NULL) |
michael@0 | 35 | { |
michael@0 | 36 | D3D11_QUERY_DESC queryDesc; |
michael@0 | 37 | queryDesc.Query = D3D11_QUERY_OCCLUSION; |
michael@0 | 38 | queryDesc.MiscFlags = 0; |
michael@0 | 39 | |
michael@0 | 40 | if (FAILED(mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery))) |
michael@0 | 41 | { |
michael@0 | 42 | return gl::error(GL_OUT_OF_MEMORY); |
michael@0 | 43 | } |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | mRenderer->getDeviceContext()->Begin(mQuery); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | void Query11::end() |
michael@0 | 50 | { |
michael@0 | 51 | if (mQuery == NULL) |
michael@0 | 52 | { |
michael@0 | 53 | return gl::error(GL_INVALID_OPERATION); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | mRenderer->getDeviceContext()->End(mQuery); |
michael@0 | 57 | |
michael@0 | 58 | mStatus = GL_FALSE; |
michael@0 | 59 | mResult = GL_FALSE; |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | GLuint Query11::getResult() |
michael@0 | 63 | { |
michael@0 | 64 | if (mQuery != NULL) |
michael@0 | 65 | { |
michael@0 | 66 | while (!testQuery()) |
michael@0 | 67 | { |
michael@0 | 68 | Sleep(0); |
michael@0 | 69 | // explicitly check for device loss, some drivers seem to return S_FALSE |
michael@0 | 70 | // if the device is lost |
michael@0 | 71 | if (mRenderer->testDeviceLost(true)) |
michael@0 | 72 | { |
michael@0 | 73 | return gl::error(GL_OUT_OF_MEMORY, 0); |
michael@0 | 74 | } |
michael@0 | 75 | } |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | return mResult; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | GLboolean Query11::isResultAvailable() |
michael@0 | 82 | { |
michael@0 | 83 | if (mQuery != NULL) |
michael@0 | 84 | { |
michael@0 | 85 | testQuery(); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | return mStatus; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | GLboolean Query11::testQuery() |
michael@0 | 92 | { |
michael@0 | 93 | if (mQuery != NULL && mStatus != GL_TRUE) |
michael@0 | 94 | { |
michael@0 | 95 | UINT64 numPixels = 0; |
michael@0 | 96 | HRESULT result = mRenderer->getDeviceContext()->GetData(mQuery, &numPixels, sizeof(UINT64), 0); |
michael@0 | 97 | if (result == S_OK) |
michael@0 | 98 | { |
michael@0 | 99 | mStatus = GL_TRUE; |
michael@0 | 100 | |
michael@0 | 101 | switch (getType()) |
michael@0 | 102 | { |
michael@0 | 103 | case GL_ANY_SAMPLES_PASSED_EXT: |
michael@0 | 104 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
michael@0 | 105 | mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE; |
michael@0 | 106 | break; |
michael@0 | 107 | default: |
michael@0 | 108 | UNREACHABLE(); |
michael@0 | 109 | } |
michael@0 | 110 | } |
michael@0 | 111 | else if (mRenderer->testDeviceLost(true)) |
michael@0 | 112 | { |
michael@0 | 113 | return gl::error(GL_OUT_OF_MEMORY, GL_TRUE); |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | return mStatus; |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | return GL_TRUE; // prevent blocking when query is null |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | } |