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 | // Query9.cpp: Defines the rx::Query9 class which implements rx::QueryImpl. |
michael@0 | 9 | |
michael@0 | 10 | |
michael@0 | 11 | #include "libGLESv2/renderer/Query9.h" |
michael@0 | 12 | #include "libGLESv2/main.h" |
michael@0 | 13 | #include "libGLESv2/renderer/renderer9_utils.h" |
michael@0 | 14 | #include "libGLESv2/renderer/Renderer9.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace rx |
michael@0 | 17 | { |
michael@0 | 18 | |
michael@0 | 19 | Query9::Query9(rx::Renderer9 *renderer, GLenum type) : QueryImpl(type) |
michael@0 | 20 | { |
michael@0 | 21 | mRenderer = renderer; |
michael@0 | 22 | mQuery = NULL; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | Query9::~Query9() |
michael@0 | 26 | { |
michael@0 | 27 | if (mQuery) |
michael@0 | 28 | { |
michael@0 | 29 | mQuery->Release(); |
michael@0 | 30 | mQuery = NULL; |
michael@0 | 31 | } |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | void Query9::begin() |
michael@0 | 35 | { |
michael@0 | 36 | if (mQuery == NULL) |
michael@0 | 37 | { |
michael@0 | 38 | if (FAILED(mRenderer->getDevice()->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mQuery))) |
michael@0 | 39 | { |
michael@0 | 40 | return gl::error(GL_OUT_OF_MEMORY); |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | HRESULT result = mQuery->Issue(D3DISSUE_BEGIN); |
michael@0 | 45 | ASSERT(SUCCEEDED(result)); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | void Query9::end() |
michael@0 | 49 | { |
michael@0 | 50 | if (mQuery == NULL) |
michael@0 | 51 | { |
michael@0 | 52 | return gl::error(GL_INVALID_OPERATION); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | HRESULT result = mQuery->Issue(D3DISSUE_END); |
michael@0 | 56 | ASSERT(SUCCEEDED(result)); |
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 Query9::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 |
michael@0 | 70 | // some drivers seem to return S_FALSE even if the device is lost |
michael@0 | 71 | // instead of D3DERR_DEVICELOST like they should |
michael@0 | 72 | if (mRenderer->testDeviceLost(true)) |
michael@0 | 73 | { |
michael@0 | 74 | return gl::error(GL_OUT_OF_MEMORY, 0); |
michael@0 | 75 | } |
michael@0 | 76 | } |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | return mResult; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | GLboolean Query9::isResultAvailable() |
michael@0 | 83 | { |
michael@0 | 84 | if (mQuery != NULL) |
michael@0 | 85 | { |
michael@0 | 86 | testQuery(); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | return mStatus; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | GLboolean Query9::testQuery() |
michael@0 | 93 | { |
michael@0 | 94 | if (mQuery != NULL && mStatus != GL_TRUE) |
michael@0 | 95 | { |
michael@0 | 96 | DWORD numPixels = 0; |
michael@0 | 97 | |
michael@0 | 98 | HRESULT hres = mQuery->GetData(&numPixels, sizeof(DWORD), D3DGETDATA_FLUSH); |
michael@0 | 99 | if (hres == S_OK) |
michael@0 | 100 | { |
michael@0 | 101 | mStatus = GL_TRUE; |
michael@0 | 102 | |
michael@0 | 103 | switch (getType()) |
michael@0 | 104 | { |
michael@0 | 105 | case GL_ANY_SAMPLES_PASSED_EXT: |
michael@0 | 106 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
michael@0 | 107 | mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE; |
michael@0 | 108 | break; |
michael@0 | 109 | default: |
michael@0 | 110 | ASSERT(false); |
michael@0 | 111 | } |
michael@0 | 112 | } |
michael@0 | 113 | else if (d3d9::isDeviceLostError(hres)) |
michael@0 | 114 | { |
michael@0 | 115 | mRenderer->notifyDeviceLost(); |
michael@0 | 116 | return gl::error(GL_OUT_OF_MEMORY, GL_TRUE); |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | return mStatus; |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | return GL_TRUE; // prevent blocking when query is null |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | } |