Skip to content

Commit

Permalink
Clean up most of remaining EnumTraits specializations under WebCore/p…
Browse files Browse the repository at this point in the history
…latform/graphics

https://bugs.webkit.org/show_bug.cgi?id=266625

Reviewed by Chris Dumez.

Run through most of EnumTraits specializations under WebCore/platform/graphics,
removing if unused or replacing them with corresponding serialization specifications
in WebKit's WebCoreArgumentCoders serialization input file.

* Source/WebCore/html/track/AudioTrack.cpp:
(WebCore::AudioTrack::updateKindFromPrivate):
* Source/WebCore/html/track/VideoTrack.cpp:
(WebCore::VideoTrack::updateKindFromPrivate):
* Source/WebCore/platform/graphics/AudioTrackPrivate.h:
(WebCore::AudioTrackPrivate::kind const):
* Source/WebCore/platform/graphics/GraphicsContextGL.h:
* Source/WebCore/platform/graphics/GraphicsContextState.h:
* Source/WebCore/platform/graphics/GraphicsLayer.h:
* Source/WebCore/platform/graphics/GraphicsTypesGL.h:
* Source/WebCore/platform/graphics/Image.h:
* Source/WebCore/platform/graphics/SystemImage.h:
* Source/WebCore/platform/graphics/VideoTrackPrivate.h:
(WebCore::VideoTrackPrivate::kind const):
* Source/WebCore/platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm:
(WebCore::AVTrackPrivateAVFObjCImpl::audioKind const):
(WebCore::AVTrackPrivateAVFObjCImpl::videoKind const):
* Source/WebCore/platform/graphics/avfoundation/AudioTrackPrivateAVF.h:
* Source/WebCore/platform/graphics/avfoundation/VideoTrackPrivateAVF.h:
* Source/WebCore/platform/graphics/transforms/TransformOperation.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/WebProcess/GPU/media/AudioTrackPrivateRemote.h:
* Source/WebKit/WebProcess/GPU/media/VideoTrackPrivateRemote.h:

Canonical link: https://commits.webkit.org/272841@main
  • Loading branch information
zdobersek committed Jan 10, 2024
1 parent 1b0ef4a commit 84f0f7a
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 249 deletions.
14 changes: 7 additions & 7 deletions Source/WebCore/html/track/AudioTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,25 @@ void AudioTrack::willRemove()
void AudioTrack::updateKindFromPrivate()
{
switch (m_private->kind()) {
case AudioTrackPrivate::Alternative:
case AudioTrackPrivate::Kind::Alternative:
setKind(alternativeAtom());
break;
case AudioTrackPrivate::Description:
case AudioTrackPrivate::Kind::Description:
setKind(AudioTrack::descriptionKeyword());
break;
case AudioTrackPrivate::Main:
case AudioTrackPrivate::Kind::Main:
setKind(mainAtom());
break;
case AudioTrackPrivate::MainDesc:
case AudioTrackPrivate::Kind::MainDesc:
setKind(AudioTrack::mainDescKeyword());
break;
case AudioTrackPrivate::Translation:
case AudioTrackPrivate::Kind::Translation:
setKind(AudioTrack::translationKeyword());
break;
case AudioTrackPrivate::Commentary:
case AudioTrackPrivate::Kind::Commentary:
setKind(commentaryAtom());
break;
case AudioTrackPrivate::None:
case AudioTrackPrivate::Kind::None:
setKind(emptyAtom());
break;
default:
Expand Down
14 changes: 7 additions & 7 deletions Source/WebCore/html/track/VideoTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,25 +212,25 @@ void VideoTrack::setLanguage(const AtomString& language)
void VideoTrack::updateKindFromPrivate()
{
switch (m_private->kind()) {
case VideoTrackPrivate::Alternative:
case VideoTrackPrivate::Kind::Alternative:
setKind(alternativeAtom());
return;
case VideoTrackPrivate::Captions:
case VideoTrackPrivate::Kind::Captions:
setKind(captionsAtom());
return;
case VideoTrackPrivate::Main:
case VideoTrackPrivate::Kind::Main:
setKind(mainAtom());
return;
case VideoTrackPrivate::Sign:
case VideoTrackPrivate::Kind::Sign:
setKind(VideoTrack::signKeyword());
return;
case VideoTrackPrivate::Subtitles:
case VideoTrackPrivate::Kind::Subtitles:
setKind(subtitlesAtom());
return;
case VideoTrackPrivate::Commentary:
case VideoTrackPrivate::Kind::Commentary:
setKind(commentaryAtom());
return;
case VideoTrackPrivate::None:
case VideoTrackPrivate::Kind::None:
setKind(emptyAtom());
return;
}
Expand Down
21 changes: 2 additions & 19 deletions Source/WebCore/platform/graphics/AudioTrackPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class AudioTrackPrivate : public TrackPrivateBase {

bool enabled() const { return m_enabled; }

enum Kind { Alternative, Description, Main, MainDesc, Translation, Commentary, None };
virtual Kind kind() const { return None; }
enum class Kind : uint8_t { Alternative, Description, Main, MainDesc, Translation, Commentary, None };
virtual Kind kind() const { return Kind::None; }

virtual bool isBackedByMediaStreamTrack() const { return false; }

Expand Down Expand Up @@ -104,21 +104,4 @@ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::AudioTrackPrivate)
static bool isType(const WebCore::TrackPrivateBase& track) { return track.type() == WebCore::TrackPrivateBase::Type::Audio; }
SPECIALIZE_TYPE_TRAITS_END()

namespace WTF {

template<> struct EnumTraits<WebCore::AudioTrackPrivate::Kind> {
using values = EnumValues<
WebCore::AudioTrackPrivate::Kind,
WebCore::AudioTrackPrivate::Kind::Alternative,
WebCore::AudioTrackPrivate::Kind::Description,
WebCore::AudioTrackPrivate::Kind::Main,
WebCore::AudioTrackPrivate::Kind::MainDesc,
WebCore::AudioTrackPrivate::Kind::Translation,
WebCore::AudioTrackPrivate::Kind::Commentary,
WebCore::AudioTrackPrivate::Kind::None
>;
};

} // namespace WTF

#endif
23 changes: 7 additions & 16 deletions Source/WebCore/platform/graphics/GraphicsContextGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ using GraphicsContextGLEGLImageSource = std::variant<
>;
#endif // PLATFORM(COCOA)


enum class GraphicsContextGLSurfaceBuffer : bool {
DrawingBuffer,
DisplayBuffer
};

// Base class for graphics context for implementing WebGL rendering model.
class GraphicsContextGL : public RefCounted<GraphicsContextGL> {
public:
Expand Down Expand Up @@ -1637,10 +1643,7 @@ class GraphicsContextGL : public RefCounted<GraphicsContextGL> {
// FIXME: these should be removed, they're part of drawing buffer and
// display buffer abstractions that the caller should hold separate to
// the context.
enum class SurfaceBuffer : uint8_t {
DrawingBuffer,
DisplayBuffer
};
using SurfaceBuffer = GraphicsContextGLSurfaceBuffer;
virtual void drawSurfaceBufferToImageBuffer(SurfaceBuffer, ImageBuffer&) = 0;
#if ENABLE(MEDIA_STREAM) || ENABLE(WEB_CODECS)
virtual RefPtr<VideoFrame> surfaceBufferToVideoFrame(SurfaceBuffer) = 0;
Expand Down Expand Up @@ -1754,16 +1757,4 @@ IMPLEMENT_GCGL_OWNED(Texture)

} // namespace WebCore

namespace WTF {

template <> struct EnumTraits<WebCore::GraphicsContextGL::SurfaceBuffer> {
using values = EnumValues<
WebCore::GraphicsContextGL::SurfaceBuffer,
WebCore::GraphicsContextGL::SurfaceBuffer::DrawingBuffer,
WebCore::GraphicsContextGL::SurfaceBuffer::DisplayBuffer
>;
};

}

#endif
33 changes: 0 additions & 33 deletions Source/WebCore/platform/graphics/GraphicsContextState.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,36 +209,3 @@ TextStream& operator<<(TextStream&, GraphicsContextState::Change);
TextStream& operator<<(TextStream&, const GraphicsContextState&);

} // namespace WebCore

namespace WTF {

template<> struct EnumTraits<WebCore::GraphicsContextState::Change> {
using values = EnumValues<
WebCore::GraphicsContextState::Change,
WebCore::GraphicsContextState::Change::FillBrush,
WebCore::GraphicsContextState::Change::FillRule,

WebCore::GraphicsContextState::Change::StrokeBrush,
WebCore::GraphicsContextState::Change::StrokeThickness,
WebCore::GraphicsContextState::Change::StrokeStyle,

WebCore::GraphicsContextState::Change::CompositeMode,
WebCore::GraphicsContextState::Change::DropShadow,
WebCore::GraphicsContextState::Change::Style,

WebCore::GraphicsContextState::Change::Alpha,
WebCore::GraphicsContextState::Change::TextDrawingMode,
WebCore::GraphicsContextState::Change::ImageInterpolationQuality,

WebCore::GraphicsContextState::Change::ShouldAntialias,
WebCore::GraphicsContextState::Change::ShouldSmoothFonts,
WebCore::GraphicsContextState::Change::ShouldSubpixelQuantizeFonts,
WebCore::GraphicsContextState::Change::ShadowsIgnoreTransforms,
WebCore::GraphicsContextState::Change::DrawLuminanceMask
#if HAVE(OS_DARK_MODE_SUPPORT)
, WebCore::GraphicsContextState::Change::UseDarkAppearance
#endif
>;
};

} // namespace WTF
15 changes: 1 addition & 14 deletions Source/WebCore/platform/graphics/GraphicsLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "TransformOperations.h"
#include "WindRule.h"
#include <wtf/CheckedRef.h>
#include <wtf/EnumTraits.h>
#include <wtf/Function.h>
#include <wtf/TypeCasts.h>

Expand Down Expand Up @@ -590,7 +589,7 @@ class GraphicsLayer : public RefCounted<GraphicsLayer> {
virtual void setDebugBackgroundColor(const Color&) { }
virtual void setDebugBorder(const Color&, float /*borderWidth*/) { }

enum class CustomAppearance : uint8_t {
enum class CustomAppearance : bool {
None,
ScrollingShadow
};
Expand Down Expand Up @@ -842,15 +841,3 @@ SPECIALIZE_TYPE_TRAITS_END()
// Outside the WebCore namespace for ease of invocation from the debugger.
void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer);
#endif

namespace WTF {

template<> struct EnumTraits<WebCore::GraphicsLayer::CustomAppearance> {
using values = EnumValues<
WebCore::GraphicsLayer::CustomAppearance,
WebCore::GraphicsLayer::CustomAppearance::None,
WebCore::GraphicsLayer::CustomAppearance::ScrollingShadow
>;
};

} // namespace WTF
17 changes: 0 additions & 17 deletions Source/WebCore/platform/graphics/GraphicsTypesGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#pragma once

#include <cstdint>
#include <wtf/EnumTraits.h>
#include <wtf/OptionSet.h>

// GCGL types match the corresponding GL types as defined in OpenGL ES 2.0
Expand Down Expand Up @@ -84,19 +83,3 @@ enum class GCGLErrorCode : uint8_t {
InvalidEnum = 1 << 6
};
using GCGLErrorCodeSet = OptionSet<GCGLErrorCode>;

namespace WTF {

template <> struct EnumTraits<GCGLErrorCode> {
using values = EnumValues <
GCGLErrorCode,
GCGLErrorCode::ContextLost,
GCGLErrorCode::InvalidFramebufferOperation,
GCGLErrorCode::OutOfMemory,
GCGLErrorCode::InvalidOperation,
GCGLErrorCode::InvalidValue,
GCGLErrorCode::InvalidEnum
>;
};

}
16 changes: 0 additions & 16 deletions Source/WebCore/platform/graphics/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "ImageTypes.h"
#include "NativeImage.h"
#include "Timer.h"
#include <wtf/EnumTraits.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
Expand Down Expand Up @@ -232,18 +231,3 @@ WTF::TextStream& operator<<(WTF::TextStream&, const Image&);
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
static bool isType(const WebCore::Image& image) { return image.is##ToClassName(); } \
SPECIALIZE_TYPE_TRAITS_END()


namespace WTF {

template<> struct EnumTraits<WebCore::Image::TileRule> {
using values = EnumValues<
WebCore::Image::TileRule,
WebCore::Image::TileRule::StretchTile,
WebCore::Image::TileRule::RoundTile,
WebCore::Image::TileRule::SpaceTile,
WebCore::Image::TileRule::RepeatTile
>;
};

} // namespace WTF
19 changes: 0 additions & 19 deletions Source/WebCore/platform/graphics/SystemImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,3 @@ class WEBCORE_EXPORT SystemImage : public RefCounted<SystemImage> {
};

} // namespace WebCore

namespace WTF {

template<> struct EnumTraits<WebCore::SystemImageType> {
using values = EnumValues<
WebCore::SystemImageType
#if ENABLE(APPLE_PAY)
, WebCore::SystemImageType::ApplePayLogo
#endif
#if USE(SYSTEM_PREVIEW)
, WebCore::SystemImageType::ARKitBadge
#endif
#if USE(APPKIT)
, WebCore::SystemImageType::AppKitControl
#endif
>;
};

} // namespace WTF
21 changes: 2 additions & 19 deletions Source/WebCore/platform/graphics/VideoTrackPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class VideoTrackPrivate : public TrackPrivateBase {
}
virtual bool selected() const { return m_selected; }

enum Kind { Alternative, Captions, Main, Sign, Subtitles, Commentary, None };
virtual Kind kind() const { return None; }
enum class Kind : uint8_t { Alternative, Captions, Main, Sign, Subtitles, Commentary, None };
virtual Kind kind() const { return Kind::None; }

#if !RELEASE_LOG_DISABLED
const char* logClassName() const final { return "VideoTrackPrivate"; }
Expand Down Expand Up @@ -102,21 +102,4 @@ SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::VideoTrackPrivate)
static bool isType(const WebCore::TrackPrivateBase& track) { return track.type() == WebCore::TrackPrivateBase::Type::Video; }
SPECIALIZE_TYPE_TRAITS_END()

namespace WTF {

template<> struct EnumTraits<WebCore::VideoTrackPrivate::Kind> {
using values = EnumValues<
WebCore::VideoTrackPrivate::Kind,
WebCore::VideoTrackPrivate::Kind::Alternative,
WebCore::VideoTrackPrivate::Kind::Captions,
WebCore::VideoTrackPrivate::Kind::Main,
WebCore::VideoTrackPrivate::Kind::Sign,
WebCore::VideoTrackPrivate::Kind::Subtitles,
WebCore::VideoTrackPrivate::Kind::Commentary,
WebCore::VideoTrackPrivate::Kind::None
>;
};

} // namespace WTF

#endif
Loading

0 comments on commit 84f0f7a

Please sign in to comment.