1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "bridge/declarative_frontend/jsview/canvas/js_rendering_context_settings.h" 17 18 #include "bridge/declarative_frontend/jsview/canvas/js_rendering_context.h" 19 #include "bridge/declarative_frontend/jsview/js_view_common_def.h" 20 21 namespace OHOS::Ace::Framework { 22 JSRenderingContextSettings()23JSRenderingContextSettings::JSRenderingContextSettings() 24 { 25 } 26 Constructor(const JSCallbackInfo & args)27void JSRenderingContextSettings::Constructor(const JSCallbackInfo& args) 28 { 29 auto jsRenderingContextSettings = Referenced::MakeRefPtr<JSRenderingContextSettings>(); 30 jsRenderingContextSettings->IncRefCount(); 31 args.SetReturnValue(Referenced::RawPtr(jsRenderingContextSettings)); 32 bool anti = false; 33 bool alpha = false; 34 if (args.Length() > 0) { 35 JSViewAbstract::ParseJsBool(args[0], anti); 36 } 37 if (args.Length() > 1) { 38 JSViewAbstract::ParseJsBool(args[1], alpha); 39 } 40 jsRenderingContextSettings->SetAntialias(anti); 41 jsRenderingContextSettings->SetAlpha(alpha); 42 } 43 Destructor(JSRenderingContextSettings * controller)44void JSRenderingContextSettings::Destructor(JSRenderingContextSettings* controller) 45 { 46 if (controller != nullptr) { 47 controller->DecRefCount(); 48 } 49 } 50 JSBind(BindingTarget globalObj)51void JSRenderingContextSettings::JSBind(BindingTarget globalObj) 52 { 53 JSClass<JSRenderingContextSettings>::Declare("RenderingContextSettings"); 54 JSClass<JSRenderingContextSettings>::Bind(globalObj, JSRenderingContextSettings::Constructor, 55 JSRenderingContextSettings::Destructor); 56 } 57 58 } // namespace OHOS::Ace::Framework 59