content/canvas/src/WebGLQuery.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/src/WebGLQuery.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     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 +#include "WebGLContext.h"
    1.10 +#include "GLContext.h"
    1.11 +#include "WebGLQuery.h"
    1.12 +#include "mozilla/dom/WebGL2RenderingContextBinding.h"
    1.13 +#include "nsContentUtils.h"
    1.14 +
    1.15 +using namespace mozilla;
    1.16 +
    1.17 +JSObject*
    1.18 +WebGLQuery::WrapObject(JSContext *cx) {
    1.19 +    return dom::WebGLQueryBinding::Wrap(cx, this);
    1.20 +}
    1.21 +
    1.22 +WebGLQuery::WebGLQuery(WebGLContext* context)
    1.23 +    : WebGLContextBoundObject(context)
    1.24 +    , mGLName(0)
    1.25 +    , mType(0)
    1.26 +{
    1.27 +    SetIsDOMBinding();
    1.28 +    mContext->mQueries.insertBack(this);
    1.29 +
    1.30 +    mContext->MakeContextCurrent();
    1.31 +    mContext->gl->fGenQueries(1, &mGLName);
    1.32 +}
    1.33 +
    1.34 +void WebGLQuery::Delete() {
    1.35 +    mContext->MakeContextCurrent();
    1.36 +    mContext->gl->fDeleteQueries(1, &mGLName);
    1.37 +    LinkedListElement<WebGLQuery>::removeFrom(mContext->mQueries);
    1.38 +}
    1.39 +
    1.40 +bool WebGLQuery::IsActive() const
    1.41 +{
    1.42 +    WebGLRefPtr<WebGLQuery>* targetSlot = mContext->GetQueryTargetSlot(mType, "WebGLQuery::IsActive()");
    1.43 +
    1.44 +    MOZ_ASSERT(targetSlot, "unknown query object's type");
    1.45 +
    1.46 +    return targetSlot && *targetSlot == this;
    1.47 +}
    1.48 +
    1.49 +
    1.50 +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLQuery)
    1.51 +
    1.52 +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLQuery, AddRef)
    1.53 +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLQuery, Release)

mercurial