aboutsummaryrefslogtreecommitdiff
path: root/src/platform/graphics
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-06-15 01:02:30 +0800
committerYuqian Yang <crupest@crupest.life>2025-06-15 01:02:30 +0800
commitd868d7b0d463ede80b761f87f10d4e25f52989c3 (patch)
treeeb61e339f15b6b8b4cc1a246b4281631e701d6e0 /src/platform/graphics
parent7ac84c9d200d43f50155ce1e8316ada12043f7a8 (diff)
downloadcru-d868d7b0d463ede80b761f87f10d4e25f52989c3.tar.gz
cru-d868d7b0d463ede80b761f87f10d4e25f52989c3.tar.bz2
cru-d868d7b0d463ede80b761f87f10d4e25f52989c3.zip
Remove some files of OSX. Symbol Point is conflict and needs to be
fixed.
Diffstat (limited to 'src/platform/graphics')
-rw-r--r--src/platform/graphics/quartz/Font.cpp10
-rw-r--r--src/platform/graphics/quartz/ImageFactory.cpp8
-rw-r--r--src/platform/graphics/quartz/TextLayout.cpp12
3 files changed, 7 insertions, 23 deletions
diff --git a/src/platform/graphics/quartz/Font.cpp b/src/platform/graphics/quartz/Font.cpp
index 62052b0a..8821062f 100644
--- a/src/platform/graphics/quartz/Font.cpp
+++ b/src/platform/graphics/quartz/Font.cpp
@@ -1,26 +1,20 @@
#include "cru/platform/graphics/quartz/Font.h"
-#include "cru/platform/osx/Convert.h"
-#include "cru/platform/graphics/quartz/Convert.h"
#include "cru/platform/graphics/quartz/Resource.h"
namespace cru::platform::graphics::quartz {
-using cru::platform::osx::Convert;
-
OsxCTFont::OsxCTFont(IGraphicsFactory* graphics_factory, const String& name,
float size)
: OsxQuartzResource(graphics_factory), name_(name) {
- CFStringRef n = Convert(name);
+ auto n = name.ToCFStringRef();
if (name.empty()) {
ct_font_ =
CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, size, nullptr);
} else {
- ct_font_ = CTFontCreateWithName(n, size, nullptr);
+ ct_font_ = CTFontCreateWithName(n.ref, size, nullptr);
}
Ensures(ct_font_);
-
- CFRelease(n);
}
OsxCTFont::~OsxCTFont() { CFRelease(ct_font_); }
diff --git a/src/platform/graphics/quartz/ImageFactory.cpp b/src/platform/graphics/quartz/ImageFactory.cpp
index 0557afa9..1f354155 100644
--- a/src/platform/graphics/quartz/ImageFactory.cpp
+++ b/src/platform/graphics/quartz/ImageFactory.cpp
@@ -1,6 +1,5 @@
#include "cru/platform/graphics/quartz/ImageFactory.h"
#include "cru/base/Exception.h"
-#include "cru/base/platform/osx/Convert.h"
#include "cru/platform/graphics/quartz/Convert.h"
#include "cru/platform/graphics/quartz/Image.h"
#include "cru/platform/Check.h"
@@ -9,8 +8,6 @@
#include <ImageIO/ImageIO.h>
namespace cru::platform::graphics::quartz {
-using cru::platform::osx::Convert;
-
QuartzImageFactory::QuartzImageFactory(IGraphicsFactory* graphics_factory)
: OsxQuartzResource(graphics_factory) {}
@@ -54,10 +51,10 @@ void QuartzImageFactory::EncodeToStream(IImage* image, io::Stream* stream,
auto quartz_image = CheckPlatform<QuartzImage>(image, GetPlatformId());
auto cg_image = quartz_image->GetCGImage();
- CFStringRef uti = Convert(GetImageFormatUniformTypeIdentifier(format));
+ auto uti = GetImageFormatUniformTypeIdentifier(format).ToCFStringRef();
CGDataConsumerRef data_consumer = ConvertStreamToCGDataConsumer(stream);
CGImageDestinationRef destination =
- CGImageDestinationCreateWithDataConsumer(data_consumer, uti, 1, nullptr);
+ CGImageDestinationCreateWithDataConsumer(data_consumer, uti.ref, 1, nullptr);
CFMutableDictionaryRef properties =
CFDictionaryCreateMutable(nullptr, 0, nullptr, nullptr);
@@ -76,7 +73,6 @@ void QuartzImageFactory::EncodeToStream(IImage* image, io::Stream* stream,
CFRelease(properties);
CFRelease(destination);
CFRelease(data_consumer);
- CFRelease(uti);
}
std::unique_ptr<IImage> QuartzImageFactory::CreateBitmap(int width,
diff --git a/src/platform/graphics/quartz/TextLayout.cpp b/src/platform/graphics/quartz/TextLayout.cpp
index 9e18ac85..1d49d6c0 100644
--- a/src/platform/graphics/quartz/TextLayout.cpp
+++ b/src/platform/graphics/quartz/TextLayout.cpp
@@ -1,19 +1,14 @@
#include "cru/platform/graphics/quartz/TextLayout.h"
#include "cru/base/Base.h"
#include "cru/base/Format.h"
-#include "cru/base/StringUtil.h"
-#include "cru/platform/osx/Convert.h"
#include "cru/platform/graphics/quartz/Convert.h"
#include "cru/platform/graphics/quartz/Resource.h"
#include "cru/platform/Check.h"
#include "cru/platform/graphics/Base.h"
-#include <algorithm>
#include <limits>
namespace cru::platform::graphics::quartz {
-using cru::platform::osx::Convert;
-
OsxCTTextLayout::OsxCTTextLayout(IGraphicsFactory* graphics_factory,
std::shared_ptr<OsxCTFont> font,
const String& str)
@@ -76,15 +71,14 @@ void OsxCTTextLayout::DoSetText(String text) {
}
}
- CFStringRef s = Convert(actual_text_);
+ auto s = actual_text_.ToCFStringRef();
cf_attributed_text_ = CFAttributedStringCreateMutable(nullptr, 0);
- CFAttributedStringReplaceString(cf_attributed_text_, CFRangeMake(0, 0), s);
+ CFAttributedStringReplaceString(cf_attributed_text_, CFRangeMake(0, 0), s.ref);
Ensures(cf_attributed_text_);
CFAttributedStringSetAttribute(
cf_attributed_text_,
CFRangeMake(0, CFAttributedStringGetLength(cf_attributed_text_)),
kCTFontAttributeName, font_->GetCTFont());
- CFRelease(s);
}
void OsxCTTextLayout::SetText(String new_text) {
@@ -411,7 +405,7 @@ std::vector<CGRect> OsxCTTextLayout::DoTextRangeRect(
auto line = lines_[i];
auto line_origin = line_origins_[i];
- Range range = Convert(CTLineGetStringRange(line));
+ Range range = Range::FromCFRange(CTLineGetStringRange(line));
range = range.CoerceInto(r.GetStart(), r.GetEnd());
if (range.count) {