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 "effect/color_space.h" 17 18 #include "impl_factory.h" 19 20 namespace OHOS { 21 namespace Rosen { 22 namespace Drawing { ColorSpace(ColorSpaceType t)23ColorSpace::ColorSpace(ColorSpaceType t) noexcept : ColorSpace() 24 { 25 type_ = t; 26 switch (type_) { 27 case ColorSpace::ColorSpaceType::SRGB: 28 impl_->InitWithSRGB(); 29 break; 30 case ColorSpace::ColorSpaceType::SRGB_LINEAR: 31 impl_->InitWithSRGBLinear(); 32 break; 33 default: 34 break; 35 } 36 } 37 ColorSpace(ColorSpaceType t,const Image & image)38ColorSpace::ColorSpace(ColorSpaceType t, const Image& image) noexcept : ColorSpace() 39 { 40 type_ = t; 41 impl_->InitWithImage(image); 42 } 43 ColorSpace()44ColorSpace::ColorSpace() noexcept 45 : type_(ColorSpace::ColorSpaceType::NO_TYPE), impl_(ImplFactory::CreateColorSpaceImpl()) 46 {} 47 GetType() const48ColorSpace::ColorSpaceType ColorSpace::GetType() const 49 { 50 return type_; 51 } 52 CreateSRGB()53std::shared_ptr<ColorSpace> ColorSpace::CreateSRGB() 54 { 55 return std::make_shared<ColorSpace>(ColorSpace::ColorSpaceType::SRGB); 56 } 57 CreateSRGBLinear()58std::shared_ptr<ColorSpace> ColorSpace::CreateSRGBLinear() 59 { 60 return std::make_shared<ColorSpace>(ColorSpace::ColorSpaceType::SRGB_LINEAR); 61 } 62 CreateRefImage(const Image & image)63std::shared_ptr<ColorSpace> ColorSpace::CreateRefImage(const Image& image) 64 { 65 return std::make_shared<ColorSpace>(ColorSpace::ColorSpaceType::REF_IMAGE, image); 66 } 67 } // namespace Drawing 68 } // namespace Rosen 69 } // namespace OHOS