Compare commits
8 Commits
3a3bc69b8e
...
5c4ff3776d
Author | SHA1 | Date |
---|---|---|
Pascal Abresch | 5c4ff3776d | |
Adrien Destugues | 0f1e3574c4 | |
Adrien Destugues | e5f2c437f1 | |
Adrien Destugues | 4e4c6a7064 | |
Jessica Hamilton | ae44f6b724 | |
Jessica Hamilton | 80f5dc160e | |
Adrien Destugues | 8e30dd7ddf | |
Adrien Destugues | c398d4ac88 |
|
@ -39,26 +39,16 @@ namespace WebCore {
|
|||
|
||||
bool GlyphPage::fill(UChar* buffer, unsigned bufferLength)
|
||||
{
|
||||
bool haveGlyphs[bufferLength];
|
||||
bool hasOneGlyph = false;
|
||||
|
||||
const BFont* font = m_font.platformData().font();
|
||||
|
||||
// Unfortunately our API expects utf-8 as input...
|
||||
StringView v(buffer, bufferLength);
|
||||
font->GetHasGlyphs(v.utf8().data(), bufferLength, haveGlyphs);
|
||||
|
||||
UTF16UChar32Iterator iterator(buffer, bufferLength);
|
||||
for (unsigned i = 0;; i++) {
|
||||
UChar32 character = iterator.next();
|
||||
if (character == iterator.end())
|
||||
break;
|
||||
|
||||
hasOneGlyph = true;
|
||||
setGlyphForIndex(i, character);
|
||||
}
|
||||
|
||||
return hasOneGlyph;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace WebCore
|
||||
|
|
|
@ -69,7 +69,7 @@ void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness
|
|||
else if (m_state.fillGradient) {
|
||||
m_state.fillGradient->fill(*this, rect);
|
||||
} else
|
||||
m_view->FillRect(rect);
|
||||
m_view->FillRect(rect, B_SOLID_LOW);
|
||||
|
||||
// TODO: Support gradients
|
||||
if (strokeStyle() != NoStroke && borderThickness > 0.0f && strokeColor().isVisible())
|
||||
|
@ -80,6 +80,11 @@ void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness
|
|||
}
|
||||
|
||||
void GraphicsContextHaiku::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
|
||||
{
|
||||
drawBitmap(image.platformImage().get(), imageSize, destRect, srcRect, options);
|
||||
}
|
||||
|
||||
void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
|
||||
{
|
||||
m_view->PushState();
|
||||
setCompositeOperation(options.compositeOperator());
|
||||
|
@ -94,7 +99,7 @@ void GraphicsContextHaiku::drawNativeImage(NativeImage& image, const FloatSize&
|
|||
if (options.interpolationQuality() > InterpolationQuality::Low)
|
||||
flags |= B_FILTER_BITMAP_BILINEAR;
|
||||
|
||||
m_view->DrawBitmapAsync(image.platformImage().get(), BRect(srcRect), BRect(destRect), flags);
|
||||
m_view->DrawBitmapAsync(image, BRect(srcRect), BRect(destRect), flags);
|
||||
|
||||
m_view->PopState();
|
||||
}
|
||||
|
@ -289,20 +294,27 @@ void GraphicsContextHaiku::clipPath(const Path& path, WindRule windRule)
|
|||
|
||||
|
||||
void GraphicsContextHaiku::drawPattern(NativeImage& image, const WebCore::FloatSize& size, const FloatRect& destRect,
|
||||
const FloatRect& tileRect, const AffineTransform& transform,
|
||||
const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& options)
|
||||
{
|
||||
drawBitmap(image.platformImage().get(), size, destRect, tileRect, transform, phase, spacing, options);
|
||||
}
|
||||
|
||||
void GraphicsContextHaiku::drawBitmap(BBitmap* image, const WebCore::FloatSize& size, const FloatRect& destRect,
|
||||
const FloatRect& tileRect, const AffineTransform&,
|
||||
const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&)
|
||||
{
|
||||
if (!image.platformImage()->IsValid()) // If the image hasn't fully loaded.
|
||||
if (!image->IsValid()) // If the image hasn't fully loaded.
|
||||
return;
|
||||
|
||||
// Figure out if the image has any alpha transparency, we can use faster drawing if not
|
||||
bool hasAlpha = false;
|
||||
|
||||
uint8* bits = reinterpret_cast<uint8*>(image.platformImage()->Bits());
|
||||
uint32 width = image.platformImage()->Bounds().IntegerWidth() + 1;
|
||||
uint32 height = image.platformImage()->Bounds().IntegerHeight() + 1;
|
||||
uint8* bits = reinterpret_cast<uint8*>(image->Bits());
|
||||
uint32 width = image->Bounds().IntegerWidth() + 1;
|
||||
uint32 height = image->Bounds().IntegerHeight() + 1;
|
||||
|
||||
uint32 bytesPerRow = image.platformImage()->BytesPerRow();
|
||||
uint32 bytesPerRow = image->BytesPerRow();
|
||||
for (uint32 y = 0; y < height && !hasAlpha; y++) {
|
||||
uint8* p = bits;
|
||||
for (uint32 x = 0; x < width && !hasAlpha; x++) {
|
||||
|
@ -325,7 +337,7 @@ void GraphicsContextHaiku::drawPattern(NativeImage& image, const WebCore::FloatS
|
|||
phaseOffsetX -= std::trunc(phaseOffsetX / tileRect.width()) * tileRect.width();
|
||||
phaseOffsetY -= std::trunc(phaseOffsetY / tileRect.height()) * tileRect.height();
|
||||
m_view->DrawTiledBitmapAsync(
|
||||
image.platformImage().get(), destRect, BPoint(phaseOffsetX, phaseOffsetY));
|
||||
image, destRect, BPoint(phaseOffsetX, phaseOffsetY));
|
||||
m_view->PopState();
|
||||
}
|
||||
|
||||
|
@ -544,11 +556,13 @@ void GraphicsContextHaiku::updateState(const GraphicsContextState& state, Graphi
|
|||
m_strokeStyle = B_SOLID_HIGH;
|
||||
break;
|
||||
case DottedStroke:
|
||||
m_view->SetLowColor(B_TRANSPARENT_COLOR);
|
||||
m_strokeStyle = B_MIXED_COLORS;
|
||||
break;
|
||||
case DashedStroke:
|
||||
// FIXME: use a better dashed stroke!
|
||||
notImplemented();
|
||||
m_view->SetLowColor(B_TRANSPARENT_COLOR);
|
||||
m_strokeStyle = B_MIXED_COLORS;
|
||||
break;
|
||||
case NoStroke:
|
||||
|
|
|
@ -87,6 +87,8 @@ public:
|
|||
void save() override;
|
||||
void restore() override;
|
||||
|
||||
void drawBitmap(BBitmap*, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { });
|
||||
void drawBitmap(BBitmap*, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { });
|
||||
BView* m_view;
|
||||
pattern m_strokeStyle;
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
BView* m_view;
|
||||
GraphicsContext* m_context;
|
||||
|
||||
RefPtr<NativeImage> m_image;
|
||||
PlatformImagePtr m_image;
|
||||
};
|
||||
|
||||
} // namespace WebCore
|
||||
|
|
|
@ -51,22 +51,21 @@ namespace WebCore {
|
|||
ImageBufferData::ImageBufferData(const IntSize& size)
|
||||
: m_view(NULL)
|
||||
, m_context(NULL)
|
||||
, m_image(NativeImage::create(new BitmapRef(BRect(0, 0, size.width() - 1, size.height() - 1), B_RGBA32, true)))
|
||||
, m_image(adoptRef(new BitmapRef(BRect(0, 0, size.width() - 1, size.height() - 1), B_RGBA32, true)))
|
||||
{
|
||||
// Always keep the bitmap locked, we are the only client.
|
||||
PlatformImagePtr bitmap = m_image->platformImage();
|
||||
bitmap->Lock();
|
||||
m_image->Lock();
|
||||
if(size.isEmpty())
|
||||
return;
|
||||
|
||||
if (!bitmap->IsLocked() || !bitmap->IsValid())
|
||||
if (!m_image->IsLocked() || !m_image->IsValid())
|
||||
return;
|
||||
|
||||
m_view = new BView(bitmap->Bounds(), "WebKit ImageBufferData", 0, 0);
|
||||
bitmap->AddChild(m_view);
|
||||
m_view = new BView(m_image->Bounds(), "WebKit ImageBufferData", 0, 0);
|
||||
m_image->AddChild(m_view);
|
||||
|
||||
// Fill with completely transparent color.
|
||||
memset(bitmap->Bits(), 0, bitmap->BitsLength());
|
||||
memset(m_image->Bits(), 0, m_image->BitsLength());
|
||||
|
||||
// Since ImageBuffer is used mainly for Canvas, explicitly initialize
|
||||
// its view's graphics state with the corresponding canvas defaults
|
||||
|
@ -90,10 +89,10 @@ ImageBufferData::~ImageBufferData()
|
|||
WTF::RefPtr<WebCore::NativeImage> ImageBufferHaikuSurfaceBackend::copyNativeImage(WebCore::BackingStoreCopy doCopy) const
|
||||
{
|
||||
if (doCopy == DontCopyBackingStore) {
|
||||
PlatformImagePtr ref = m_data.m_image->platformImage();
|
||||
PlatformImagePtr ref = m_data.m_image;
|
||||
return NativeImage::create(std::move(ref));
|
||||
} else {
|
||||
BitmapRef* ref = new BitmapRef(*(BBitmap*)m_data.m_image->platformImage().get());
|
||||
BitmapRef* ref = new BitmapRef(*(BBitmap*)m_data.m_image.get());
|
||||
return NativeImage::create(ref);
|
||||
}
|
||||
}
|
||||
|
@ -143,8 +142,9 @@ RefPtr<Image> ImageBufferHaikuSurfaceBackend::copyImage(BackingStoreCopy copyBeh
|
|||
return BitmapImage::create(copyNativeImage(copyBehavior));
|
||||
}
|
||||
|
||||
void ImageBufferHaikuSurfaceBackend::draw(GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect,
|
||||
const ImagePaintingOptions& options)
|
||||
void ImageBufferHaikuSurfaceBackend::draw(GraphicsContext& destContext,
|
||||
const FloatRect& destRect, const FloatRect& srcRect,
|
||||
const ImagePaintingOptions& options)
|
||||
{
|
||||
if (!m_data.m_view)
|
||||
return;
|
||||
|
@ -154,8 +154,9 @@ void ImageBufferHaikuSurfaceBackend::draw(GraphicsContext& destContext, const Fl
|
|||
// We're drawing into our own buffer. In order for this to work, we need to copy the source buffer first.
|
||||
RefPtr<Image> copy = copyImage(CopyBackingStore, PreserveResolution::Yes);
|
||||
destContext.drawImage(*copy.get(), destRect, srcRect, options);
|
||||
} else
|
||||
destContext.drawNativeImage(*m_data.m_image.get(), srcRect.size(), destRect, srcRect, options);
|
||||
} else {
|
||||
dynamic_cast<GraphicsContextHaiku&>(destContext).drawBitmap(m_data.m_image.get(), srcRect.size(), destRect, srcRect, options);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageBufferHaikuSurfaceBackend::drawPattern(GraphicsContext& destContext,
|
||||
|
@ -172,23 +173,23 @@ void ImageBufferHaikuSurfaceBackend::drawPattern(GraphicsContext& destContext,
|
|||
RefPtr<Image> copy = copyImage(CopyBackingStore, PreserveResolution::Yes);
|
||||
copy->drawPattern(destContext, destRect, srcRect, patternTransform, phase, size, options.compositeOperator());
|
||||
} else
|
||||
destContext.drawPattern(*m_data.m_image.get(), srcRect.size(), destRect, srcRect, patternTransform, phase, size, options.compositeOperator());
|
||||
dynamic_cast<GraphicsContextHaiku&>(destContext).drawBitmap(m_data.m_image.get(), srcRect.size(), destRect, srcRect, patternTransform, phase, size, options.compositeOperator());
|
||||
}
|
||||
|
||||
|
||||
std::optional<PixelBuffer> ImageBufferHaikuSurfaceBackend::getPixelBuffer(const PixelBufferFormat& outputFormat, const IntRect& srcRect) const
|
||||
{
|
||||
return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, m_data.m_image->platformImage()->Bits());
|
||||
return ImageBufferBackend::getPixelBuffer(outputFormat, srcRect, m_data.m_image->Bits());
|
||||
}
|
||||
|
||||
void ImageBufferHaikuSurfaceBackend::putPixelBuffer(const PixelBuffer& imageData, const IntRect& sourceRect, const IntPoint& destPoint, AlphaPremultiplication premultiplication)
|
||||
{
|
||||
ImageBufferBackend::putPixelBuffer(imageData, sourceRect, destPoint, premultiplication, m_data.m_image->platformImage()->Bits());
|
||||
ImageBufferBackend::putPixelBuffer(imageData, sourceRect, destPoint, premultiplication, m_data.m_image->Bits());
|
||||
}
|
||||
|
||||
unsigned ImageBufferHaikuSurfaceBackend::bytesPerRow() const
|
||||
{
|
||||
return m_data.m_image->platformImage()->BytesPerRow();
|
||||
return m_data.m_image->BytesPerRow();
|
||||
}
|
||||
|
||||
// TODO: PreserveResolution
|
||||
|
@ -250,7 +251,7 @@ Vector<uint8_t> ImageBufferHaikuSurfaceBackend::toData(const String& mimeType, s
|
|||
|
||||
BMallocIO translatedStream;
|
||||
// BBitmapStream doesn't take "const Bitmap*"...
|
||||
BBitmapStream bitmapStream(m_data.m_image->platformImage().get());
|
||||
BBitmapStream bitmapStream(m_data.m_image.get());
|
||||
BBitmap* tmp = NULL;
|
||||
if (roster->Translate(&bitmapStream, 0, 0, &translatedStream, translatorType,
|
||||
B_TRANSLATOR_BITMAP, mimeType.utf8().data()) != B_OK) {
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
background-color: #121212;
|
||||
}
|
||||
body {
|
||||
color: #CCC
|
||||
}
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
body {
|
||||
color: #333333
|
||||
}
|
||||
}
|
||||
body {
|
||||
color: #333333;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
|
|
@ -1090,8 +1090,8 @@ void IconDatabase::performURLImport()
|
|||
// we use it or not). This code works anyway because the IconDatabase downloads icons again if they are older than 4 days,
|
||||
// so if the timestamp goes back in time more than those 30 days we can be sure that the icon was not used at all.
|
||||
auto query = m_syncDB.prepareStatement("SELECT PageURL.url, IconInfo.url, IconInfo.stamp FROM PageURL INNER JOIN IconInfo ON PageURL.iconID=IconInfo.iconID WHERE IconInfo.stamp > (?) ;"_s);
|
||||
query->bindInt(1, floor((WallTime::now() - notUsedIconExpirationTime).secondsSinceEpoch().seconds()));
|
||||
if (!query) {
|
||||
if (!query || query->bindInt(1, floor((WallTime::now() - notUsedIconExpirationTime).secondsSinceEpoch().seconds())) != SQLITE_OK)
|
||||
{
|
||||
LOG_ERROR("Unable to prepare icon url import query");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ include(VersioningUtils)
|
|||
|
||||
SET(PROJECT_VERSION_MAJOR 1)
|
||||
SET(PROJECT_VERSION_MINOR 8)
|
||||
SET(PROJECT_VERSION_PATCH 0)
|
||||
SET(PROJECT_VERSION_PATCH 2)
|
||||
SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
|
||||
add_definitions(-DHAIKU_WEBKIT_VERSION=\"${PROJECT_VERSION}\")
|
||||
|
|
Loading…
Reference in New Issue