本文整理汇总了C++中WebGLContextAttributes::setPreserveDrawingBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ WebGLContextAttributes::setPreserveDrawingBuffer方法的具体用法?C++ WebGLContextAttributes::setPreserveDrawingBuffer怎么用?C++ WebGLContextAttributes::setPreserveDrawingBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLContextAttributes
的用法示例。
在下文中一共展示了WebGLContextAttributes::setPreserveDrawingBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toWebGLContextAttributes
WebGLContextAttributes toWebGLContextAttributes(const CanvasContextCreationAttributes& attrs)
{
WebGLContextAttributes result;
result.setAlpha(attrs.alpha());
result.setDepth(attrs.depth());
result.setStencil(attrs.stencil());
result.setAntialias(attrs.antialias());
result.setPremultipliedAlpha(attrs.premultipliedAlpha());
result.setPreserveDrawingBuffer(attrs.preserveDrawingBuffer());
result.setFailIfMajorPerformanceCaveat(attrs.failIfMajorPerformanceCaveat());
return result;
}
示例2: setJSWebGLContextAttributesPreserveDrawingBuffer
void setJSWebGLContextAttributesPreserveDrawingBuffer(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSWebGLContextAttributes* castedThis = static_cast<JSWebGLContextAttributes*>(thisObject);
WebGLContextAttributes* imp = static_cast<WebGLContextAttributes*>(castedThis->impl());
imp->setPreserveDrawingBuffer(value.toBoolean(exec));
}
示例3: if
v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Arguments& args)
{
INC_STATS("DOM.HTMLCanvasElement.context");
v8::Handle<v8::Object> holder = args.Holder();
HTMLCanvasElement* imp = V8HTMLCanvasElement::toNative(holder);
String contextId = toWebCoreString(args[0]);
RefPtr<CanvasContextAttributes> attrs;
#if ENABLE(WEBGL)
if (contextId == "experimental-webgl" || contextId == "webkit-3d") {
attrs = WebGLContextAttributes::create();
WebGLContextAttributes* webGLAttrs = static_cast<WebGLContextAttributes*>(attrs.get());
if (args.Length() > 1 && args[1]->IsObject()) {
v8::Handle<v8::Object> jsAttrs = args[1]->ToObject();
v8::Handle<v8::String> alpha = v8::String::New("alpha");
if (jsAttrs->Has(alpha))
webGLAttrs->setAlpha(jsAttrs->Get(alpha)->BooleanValue());
v8::Handle<v8::String> depth = v8::String::New("depth");
if (jsAttrs->Has(depth))
webGLAttrs->setDepth(jsAttrs->Get(depth)->BooleanValue());
v8::Handle<v8::String> stencil = v8::String::New("stencil");
if (jsAttrs->Has(stencil))
webGLAttrs->setStencil(jsAttrs->Get(stencil)->BooleanValue());
v8::Handle<v8::String> antialias = v8::String::New("antialias");
if (jsAttrs->Has(antialias))
webGLAttrs->setAntialias(jsAttrs->Get(antialias)->BooleanValue());
v8::Handle<v8::String> premultipliedAlpha = v8::String::New("premultipliedAlpha");
if (jsAttrs->Has(premultipliedAlpha))
webGLAttrs->setPremultipliedAlpha(jsAttrs->Get(premultipliedAlpha)->BooleanValue());
v8::Handle<v8::String> preserveDrawingBuffer = v8::String::New("preserveDrawingBuffer");
if (jsAttrs->Has(preserveDrawingBuffer))
webGLAttrs->setPreserveDrawingBuffer(jsAttrs->Get(preserveDrawingBuffer)->BooleanValue());
}
}
#endif
CanvasRenderingContext* result = imp->getContext(contextId, attrs.get());
if (!result)
return v8::Null(args.GetIsolate());
else if (result->is2d()) {
v8::Handle<v8::Value> v8Result = toV8(static_cast<CanvasRenderingContext2D*>(result), args.Holder(), args.GetIsolate());
if (InspectorInstrumentation::canvasAgentEnabled(imp->document())) {
ScriptState* scriptState = ScriptState::forContext(v8::Context::GetCurrent());
ScriptObject context(scriptState, v8::Handle<v8::Object>::Cast(v8Result));
ScriptObject wrapped = InspectorInstrumentation::wrapCanvas2DRenderingContextForInstrumentation(imp->document(), context);
if (!wrapped.hasNoValue())
return wrapped.v8Value();
}
return v8Result;
}
#if ENABLE(WEBGL)
else if (result->is3d()) {
// 3D canvas contexts can hold on to lots of GPU resources, and we want to take an
// opportunity to get rid of them as soon as possible when we navigate away from pages using
// them.
V8PerIsolateData* perIsolateData = V8PerIsolateData::from(args.GetIsolate());
perIsolateData->setShouldCollectGarbageSoon();
v8::Handle<v8::Value> v8Result = toV8(static_cast<WebGLRenderingContext*>(result), args.Holder(), args.GetIsolate());
if (InspectorInstrumentation::canvasAgentEnabled(imp->document())) {
ScriptState* scriptState = ScriptState::forContext(v8::Context::GetCurrent());
ScriptObject glContext(scriptState, v8::Handle<v8::Object>::Cast(v8Result));
ScriptObject wrapped = InspectorInstrumentation::wrapWebGLRenderingContextForInstrumentation(imp->document(), glContext);
if (!wrapped.hasNoValue())
return wrapped.v8Value();
}
return v8Result;
}
#endif
ASSERT_NOT_REACHED();
return v8::Null(args.GetIsolate());
}