Title: [206383] trunk/Source/WebCore
- Revision
- 206383
- Author
- [email protected]
- Date
- 2016-09-26 11:57:21 -0700 (Mon, 26 Sep 2016)
Log Message
Add CairoUniquePtr and use it in FontPlatformDataFreetype.cpp
https://bugs.webkit.org/show_bug.cgi?id=162557
Reviewed by Alex Christensen.
* platform/graphics/cairo/CairoUniquePtr.h: Added.
(WebCore::CairoPtrDeleter<cairo_font_options_t>::operator()):
* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::getDefaultCairoFontOptions): Return a smart pointer.
(WebCore::FontPlatformData::buildScaledFont): Use smart pointer.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (206382 => 206383)
--- trunk/Source/WebCore/ChangeLog 2016-09-26 18:55:57 UTC (rev 206382)
+++ trunk/Source/WebCore/ChangeLog 2016-09-26 18:57:21 UTC (rev 206383)
@@ -1,5 +1,18 @@
2016-09-26 Michael Catanzaro <[email protected]>
+ Add CairoUniquePtr and use it in FontPlatformDataFreetype.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=162557
+
+ Reviewed by Alex Christensen.
+
+ * platform/graphics/cairo/CairoUniquePtr.h: Added.
+ (WebCore::CairoPtrDeleter<cairo_font_options_t>::operator()):
+ * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
+ (WebCore::getDefaultCairoFontOptions): Return a smart pointer.
+ (WebCore::FontPlatformData::buildScaledFont): Use smart pointer.
+
+2016-09-26 Michael Catanzaro <[email protected]>
+
Silence unused parameter warnings from Geoclue2Interface.c
https://bugs.webkit.org/show_bug.cgi?id=162545
Added: trunk/Source/WebCore/platform/graphics/cairo/CairoUniquePtr.h (0 => 206383)
--- trunk/Source/WebCore/platform/graphics/cairo/CairoUniquePtr.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cairo/CairoUniquePtr.h 2016-09-26 18:57:21 UTC (rev 206383)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <cairo.h>
+#include <memory>
+
+namespace WebCore {
+
+template<typename T> struct CairoPtrDeleter {
+ void operator()(T* ptr) const = delete;
+};
+
+template<typename T>
+using CairoUniquePtr = std::unique_ptr<T, CairoPtrDeleter<T>>;
+
+template<> struct CairoPtrDeleter<cairo_font_options_t> {
+ void operator() (cairo_font_options_t* ptr) const
+ {
+ cairo_font_options_destroy(ptr);
+ }
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp (206382 => 206383)
--- trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2016-09-26 18:55:57 UTC (rev 206382)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2016-09-26 18:57:21 UTC (rev 206383)
@@ -25,6 +25,7 @@
#include "config.h"
#include "FontPlatformData.h"
+#include "CairoUniquePtr.h"
#include "CairoUtilities.h"
#include "FontCache.h"
#include "FontDescription.h"
@@ -105,16 +106,16 @@
cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
}
-static cairo_font_options_t* getDefaultCairoFontOptions()
+static CairoUniquePtr<cairo_font_options_t> getDefaultCairoFontOptions()
{
#if PLATFORM(GTK)
if (GdkScreen* screen = gdk_screen_get_default()) {
const cairo_font_options_t* screenOptions = gdk_screen_get_font_options(screen);
if (screenOptions)
- return cairo_font_options_copy(screenOptions);
+ return CairoUniquePtr<cairo_font_options_t>(cairo_font_options_copy(screenOptions));
}
#endif
- return cairo_font_options_create();
+ return CairoUniquePtr<cairo_font_options_t>(cairo_font_options_create());
}
static FcPattern* getDefaultFontconfigOptions()
@@ -299,9 +300,9 @@
void FontPlatformData::buildScaledFont(cairo_font_face_t* fontFace)
{
- cairo_font_options_t* options = getDefaultCairoFontOptions();
+ CairoUniquePtr<cairo_font_options_t> options = getDefaultCairoFontOptions();
FcPattern* optionsPattern = m_pattern ? m_pattern.get() : getDefaultFontconfigOptions();
- setCairoFontOptionsFromFontConfigPattern(options, optionsPattern);
+ setCairoFontOptionsFromFontConfigPattern(options.get(), optionsPattern);
cairo_matrix_t ctm;
cairo_matrix_init_identity(&ctm);
@@ -340,8 +341,7 @@
cairo_matrix_translate(&fontMatrix, 0.0, 1.0);
}
- m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
- cairo_font_options_destroy(options);
+ m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options.get()));
}
bool FontPlatformData::hasCompatibleCharmap() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes