Skip to content

Commit

Permalink
Fix build after merge.
Browse files Browse the repository at this point in the history
Large rework of image/BBitmap handling, making things a bit simpler.
  • Loading branch information
pulkomandy committed Nov 28, 2020
1 parent 339aa25 commit cdeafd2
Show file tree
Hide file tree
Showing 24 changed files with 193 additions and 330 deletions.
5 changes: 2 additions & 3 deletions Source/WebCore/PlatformHaiku.cmake
Expand Up @@ -46,7 +46,6 @@ list(APPEND WebCore_SOURCES
platform/haiku/PlatformKeyboardEventHaiku.cpp
platform/haiku/PlatformMouseEventHaiku.cpp
platform/haiku/PlatformScreenHaiku.cpp
platform/haiku/PlatformWheelEventHaiku.cpp
platform/haiku/PopupMenuHaiku.cpp
platform/haiku/RenderThemeHaiku.cpp
platform/haiku/ScrollbarThemeHaiku.cpp
Expand All @@ -59,6 +58,7 @@ list(APPEND WebCore_SOURCES
platform/posix/SharedBufferPOSIX.cpp

platform/graphics/WOFFFileFormat.cpp
platform/graphics/displaylists/DisplayListDrawGlyphsRecorderHaiku.cpp

platform/graphics/haiku/AffineTransformHaiku.cpp
platform/graphics/haiku/BitmapImageHaiku.cpp
Expand All @@ -83,9 +83,9 @@ list(APPEND WebCore_SOURCES
platform/graphics/haiku/IntRectHaiku.cpp
platform/graphics/haiku/IntSizeHaiku.cpp
platform/graphics/haiku/MediaPlayerPrivateHaiku.cpp
platform/graphics/haiku/NativeImageHaiku.cpp
platform/graphics/haiku/PathHaiku.cpp
platform/graphics/haiku/SimpleFontDataHaiku.cpp
platform/graphics/haiku/StillImageHaiku.cpp
platform/graphics/haiku/TileHaiku.cpp
platform/graphics/haiku/TiledBackingStoreHaiku.cpp
platform/graphics/haiku/GraphicsLayerHaiku.cpp
Expand Down Expand Up @@ -355,7 +355,6 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/DateTimeChooser.h
platform/DateTimeChooserClient.h

platform/graphics/haiku/StillImageHaiku.h
platform/graphics/haiku/ImageBufferDataHaiku.h
platform/graphics/Image.h
)
4 changes: 2 additions & 2 deletions Source/WebCore/page/haiku/EventHandlerHaiku.cpp
Expand Up @@ -96,12 +96,12 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const
return false;
}

bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& event, Widget& widget)
bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& event, Widget& widget, OptionSet<WheelEventProcessingSteps> processingSteps)
{
if (!widget.isFrameView())
return false;

return static_cast<FrameView&>(widget).frame().eventHandler().handleWheelEvent(event);
return static_cast<FrameView&>(widget).frame().eventHandler().handleWheelEvent(event, processingSteps);
}

bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame& subframe)
Expand Down
29 changes: 29 additions & 0 deletions Source/WebCore/platform/graphics/PlatformImage.h
Expand Up @@ -32,6 +32,8 @@ typedef struct CGImage* CGImageRef;
#include "RefPtrCairo.h"
#elif USE(WINGDI)
#include "SharedBitmap.h"
#elif USE(HAIKU)
#include <Bitmap.h>
#endif

namespace WebCore {
Expand All @@ -44,6 +46,33 @@ using PlatformImagePtr = COMPtr<ID2D1Bitmap>;
using PlatformImagePtr = RefPtr<cairo_surface_t>;
#elif USE(WINGDI)
using PlatformImagePtr = RefPtr<SharedBitmap>;
#elif USE(HAIKU)
class BitmapRef: public BBitmap, public RefCounted<BitmapRef>
{
public:
BitmapRef(BRect r, uint32 f, color_space c, int32 b)
: BBitmap(r, f, c, b)
{
}

BitmapRef(BRect r, color_space c, bool v)
: BBitmap(r, c, v)
{
}

BitmapRef(const BBitmap& other)
: BBitmap(other)
{
}

BitmapRef(const BitmapRef& other) = delete;

~BitmapRef()
{
}
};

using PlatformImagePtr = RefPtr<BitmapRef>;
#endif

}
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "DisplayListDrawGlyphsRecorder.h"

#include "DisplayListItems.h"
#include "DisplayListRecorder.h"
#include "FloatPoint.h"
#include "Font.h"
#include "GlyphBuffer.h"

namespace WebCore {

namespace DisplayList {

DrawGlyphsRecorder::DrawGlyphsRecorder(Recorder& owner, DrawGlyphsDeconstruction)
: m_owner(owner)
{
}

void DrawGlyphsRecorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode)
{
m_owner.append<DrawGlyphs>(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, startPoint, smoothingMode);
}

} // namespace DisplayList

} // namespace WebCore
Expand Up @@ -62,7 +62,7 @@ float subsamplingScale(GraphicsContext&, const FloatRect&, const FloatRect&)
return 1;
}

void clearNativeImageSubimages(const NativeImagePtr&)
void clearNativeImageSubimages(const PlatformImagePtr&)
{
}

Expand Down
47 changes: 8 additions & 39 deletions Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp
Expand Up @@ -186,7 +186,7 @@ void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
}
}

void GraphicsContext::drawNativeImage(const NativeImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
void GraphicsContext::drawPlatformImage(const PlatformImagePtr& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
{
if (paintingDisabled())
return;
Expand Down Expand Up @@ -444,56 +444,25 @@ void GraphicsContext::clipPath(const Path& path, WindRule windRule)
// TODO: reset wind rule
}

void GraphicsContext::clipToImageBuffer(ImageBuffer& buffer, const FloatRect& destRect)
{
if (paintingDisabled())
return;

NativeImagePtr surface = buffer.copyNativeImage(DontCopyBackingStore);
BPicture picture;
BView* view = platformContext();

if (!view)
return;

view->LockLooper();
view->BeginPicture(&picture);
view->PushState();

view->SetLowColor(make_color(255, 255, 255, 0));
view->SetViewColor(make_color(255, 255, 255, 0));
view->SetHighColor(make_color(0, 0, 0, 255));
view->SetDrawingMode(B_OP_ALPHA);
view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);

view->DrawBitmap(surface.get(), destRect);

view->PopState();
view->EndPicture();
view->ClipToPicture(&picture);
view->UnlockLooper();
}


void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect,
void GraphicsContext::drawPlatformPattern(const PlatformImagePtr& image, const WebCore::FloatSize& size, const FloatRect& destRect,
const FloatRect& tileRect, const AffineTransform&,
const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions&)
{
if (paintingDisabled())
return;

NativeImagePtr pixels = image.nativeImageForCurrentFrame();
if (!pixels || !pixels->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*>(pixels->Bits());
uint32 width = pixels->Bounds().IntegerWidth() + 1;
uint32 height = pixels->Bounds().IntegerHeight() + 1;
uint8* bits = reinterpret_cast<uint8*>(image->Bits());
uint32 width = image->Bounds().IntegerWidth() + 1;
uint32 height = image->Bounds().IntegerHeight() + 1;

uint32 bytesPerRow = pixels->BytesPerRow();
uint32 bytesPerRow = image->BytesPerRow();
for (uint32 y = 0; y < height && !hasAlpha; y++) {
uint8* p = bits;
for (uint32 x = 0; x < width && !hasAlpha; x++) {
Expand All @@ -516,7 +485,7 @@ void GraphicsContext::drawPattern(Image& image, const FloatRect& destRect,
phaseOffsetX -= std::trunc(phaseOffsetX / tileRect.width()) * tileRect.width();
phaseOffsetY -= std::trunc(phaseOffsetY / tileRect.height()) * tileRect.height();
platformContext()->DrawTiledBitmapAsync(
pixels.get(), destRect, BPoint(phaseOffsetX, phaseOffsetY));
image.get(), destRect, BPoint(phaseOffsetX, phaseOffsetY));
restore();
}

Expand Down
Expand Up @@ -44,11 +44,10 @@ class ImageBufferData {
ImageBufferData(const IntSize&);
~ImageBufferData();

NativeImagePtr m_bitmap;
BView* m_view;
GraphicsContext* m_context;

RefPtr<Image> m_image;
RefPtr<NativeImage> m_image;
};

} // namespace WebCore
Expand Down

0 comments on commit cdeafd2

Please sign in to comment.