diff options
Diffstat (limited to 'src/platform')
23 files changed, 81 insertions, 108 deletions
diff --git a/src/platform/Exception.cpp b/src/platform/Exception.cpp index 744404e0..6a718f63 100644 --- a/src/platform/Exception.cpp +++ b/src/platform/Exception.cpp @@ -17,15 +17,6 @@ PlatformNotMatchException::PlatformNotMatchException( AppendMessage(additional_message); } -PlatformNotMatchException::PlatformNotMatchException( - StringView resource_platform, StringView target_platform, - std::optional<StringView> additional_message) - : PlatformNotMatchException( - resource_platform.ToUtf8(), target_platform.ToUtf8(), - additional_message.has_value() - ? std::make_optional(additional_message->ToUtf8()) - : std::nullopt) {} - PlatformNotMatchException::~PlatformNotMatchException() {} PlatformUnsupportedException::PlatformUnsupportedException( @@ -39,23 +30,5 @@ PlatformUnsupportedException::PlatformUnsupportedException( AppendMessage(additional_message); } -PlatformUnsupportedException::PlatformUnsupportedException( - StringView platform, StringView operation, - std::optional<StringView> additional_message) - : PlatformUnsupportedException( - platform.ToUtf8(), operation.ToUtf8(), - additional_message.has_value() - ? std::make_optional(additional_message->ToUtf8()) - : std::nullopt) {} - PlatformUnsupportedException::~PlatformUnsupportedException() {} - -String PlatformUnsupportedException::GetPlatform() const { - return String::FromUtf8(platform_); -} - -String PlatformUnsupportedException::GetOperation() const { - return String::FromUtf8(operation_); -} - } // namespace cru::platform diff --git a/src/platform/graphics/Geometry.cpp b/src/platform/graphics/Geometry.cpp index b9503c4e..2c842a6e 100644 --- a/src/platform/graphics/Geometry.cpp +++ b/src/platform/graphics/Geometry.cpp @@ -15,9 +15,9 @@ bool IGeometry::StrokeContains(float width, const Point& point) { std::unique_ptr<IGeometry> IGeometry::CreateStrokeGeometry( [[maybe_unused]] float width) { - throw PlatformUnsupportedException(GetPlatformId(), u"CreateStrokeGeometry", - u"Create stroke geometry of a geometry is " - u"not supported on this platform."); + throw PlatformUnsupportedException(GetPlatformIdUtf8(), "CreateStrokeGeometry", + "Create stroke geometry of a geometry is " + "not supported on this platform."); } void IGeometryBuilder::RelativeMoveTo(const Point& offset) { @@ -227,7 +227,7 @@ void IGeometryBuilder::ParseAndApplySvgPathData(StringView path_d) { auto read_number = [&] { if (read_spaces()) { - throw Exception(u"Unexpected eof of svg path data command."); + throw Exception("Unexpected eof of svg path data command."); } if (path_d[position] == ',') { @@ -239,7 +239,7 @@ void IGeometryBuilder::ParseAndApplySvgPathData(StringView path_d) { auto result = path_d.substr(position).ParseToFloat( &processed_count, StringToNumberFlags::kAllowTrailingJunk); - if (std::isnan(result)) throw Exception(u"Invalid svg path data number."); + if (std::isnan(result)) throw Exception("Invalid svg path data number."); position += processed_count; @@ -415,7 +415,7 @@ void IGeometryBuilder::ParseAndApplySvgPathData(StringView path_d) { CloseFigure(true); break; default: - throw Exception(u"Invalid svg path command."); + throw Exception("Invalid svg path command."); } return true; }; diff --git a/src/platform/graphics/SvgGeometryBuilderMixin.cpp b/src/platform/graphics/SvgGeometryBuilderMixin.cpp index bf5275c5..73290da5 100644 --- a/src/platform/graphics/SvgGeometryBuilderMixin.cpp +++ b/src/platform/graphics/SvgGeometryBuilderMixin.cpp @@ -10,8 +10,8 @@ SvgGeometryBuilderMixin::~SvgGeometryBuilderMixin() {} Point SvgGeometryBuilderMixin::GetCurrentPosition() { throw PlatformUnsupportedException( - GetPlatformId(), u"GetCurrentPosition", - u"Svg-based geometry does not support get current position."); + GetPlatformIdUtf8(), "GetCurrentPosition", + "Svg-based geometry does not support get current position."); } void SvgGeometryBuilderMixin::MoveTo(const Point& point) { diff --git a/src/platform/graphics/cairo/CairoGeometry.cpp b/src/platform/graphics/cairo/CairoGeometry.cpp index 2d415884..1f680c34 100644 --- a/src/platform/graphics/cairo/CairoGeometry.cpp +++ b/src/platform/graphics/cairo/CairoGeometry.cpp @@ -72,7 +72,7 @@ std::unique_ptr<IGeometry> CairoGeometry::Transform(const Matrix& matrix) { } std::unique_ptr<IGeometry> CairoGeometry::CreateStrokeGeometry(float width) { - throw Exception(u"Not implemented"); + throw Exception("Not implemented"); } CairoGeometryBuilder::CairoGeometryBuilder(CairoGraphicsFactory* factory) diff --git a/src/platform/graphics/cairo/CairoImageFactory.cpp b/src/platform/graphics/cairo/CairoImageFactory.cpp index 912226d9..ff922e77 100644 --- a/src/platform/graphics/cairo/CairoImageFactory.cpp +++ b/src/platform/graphics/cairo/CairoImageFactory.cpp @@ -207,19 +207,19 @@ std::unique_ptr<IImage> CairoImageFactory::DecodeFromStream( return DecodePng(GetCairoGraphicsFactory(), stream); } - throw Exception(u"Image format unknown. Currently only support png."); + throw Exception("Image format unknown. Currently only support png."); } void CairoImageFactory::EncodeToStream(IImage* image, io::Stream* stream, ImageFormat format, float quality) { - auto cairo_image = CheckPlatform<CairoImage>(image, GetPlatformId()); + auto cairo_image = CheckPlatform<CairoImage>(image, GetPlatformIdUtf8()); if (format == ImageFormat::Png) { EncodePng(cairo_image->GetCairoSurface(), stream); return; } - throw Exception(u"Not implemented. Currently only support png."); + throw Exception("Not implemented. Currently only support png."); } std::unique_ptr<IImage> CairoImageFactory::CreateBitmap(int width, int height) { diff --git a/src/platform/graphics/cairo/CairoPainter.cpp b/src/platform/graphics/cairo/CairoPainter.cpp index b9babaa2..94111098 100644 --- a/src/platform/graphics/cairo/CairoPainter.cpp +++ b/src/platform/graphics/cairo/CairoPainter.cpp @@ -56,7 +56,7 @@ void CairoPainter::Clear(const Color& color) { void CairoPainter::DrawLine(const Point& start, const Point& end, IBrush* brush, float width) { CheckValidation(); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_pattern = cairo_brush->GetCairoPattern(); cairo_save(cairo_); cairo_set_source(cairo_, cairo_pattern); @@ -71,7 +71,7 @@ void CairoPainter::DrawLine(const Point& start, const Point& end, IBrush* brush, void CairoPainter::StrokeRectangle(const Rect& rectangle, IBrush* brush, float width) { CheckValidation(); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_pattern = cairo_brush->GetCairoPattern(); cairo_save(cairo_); cairo_set_source(cairo_, cairo_pattern); @@ -85,7 +85,7 @@ void CairoPainter::StrokeRectangle(const Rect& rectangle, IBrush* brush, void CairoPainter::FillRectangle(const Rect& rectangle, IBrush* brush) { CheckValidation(); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_pattern = cairo_brush->GetCairoPattern(); cairo_save(cairo_); cairo_set_source(cairo_, cairo_pattern); @@ -99,7 +99,7 @@ void CairoPainter::FillRectangle(const Rect& rectangle, IBrush* brush) { void CairoPainter::StrokeEllipse(const Rect& outline_rect, IBrush* brush, float width) { CheckValidation(); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_pattern = cairo_brush->GetCairoPattern(); cairo_save(cairo_); cairo_set_source(cairo_, cairo_pattern); @@ -122,7 +122,7 @@ void CairoPainter::StrokeEllipse(const Rect& outline_rect, IBrush* brush, void CairoPainter::FillEllipse(const Rect& outline_rect, IBrush* brush) { CheckValidation(); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_pattern = cairo_brush->GetCairoPattern(); cairo_save(cairo_); cairo_set_source(cairo_, cairo_pattern); @@ -145,8 +145,8 @@ void CairoPainter::FillEllipse(const Rect& outline_rect, IBrush* brush) { void CairoPainter::StrokeGeometry(IGeometry* geometry, IBrush* brush, float width) { CheckValidation(); - auto cairo_geometry = CheckPlatform<CairoGeometry>(geometry, GetPlatformId()); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_geometry = CheckPlatform<CairoGeometry>(geometry, GetPlatformIdUtf8()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_path = cairo_geometry->GetCairoPath(); auto cairo_pattern = cairo_brush->GetCairoPattern(); @@ -162,8 +162,8 @@ void CairoPainter::StrokeGeometry(IGeometry* geometry, IBrush* brush, void CairoPainter::FillGeometry(IGeometry* geometry, IBrush* brush) { CheckValidation(); - auto cairo_geometry = CheckPlatform<CairoGeometry>(geometry, GetPlatformId()); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_geometry = CheckPlatform<CairoGeometry>(geometry, GetPlatformIdUtf8()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_path = cairo_geometry->GetCairoPath(); auto cairo_pattern = cairo_brush->GetCairoPattern(); @@ -181,9 +181,9 @@ void CairoPainter::DrawText(const Point& offset, ITextLayout* text_layout, CheckValidation(); auto pango_text_layout = - CheckPlatform<PangoTextLayout>(text_layout, GetPlatformId()); + CheckPlatform<PangoTextLayout>(text_layout, GetPlatformIdUtf8()); - auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformId()); + auto cairo_brush = CheckPlatform<CairoBrush>(brush, GetPlatformIdUtf8()); auto cairo_pattern = cairo_brush->GetCairoPattern(); cairo_save(cairo_); @@ -196,7 +196,7 @@ void CairoPainter::DrawText(const Point& offset, ITextLayout* text_layout, void CairoPainter::DrawImage(const Point& offset, IImage* image) { CheckValidation(); - auto cairo_image = CheckPlatform<CairoImage>(image, GetPlatformId()); + auto cairo_image = CheckPlatform<CairoImage>(image, GetPlatformIdUtf8()); cairo_save(cairo_); cairo_set_source_surface(cairo_, cairo_image->GetCairoSurface(), 0, 0); cairo_new_path(cairo_); @@ -251,7 +251,7 @@ void CairoPainter::EndDraw() { void CairoPainter::CheckValidation() { if (!valid_) { - throw ReuseException(u"Painter already ended drawing."); + throw ReuseException("Painter already ended drawing."); } } } // namespace cru::platform::graphics::cairo diff --git a/src/platform/graphics/cairo/PangoTextLayout.cpp b/src/platform/graphics/cairo/PangoTextLayout.cpp index 8dfd59d5..746056e2 100644 --- a/src/platform/graphics/cairo/PangoTextLayout.cpp +++ b/src/platform/graphics/cairo/PangoTextLayout.cpp @@ -24,7 +24,7 @@ PangoTextLayout::PangoTextLayout(CairoGraphicsFactory* factory, std::shared_ptr<IFont> font) : CairoResource(factory) { Expects(font); - font_ = CheckPlatform<PangoFont>(font, GetPlatformId()); + font_ = CheckPlatform<PangoFont>(font, GetPlatformIdUtf8()); pango_layout_ = pango_cairo_create_layout(factory->GetDefaultCairo()); pango_layout_set_font_description(pango_layout_, font_->GetPangoFontDescription()); @@ -44,7 +44,7 @@ std::shared_ptr<IFont> PangoTextLayout::GetFont() { return font_; } void PangoTextLayout::SetFont(std::shared_ptr<IFont> font) { Expects(font); - font_ = CheckPlatform<PangoFont>(font, GetPlatformId()); + font_ = CheckPlatform<PangoFont>(font, GetPlatformIdUtf8()); pango_layout_set_font_description(pango_layout_, font_->GetPangoFontDescription()); } diff --git a/src/platform/graphics/direct2d/Geometry.cpp b/src/platform/graphics/direct2d/Geometry.cpp index a2377400..45971b76 100644 --- a/src/platform/graphics/direct2d/Geometry.cpp +++ b/src/platform/graphics/direct2d/Geometry.cpp @@ -17,7 +17,7 @@ D2DGeometryBuilder::D2DGeometryBuilder(DirectGraphicsFactory* factory) void D2DGeometryBuilder::CheckValidation() { if (!IsValid()) - throw ReuseException(u"The geometry builder is already disposed."); + throw ReuseException("The geometry builder is already disposed."); } Point D2DGeometryBuilder::GetCurrentPosition() { diff --git a/src/platform/graphics/direct2d/ImageFactory.cpp b/src/platform/graphics/direct2d/ImageFactory.cpp index 113f70c8..b9e9221a 100644 --- a/src/platform/graphics/direct2d/ImageFactory.cpp +++ b/src/platform/graphics/direct2d/ImageFactory.cpp @@ -67,14 +67,14 @@ GUID ConvertImageFormatToGUID(ImageFormat format) { format_guid = GUID_ContainerFormatGif; break; default: - throw Exception(u"Unknown image format"); + throw Exception("Unknown image format"); } return format_guid; } void WinImageFactory::EncodeToStream(IImage* image, io::Stream* stream, ImageFormat format, float quality) { - auto direct_image = CheckPlatform<Direct2DImage>(image, GetPlatformId()); + auto direct_image = CheckPlatform<Direct2DImage>(image, GetPlatformIdUtf8()); Microsoft::WRL::ComPtr<IStream> com_stream( platform::win::ConvertStreamToComStream(stream)); @@ -139,8 +139,8 @@ void WinImageFactory::EncodeToStream(IImage* image, io::Stream* stream, } std::unique_ptr<IImage> WinImageFactory::CreateBitmap(int width, int height) { - if (width <= 0) throw Exception(u"Bitmap width must be greater than 0."); - if (height <= 0) throw Exception(u"Bitmap height must be greater than 0."); + if (width <= 0) throw Exception("Bitmap width must be greater than 0."); + if (height <= 0) throw Exception("Bitmap height must be greater than 0."); auto graphics_factory = GetDirectFactory(); diff --git a/src/platform/graphics/direct2d/Painter.cpp b/src/platform/graphics/direct2d/Painter.cpp index a505e46e..29ddcabb 100644 --- a/src/platform/graphics/direct2d/Painter.cpp +++ b/src/platform/graphics/direct2d/Painter.cpp @@ -55,7 +55,7 @@ void D2DDeviceContextPainter::Clear(const Color& color) { void D2DDeviceContextPainter::DrawLine(const Point& start, const Point& end, IBrush* brush, float width) { CheckValidation(); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->DrawLine(Convert(start), Convert(end), b->GetD2DBrushInterface(), width); } @@ -63,7 +63,7 @@ void D2DDeviceContextPainter::DrawLine(const Point& start, const Point& end, void D2DDeviceContextPainter::StrokeRectangle(const Rect& rectangle, IBrush* brush, float width) { CheckValidation(); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->DrawRectangle(Convert(rectangle), b->GetD2DBrushInterface(), width); } @@ -71,14 +71,14 @@ void D2DDeviceContextPainter::StrokeRectangle(const Rect& rectangle, void D2DDeviceContextPainter::FillRectangle(const Rect& rectangle, IBrush* brush) { CheckValidation(); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->FillRectangle(Convert(rectangle), b->GetD2DBrushInterface()); } void D2DDeviceContextPainter::StrokeEllipse(const Rect& outline_rect, IBrush* brush, float width) { CheckValidation(); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->DrawEllipse( D2D1::Ellipse(Convert(outline_rect.GetCenter()), outline_rect.width / 2.0f, outline_rect.height / 2.0f), @@ -87,7 +87,7 @@ void D2DDeviceContextPainter::StrokeEllipse(const Rect& outline_rect, void D2DDeviceContextPainter::FillEllipse(const Rect& outline_rect, IBrush* brush) { CheckValidation(); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->FillEllipse( D2D1::Ellipse(Convert(outline_rect.GetCenter()), outline_rect.width / 2.0f, outline_rect.height / 2.0f), @@ -97,16 +97,16 @@ void D2DDeviceContextPainter::FillEllipse(const Rect& outline_rect, void D2DDeviceContextPainter::StrokeGeometry(IGeometry* geometry, IBrush* brush, float width) { CheckValidation(); - const auto g = CheckPlatform<D2DGeometry>(geometry, GetPlatformId()); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto g = CheckPlatform<D2DGeometry>(geometry, GetPlatformIdUtf8()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->DrawGeometry(g->GetComInterface(), b->GetD2DBrushInterface(), width); } void D2DDeviceContextPainter::FillGeometry(IGeometry* geometry, IBrush* brush) { CheckValidation(); - const auto g = CheckPlatform<D2DGeometry>(geometry, GetPlatformId()); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto g = CheckPlatform<D2DGeometry>(geometry, GetPlatformIdUtf8()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->FillGeometry(g->GetComInterface(), b->GetD2DBrushInterface()); } @@ -115,15 +115,15 @@ void D2DDeviceContextPainter::DrawText(const Point& offset, ITextLayout* text_layout, IBrush* brush) { CheckValidation(); - const auto t = CheckPlatform<DWriteTextLayout>(text_layout, GetPlatformId()); - const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformId()); + const auto t = CheckPlatform<DWriteTextLayout>(text_layout, GetPlatformIdUtf8()); + const auto b = CheckPlatform<ID2DBrush>(brush, GetPlatformIdUtf8()); device_context_->DrawTextLayout(Convert(offset), t->GetComInterface(), b->GetD2DBrushInterface()); } void D2DDeviceContextPainter::DrawImage(const Point& offset, IImage* image) { CheckValidation(); - const auto i = CheckPlatform<Direct2DImage>(image, GetPlatformId()); + const auto i = CheckPlatform<Direct2DImage>(image, GetPlatformIdUtf8()); Microsoft::WRL::ComPtr<ID2D1DeviceContext> device_context; @@ -177,7 +177,7 @@ void D2DDeviceContextPainter::EndDraw() { void D2DDeviceContextPainter::CheckValidation() { if (!is_drawing_) { throw cru::platform::ReuseException( - u"Can't do that on painter after end drawing."); + "Can't do that on painter after end drawing."); } } } // namespace cru::platform::graphics::direct2d diff --git a/src/platform/graphics/direct2d/TextLayout.cpp b/src/platform/graphics/direct2d/TextLayout.cpp index 06bbcaa6..7a2074ec 100644 --- a/src/platform/graphics/direct2d/TextLayout.cpp +++ b/src/platform/graphics/direct2d/TextLayout.cpp @@ -14,7 +14,7 @@ DWriteTextLayout::DWriteTextLayout(DirectGraphicsFactory* factory, std::shared_ptr<IFont> font, String text) : DirectGraphicsResource(factory), text_(std::move(text)) { Expects(font); - font_ = CheckPlatform<DWriteFont>(font, GetPlatformId()); + font_ = CheckPlatform<DWriteFont>(font, GetPlatformIdUtf8()); ThrowIfFailed(factory->GetDWriteFactory()->CreateTextLayout( reinterpret_cast<const wchar_t*>(text_.c_str()), @@ -39,7 +39,7 @@ std::shared_ptr<IFont> DWriteTextLayout::GetFont() { } void DWriteTextLayout::SetFont(std::shared_ptr<IFont> font) { - font_ = CheckPlatform<DWriteFont>(font, GetPlatformId()); + font_ = CheckPlatform<DWriteFont>(font, GetPlatformIdUtf8()); ThrowIfFailed(GetDirectFactory()->GetDWriteFactory()->CreateTextLayout( reinterpret_cast<const wchar_t*>(text_.c_str()), static_cast<UINT32>(text_.size()), font_->GetComInterface(), max_width_, diff --git a/src/platform/graphics/quartz/Factory.cpp b/src/platform/graphics/quartz/Factory.cpp index 862c0966..5d5b48b5 100644 --- a/src/platform/graphics/quartz/Factory.cpp +++ b/src/platform/graphics/quartz/Factory.cpp @@ -33,7 +33,7 @@ std::unique_ptr<IFont> QuartzGraphicsFactory::CreateFont(String font_family, std::unique_ptr<ITextLayout> QuartzGraphicsFactory::CreateTextLayout( std::shared_ptr<IFont> font, String text) { - auto f = CheckPlatform<OsxCTFont>(font, GetPlatformId()); + auto f = CheckPlatform<OsxCTFont>(font, GetPlatformIdUtf8()); return std::make_unique<OsxCTTextLayout>(this, f, text); } diff --git a/src/platform/graphics/quartz/Image.cpp b/src/platform/graphics/quartz/Image.cpp index 966ce6be..d4ccd416 100644 --- a/src/platform/graphics/quartz/Image.cpp +++ b/src/platform/graphics/quartz/Image.cpp @@ -35,7 +35,7 @@ std::unique_ptr<IImage> QuartzImage::CreateWithRect(const Rect& rect) { std::unique_ptr<IPainter> QuartzImage::CreatePainter() { if (!buffer_) throw Exception( - u"Failed to create painter for image because failed to get its " + "Failed to create painter for image because failed to get its " u"buffer."); auto width = CGImageGetWidth(image_); diff --git a/src/platform/graphics/quartz/ImageFactory.cpp b/src/platform/graphics/quartz/ImageFactory.cpp index 93e452e1..62229bcb 100644 --- a/src/platform/graphics/quartz/ImageFactory.cpp +++ b/src/platform/graphics/quartz/ImageFactory.cpp @@ -39,17 +39,17 @@ static String GetImageFormatUniformTypeIdentifier(ImageFormat format) { case ImageFormat::Gif: return u"com.compuserve.gif"; default: - throw Exception(u"Unknown image format."); + throw Exception("Unknown image format."); } } void QuartzImageFactory::EncodeToStream(IImage* image, io::Stream* stream, ImageFormat format, float quality) { if (quality <= 0 || quality > 1) { - throw Exception(u"Invalid quality value."); + throw Exception("Invalid quality value."); } - auto quartz_image = CheckPlatform<QuartzImage>(image, GetPlatformId()); + auto quartz_image = CheckPlatform<QuartzImage>(image, GetPlatformIdUtf8()); auto cg_image = quartz_image->GetCGImage(); auto uti = ToCFString(GetImageFormatUniformTypeIdentifier(format)); @@ -67,7 +67,7 @@ void QuartzImageFactory::EncodeToStream(IImage* image, io::Stream* stream, CGImageDestinationAddImage(destination, cg_image, properties); if (!CGImageDestinationFinalize(destination)) { - throw Exception(u"Failed to finalize image destination."); + throw Exception("Failed to finalize image destination."); } CFRelease(quality_wrap); @@ -78,8 +78,8 @@ void QuartzImageFactory::EncodeToStream(IImage* image, io::Stream* stream, std::unique_ptr<IImage> QuartzImageFactory::CreateBitmap(int width, int height) { - if (width <= 0) throw Exception(u"Image width should be greater than 0."); - if (height <= 0) throw Exception(u"Image height should be greater than 0."); + if (width <= 0) throw Exception("Image width should be greater than 0."); + if (height <= 0) throw Exception("Image height should be greater than 0."); CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); diff --git a/src/platform/graphics/quartz/Painter.cpp b/src/platform/graphics/quartz/Painter.cpp index 69e187c3..fe0f5d43 100644 --- a/src/platform/graphics/quartz/Painter.cpp +++ b/src/platform/graphics/quartz/Painter.cpp @@ -66,7 +66,7 @@ void QuartzCGContextPainter::DrawLine(const Point& start, const Point& end, CGContextMoveToPoint(cg_context_, start.x, start.y); CGContextAddLineToPoint(cg_context_, end.x, end.y); - QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformIdUtf8()); b->Select(cg_context_); SetLineWidth(width); @@ -77,7 +77,7 @@ void QuartzCGContextPainter::StrokeRectangle(const Rect& rectangle, IBrush* brush, float width) { Validate(); - QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformIdUtf8()); b->Select(cg_context_); CGContextStrokeRectWithWidth(cg_context_, Convert(rectangle), width); } @@ -86,7 +86,7 @@ void QuartzCGContextPainter::FillRectangle(const Rect& rectangle, IBrush* brush) { Validate(); - QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformIdUtf8()); b->Select(cg_context_); CGContextFillRect(cg_context_, Convert(rectangle)); } @@ -95,7 +95,7 @@ void QuartzCGContextPainter::StrokeEllipse(const Rect& outline_rect, IBrush* brush, float width) { Validate(); - QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformIdUtf8()); b->Select(cg_context_); SetLineWidth(width); @@ -106,7 +106,7 @@ void QuartzCGContextPainter::FillEllipse(const Rect& outline_rect, IBrush* brush) { Validate(); - QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformIdUtf8()); b->Select(cg_context_); CGContextFillEllipseInRect(cg_context_, Convert(outline_rect)); } @@ -115,8 +115,8 @@ void QuartzCGContextPainter::StrokeGeometry(IGeometry* geometry, IBrush* brush, float width) { Validate(); - QuartzGeometry* g = CheckPlatform<QuartzGeometry>(geometry, GetPlatformId()); - QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + QuartzGeometry* g = CheckPlatform<QuartzGeometry>(geometry, GetPlatformIdUtf8()); + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformIdUtf8()); b->Select(cg_context_); SetLineWidth(width); @@ -129,8 +129,8 @@ void QuartzCGContextPainter::StrokeGeometry(IGeometry* geometry, IBrush* brush, void QuartzCGContextPainter::FillGeometry(IGeometry* geometry, IBrush* brush) { Validate(); - QuartzGeometry* g = CheckPlatform<QuartzGeometry>(geometry, GetPlatformId()); - QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformId()); + QuartzGeometry* g = CheckPlatform<QuartzGeometry>(geometry, GetPlatformIdUtf8()); + QuartzBrush* b = CheckPlatform<QuartzBrush>(brush, GetPlatformIdUtf8()); b->Select(cg_context_); CGContextBeginPath(cg_context_); @@ -142,7 +142,7 @@ void QuartzCGContextPainter::DrawText(const Point& offset, ITextLayout* text_layout, IBrush* brush) { Validate(); - auto tl = CheckPlatform<OsxCTTextLayout>(text_layout, GetPlatformId()); + auto tl = CheckPlatform<OsxCTTextLayout>(text_layout, GetPlatformIdUtf8()); Color color; @@ -169,7 +169,7 @@ void QuartzCGContextPainter::DrawText(const Point& offset, void QuartzCGContextPainter::DrawImage(const Point& offset, IImage* image) { Validate(); - auto i = CheckPlatform<QuartzImage>(image, GetPlatformId()); + auto i = CheckPlatform<QuartzImage>(image, GetPlatformIdUtf8()); auto cg_image = i->GetCGImage(); @@ -225,6 +225,6 @@ void QuartzCGContextPainter::DoEndDraw() { void QuartzCGContextPainter::Validate() { if (cg_context_ == nullptr) - throw ReuseException(u"QuartzCGContextPainter has already be released."); + throw ReuseException("QuartzCGContextPainter has already be released."); } } // namespace cru::platform::graphics::quartz diff --git a/src/platform/graphics/quartz/TextLayout.cpp b/src/platform/graphics/quartz/TextLayout.cpp index 8c573c7a..41a2f176 100644 --- a/src/platform/graphics/quartz/TextLayout.cpp +++ b/src/platform/graphics/quartz/TextLayout.cpp @@ -31,7 +31,7 @@ OsxCTTextLayout::~OsxCTTextLayout() { } void OsxCTTextLayout::SetFont(std::shared_ptr<IFont> font) { - font_ = CheckPlatform<OsxCTFont>(font, GetPlatformId()); + font_ = CheckPlatform<OsxCTFont>(font, GetPlatformIdUtf8()); RecreateFrame(); } diff --git a/src/platform/graphics/web_canvas/Painter.cpp b/src/platform/graphics/web_canvas/Painter.cpp index c9184165..f928de35 100644 --- a/src/platform/graphics/web_canvas/Painter.cpp +++ b/src/platform/graphics/web_canvas/Painter.cpp @@ -94,7 +94,7 @@ void WebCanvasPainter::SetFillStyle(IBrush* brush) { } WebCanvasBrush* WebCanvasPainter::ConvertBrush(IBrush* brush) const { - return CheckPlatform<WebCanvasBrush>(brush, GetPlatformId()); + return CheckPlatform<WebCanvasBrush>(brush, GetPlatformIdUtf8()); } WebCanvasRef WebCanvasPainter::GetCanvas() { diff --git a/src/platform/gui/UiApplication.cpp b/src/platform/gui/UiApplication.cpp index 7bc27847..ac93a57d 100644 --- a/src/platform/gui/UiApplication.cpp +++ b/src/platform/gui/UiApplication.cpp @@ -24,11 +24,11 @@ IMenu* IUiApplication::GetApplicationMenu() { return nullptr; } std::optional<String> IUiApplication::ShowSaveDialog( SaveDialogOptions options) { - throw Exception(u"Not implemented."); + throw Exception("Not implemented."); } std::optional<std::vector<String>> IUiApplication::ShowOpenDialog( OpenDialogOptions options) { - throw Exception(u"Not implemented."); + throw Exception("Not implemented."); } } // namespace cru::platform::gui diff --git a/src/platform/gui/osx/Cursor.mm b/src/platform/gui/osx/Cursor.mm index ec364fa7..9c25fdbd 100644 --- a/src/platform/gui/osx/Cursor.mm +++ b/src/platform/gui/osx/Cursor.mm @@ -24,7 +24,7 @@ OsxCursorPrivate::OsxCursorPrivate(OsxCursor* cursor, SystemCursorType cursor_ty ns_cursor_ = [NSCursor IBeamCursor]; break; default: - throw Exception(u"Unknown system cursor type."); + throw Exception("Unknown system cursor type."); } } @@ -87,7 +87,7 @@ std::shared_ptr<ICursor> OsxCursorManager::GetSystemCursor(SystemCursorType type case SystemCursorType::IBeam: return p_->ibeam_cursor_; default: - throw Exception(u"Unknown system cursor type."); + throw Exception("Unknown system cursor type."); } } } // namespace cru::platform::gui::osx diff --git a/src/platform/gui/osx/Keyboard.mm b/src/platform/gui/osx/Keyboard.mm index 8a419009..da4c85f0 100644 --- a/src/platform/gui/osx/Keyboard.mm +++ b/src/platform/gui/osx/Keyboard.mm @@ -260,7 +260,7 @@ NSString* ConvertKeyCodeToKeyEquivalent(KeyCode key_code) { CRU_DEFINE_KEYCODE_MAP(KeyCode::Backspace, @"\x08") CRU_DEFINE_KEYCODE_MAP(KeyCode::Delete, @"\x7F") default: - throw Exception(u"Failed to convert key code to key equivalent string."); + throw Exception("Failed to convert key code to key equivalent string."); } #undef CRU_DEFINE_KEYCODE_MAP } diff --git a/src/platform/gui/osx/Window.mm b/src/platform/gui/osx/Window.mm index 6559cf70..7381ca55 100644 --- a/src/platform/gui/osx/Window.mm +++ b/src/platform/gui/osx/Window.mm @@ -64,7 +64,7 @@ void OsxWindowPrivate::OnWindowWillClose() { bool quit = true; for (auto window : all_window) { - auto w = CheckPlatform<OsxWindow>(window, osx_window_->GetPlatformId()); + auto w = CheckPlatform<OsxWindow>(window, osx_window_->GetPlatformIdUtf8()); if (w->p_->window_) { quit = false; break; @@ -179,7 +179,7 @@ void OsxWindowPrivate::CreateWindow() { [window_ setDelegate:window_delegate_]; if (parent_) { - auto parent = CheckPlatform<OsxWindow>(parent_, this->osx_window_->GetPlatformId()); + auto parent = CheckPlatform<OsxWindow>(parent_, this->osx_window_->GetPlatformIdUtf8()); [window_ setParentWindow:parent->p_->window_]; } @@ -231,7 +231,7 @@ void OsxWindow::Close() { INativeWindow* OsxWindow::GetParent() { return p_->parent_; } void OsxWindow::SetParent(INativeWindow* parent) { - auto p = CheckPlatform<OsxWindow>(parent, GetPlatformId()); + auto p = CheckPlatform<OsxWindow>(parent, GetPlatformIdUtf8()); p_->parent_ = parent; @@ -366,7 +366,7 @@ bool OsxWindow::CaptureMouse() { return true; } bool OsxWindow::ReleaseMouse() { return true; } void OsxWindow::SetCursor(std::shared_ptr<ICursor> cursor) { - p_->cursor_ = CheckPlatform<OsxCursor>(cursor, GetPlatformId()); + p_->cursor_ = CheckPlatform<OsxCursor>(cursor, GetPlatformIdUtf8()); p_->UpdateCursor(); } diff --git a/src/platform/gui/win/Window.cpp b/src/platform/gui/win/Window.cpp index eeb2cde4..5739d0f3 100644 --- a/src/platform/gui/win/Window.cpp +++ b/src/platform/gui/win/Window.cpp @@ -79,7 +79,7 @@ void WinNativeWindow::Close() { } void WinNativeWindow::SetParent(INativeWindow* parent) { - auto p = CheckPlatform<WinNativeWindow>(parent, GetPlatformId()); + auto p = CheckPlatform<WinNativeWindow>(parent, GetPlatformIdUtf8()); parent_window_ = p; if (hwnd_) { @@ -228,7 +228,7 @@ void WinNativeWindow::SetCursor(std::shared_ptr<ICursor> cursor) { throw std::runtime_error("Can't use a nullptr as cursor."); } - cursor_ = CheckPlatform<WinCursor>(cursor, GetPlatformId()); + cursor_ = CheckPlatform<WinCursor>(cursor, GetPlatformIdUtf8()); if (hwnd_) return; diff --git a/src/platform/gui/xcb/Window.cpp b/src/platform/gui/xcb/Window.cpp index 6a5857fc..6458046b 100644 --- a/src/platform/gui/xcb/Window.cpp +++ b/src/platform/gui/xcb/Window.cpp @@ -271,7 +271,7 @@ bool XcbWindow::ReleaseMouse() { void XcbWindow::SetCursor(std::shared_ptr<ICursor> cursor) { if (!xcb_window_) return; - auto xcb_cursor = CheckPlatform<XcbCursor>(cursor, GetPlatformId()); + auto xcb_cursor = CheckPlatform<XcbCursor>(cursor, GetPlatformIdUtf8()); cursor_ = xcb_cursor; DoSetCursor(*xcb_window_, xcb_cursor.get()); } |
