Skip to content

Commit

Permalink
ozone: Support building without cairo
Browse files Browse the repository at this point in the history
This adds a use_cairo gyp variable that removes cairo from the build.
To build skia without cairo, we need the code in
bitmap_platform_device_android.cc.

To make all platforms build the correct files, rename
bitmap_platform_device_linux to bitmap_platform_device_cairo and
rename bitmap_platform_device_android to bitmap_platform_device_skia.
We'll use bitmap_platform_device_skia for Android and for embedded
content shell.

BUG=318315, 318413

Review URL: https://codereview.chromium.org/59133008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236037 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
spang@chromium.org committed Nov 19, 2013
1 parent ea9f65b commit 928362a
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 36 deletions.
8 changes: 7 additions & 1 deletion build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,13 @@
'use_glib%': 1,
}],

# Flags to use pango.
# Flags to use pango and cairo.
['OS=="win" or OS=="mac" or OS=="ios" or OS=="android" or embedded==1', {
'use_pango%': 0,
'use_cairo%': 0,
}, {
'use_pango%': 1,
'use_cairo%': 1,
}],

# DBus usage.
Expand Down Expand Up @@ -853,6 +855,7 @@
'use_dbus%': '<(use_dbus)',
'use_glib%': '<(use_glib)',
'use_pango%': '<(use_pango)',
'use_cairo%': '<(use_cairo)',
'use_ozone%': '<(use_ozone)',
'use_ozone_evdev%': '<(use_ozone_evdev)',
'toolkit_uses_gtk%': '<(toolkit_uses_gtk)',
Expand Down Expand Up @@ -2053,6 +2056,9 @@
['use_ash==1', {
'defines': ['USE_ASH=1'],
}],
['use_cairo==1', {
'defines': ['USE_CAIRO=1'],
}],
['use_cras==1', {
'defines': ['USE_CRAS=1'],
}],
Expand Down
8 changes: 4 additions & 4 deletions skia/ext/bitmap_platform_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include "skia/ext/bitmap_platform_device_win.h"
#elif defined(__APPLE__)
#include "skia/ext/bitmap_platform_device_mac.h"
#elif defined(ANDROID)
#include "skia/ext/bitmap_platform_device_android.h"
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
#include "skia/ext/bitmap_platform_device_linux.h"
#elif defined(USE_CAIRO)
#include "skia/ext/bitmap_platform_device_cairo.h"
#else
#include "skia/ext/bitmap_platform_device_skia.h"
#endif

namespace skia {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "skia/ext/bitmap_platform_device_linux.h"
#include "skia/ext/bitmap_platform_device_cairo.h"
#include "skia/ext/bitmap_platform_device_data.h"
#include "skia/ext/platform_canvas.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
#define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
#ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_
#define SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
Expand Down Expand Up @@ -111,4 +111,4 @@ class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {

} // namespace skia

#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "skia/ext/bitmap_platform_device_android.h"
#include "skia/ext/bitmap_platform_device_skia.h"
#include "skia/ext/platform_canvas.h"

namespace skia {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_
#define SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_
#ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_
#define SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_

#include "base/memory/ref_counted.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "skia/ext/platform_device.h"

namespace skia {
Expand Down Expand Up @@ -57,4 +57,4 @@ class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {

} // namespace skia

#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_
#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_
12 changes: 5 additions & 7 deletions skia/ext/platform_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class SkMetaData;
class SkPath;
class SkRegion;

#if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \
|| defined(OS_SOLARIS)
#if defined(USE_CAIRO)
typedef struct _cairo cairo_t;
typedef struct _cairo_rectangle cairo_rectangle_t;
#elif defined(OS_MACOSX)
Expand All @@ -37,16 +36,15 @@ class PlatformDevice;
#if defined(OS_WIN)
typedef HDC PlatformSurface;
typedef RECT PlatformRect;
#elif defined(ANDROID)
typedef void* PlatformSurface;
typedef SkIRect* PlatformRect;
#elif defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \
|| defined(OS_SOLARIS)
#elif defined(USE_CAIRO)
typedef cairo_t* PlatformSurface;
typedef cairo_rectangle_t PlatformRect;
#elif defined(OS_MACOSX)
typedef CGContextRef PlatformSurface;
typedef CGRect PlatformRect;
#else
typedef void* PlatformSurface;
typedef SkIRect* PlatformRect;
#endif

// The following routines provide accessor points for the functionality
Expand Down
13 changes: 9 additions & 4 deletions skia/skia_chrome.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
'ext/benchmarking_canvas.cc',
'ext/benchmarking_canvas.h',
'ext/bitmap_platform_device.h',
'ext/bitmap_platform_device_android.cc',
'ext/bitmap_platform_device_android.h',
'ext/bitmap_platform_device_cairo.cc',
'ext/bitmap_platform_device_cairo.h',
'ext/bitmap_platform_device_data.h',
'ext/bitmap_platform_device_linux.cc',
'ext/bitmap_platform_device_linux.h',
'ext/bitmap_platform_device_mac.cc',
'ext/bitmap_platform_device_mac.h',
'ext/bitmap_platform_device_skia.cc',
'ext/bitmap_platform_device_skia.h',
'ext/bitmap_platform_device_win.cc',
'ext/bitmap_platform_device_win.h',
'ext/convolver.cc',
Expand Down Expand Up @@ -104,6 +104,11 @@
'-Wstring-conversion',
],
}],
[ 'OS != "android" and (OS != "linux" or use_cairo==1)', {
'sources!': [
'ext/bitmap_platform_device_skia.cc',
],
}],
],

'target_conditions': [
Expand Down
3 changes: 3 additions & 0 deletions skia/skia_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
[ 'desktop_linux == 0 and chromeos == 0', {
'sources/': [ ['exclude', '_linux\\.(cc|cpp)$'] ],
}],
[ 'use_cairo == 0', {
'sources/': [ ['exclude', '_cairo\\.(cc|cpp)$'] ],
}],
],

# We would prefer this to be direct_dependent_settings,
Expand Down
6 changes: 5 additions & 1 deletion skia/skia_library.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,18 @@
'dependencies': [
'../build/linux/system.gyp:fontconfig',
'../build/linux/system.gyp:freetype2',
'../build/linux/system.gyp:pangocairo',
'../third_party/icu/icu.gyp:icuuc',
],
'cflags': [
'-Wno-unused',
'-Wno-unused-function',
],
}],
[ 'use_cairo == 1', {
'dependencies': [
'../build/linux/system.gyp:pangocairo',
],
}],
[ 'OS=="win" or OS=="mac" or OS=="ios" or OS=="android"', {
'sources!': [
'../third_party/skia/src/ports/SkFontConfigInterface_direct.cpp',
Expand Down
8 changes: 5 additions & 3 deletions ui/gfx/blit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/vector2d.h"

#if defined(USE_CAIRO)
#if defined(OS_OPENBSD)
#include <cairo.h>
#elif defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
#include <cairo/cairo.h>
#endif
#endif

#if defined(OS_MACOSX)
#include "base/mac/scoped_cftyperef.h"
Expand Down Expand Up @@ -76,9 +78,7 @@ void BlitContextToContext(NativeDrawingContext dst_context,
base::ScopedCFTypeRef<CGImageRef> src_sub_image(
CGImageCreateWithImageInRect(src_image, src_rect.ToCGRect()));
CGContextDrawImage(dst_context, dst_rect.ToCGRect(), src_sub_image);
#elif defined(OS_ANDROID)
NOTIMPLEMENTED();
#else // Linux, BSD, others
#elif defined(USE_CAIRO)
// Only translations in the source context are supported; more complex
// source context transforms will be ignored.
cairo_save(dst_context);
Expand All @@ -92,6 +92,8 @@ void BlitContextToContext(NativeDrawingContext dst_context,
cairo_clip(dst_context);
cairo_paint(dst_context);
cairo_restore(dst_context);
#else
NOTIMPLEMENTED();
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion ui/gfx/image/image_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

namespace {

#if defined(TOOLKIT_VIEWS) || defined(OS_ANDROID)
#if defined(TOOLKIT_VIEWS) || defined(OS_ANDROID) || \
(defined(OS_LINUX) && !defined(USE_CAIRO))
const bool kUsesSkiaNatively = true;
#else
const bool kUsesSkiaNatively = false;
Expand Down
4 changes: 2 additions & 2 deletions ui/gfx/native_widget_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ typedef PangoFontDescription* NativeFont;
typedef GtkWidget* NativeEditView;
typedef cairo_t* NativeDrawingContext;
typedef void* NativeViewAccessible;
#elif defined(USE_AURA)
#elif defined(USE_CAIRO)
typedef PangoFontDescription* NativeFont;
typedef void* NativeEditView;
typedef cairo_t* NativeDrawingContext;
typedef void* NativeViewAccessible;
#elif defined(OS_ANDROID)
#else
typedef void* NativeFont;
typedef void* NativeEditView;
typedef void* NativeDrawingContext;
Expand Down

0 comments on commit 928362a

Please sign in to comment.