summaryrefslogtreecommitdiff
path: root/chromium/skia
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/skia
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/skia')
-rw-r--r--chromium/skia/PRESUBMIT.py18
-rw-r--r--chromium/skia/config/SkUserConfig.h23
-rw-r--r--chromium/skia/config/sk_ref_cnt_ext_debug.h48
-rw-r--r--chromium/skia/config/sk_ref_cnt_ext_release.h19
-rw-r--r--chromium/skia/ext/SkDiscardableMemory_chrome.cc25
-rw-r--r--chromium/skia/ext/SkDiscardableMemory_chrome.h12
-rw-r--r--chromium/skia/ext/SkMemory_new_handler.cpp90
-rw-r--r--chromium/skia/ext/SkThread_chrome.cc88
-rw-r--r--chromium/skia/ext/analysis_canvas.cc10
-rw-r--r--chromium/skia/ext/analysis_canvas.h3
-rw-r--r--chromium/skia/ext/bitmap_platform_device.h8
-rw-r--r--chromium/skia/ext/bitmap_platform_device_cairo.cc (renamed from chromium/skia/ext/bitmap_platform_device_linux.cc)126
-rw-r--r--chromium/skia/ext/bitmap_platform_device_cairo.h (renamed from chromium/skia/ext/bitmap_platform_device_linux.h)37
-rw-r--r--chromium/skia/ext/bitmap_platform_device_data.h102
-rw-r--r--chromium/skia/ext/bitmap_platform_device_mac.cc76
-rw-r--r--chromium/skia/ext/bitmap_platform_device_mac.h35
-rw-r--r--chromium/skia/ext/bitmap_platform_device_skia.cc (renamed from chromium/skia/ext/bitmap_platform_device_android.cc)16
-rw-r--r--chromium/skia/ext/bitmap_platform_device_skia.h (renamed from chromium/skia/ext/bitmap_platform_device_android.h)10
-rw-r--r--chromium/skia/ext/bitmap_platform_device_win.cc149
-rw-r--r--chromium/skia/ext/bitmap_platform_device_win.h62
-rw-r--r--chromium/skia/ext/image_operations.cc10
-rw-r--r--chromium/skia/ext/lazy_pixel_ref.cc8
-rw-r--r--chromium/skia/ext/lazy_pixel_ref.h5
-rw-r--r--chromium/skia/ext/lazy_pixel_ref_utils.cc11
-rw-r--r--chromium/skia/ext/lazy_pixel_ref_utils_unittest.cc13
-rw-r--r--chromium/skia/ext/platform_canvas_unittest.cc4
-rw-r--r--chromium/skia/ext/platform_device.h12
-rw-r--r--chromium/skia/ext/skia_utils_ios.mm8
-rw-r--r--chromium/skia/ext/skia_utils_mac.h10
-rw-r--r--chromium/skia/ext/skia_utils_mac.mm30
-rw-r--r--chromium/skia/ext/skia_utils_mac_unittest.mm19
-rw-r--r--chromium/skia/ext/vector_canvas_unittest.cc6
-rw-r--r--chromium/skia/ext/vector_platform_device_emf_win.cc7
-rw-r--r--chromium/skia/ext/vector_platform_device_emf_win.h2
-rw-r--r--chromium/skia/skia.gyp14
-rw-r--r--chromium/skia/skia_chrome.gypi34
-rw-r--r--chromium/skia/skia_common.gypi25
-rw-r--r--chromium/skia/skia_library.gypi54
-rw-r--r--chromium/skia/skia_library_opts.gyp39
-rw-r--r--chromium/skia/skia_test_expectations.txt25
-rw-r--r--chromium/skia/tools/filter_fuzz_stub/filter_fuzz_stub.cc93
41 files changed, 798 insertions, 588 deletions
diff --git a/chromium/skia/PRESUBMIT.py b/chromium/skia/PRESUBMIT.py
new file mode 100644
index 00000000000..e22733cf670
--- /dev/null
+++ b/chromium/skia/PRESUBMIT.py
@@ -0,0 +1,18 @@
+# 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.
+
+"""Top-level presubmit script for skia/
+
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details about the presubmit API built into depot_tools.
+"""
+
+def GetPreferredTrySlaves(project, change):
+ return [
+ 'linux_gpu',
+ 'win_gpu',
+ 'mac_gpu',
+ 'mac_gpu_retina',
+ 'linux_layout_rel',
+ ]
diff --git a/chromium/skia/config/SkUserConfig.h b/chromium/skia/config/SkUserConfig.h
index 77a9af97a66..d15882c2fe3 100644
--- a/chromium/skia/config/SkUserConfig.h
+++ b/chromium/skia/config/SkUserConfig.h
@@ -152,11 +152,17 @@
// ===== Begin Chrome-specific definitions =====
+#ifdef SK_DEBUG
+#define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_debug.h"
+#else
+#define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_release.h"
+#endif
+
#define SK_SCALAR_IS_FLOAT
#undef SK_SCALAR_IS_FIXED
-#define SK_MSCALAR_IS_DOUBLE
-#undef SK_MSCALAR_IS_FLOAT
+#define SK_MSCALAR_IS_FLOAT
+#undef SK_MSCALAR_IS_DOUBLE
#define GR_MAX_OFFSCREEN_AA_DIM 512
@@ -183,19 +189,6 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
#define SK_BUILD_FOR_WIN
-// VC8 doesn't support stdint.h, so we define those types here.
-#define SK_IGNORE_STDINT_DOT_H
-typedef signed char int8_t;
-typedef unsigned char uint8_t;
-typedef short int16_t;
-typedef unsigned short uint16_t;
-typedef int int32_t;
-typedef unsigned uint32_t;
-
-// VC doesn't support __restrict__, so make it a NOP.
-#undef SK_RESTRICT
-#define SK_RESTRICT
-
// Skia uses this deprecated bzero function to fill zeros into a string.
#define bzero(str, len) memset(str, 0, len)
diff --git a/chromium/skia/config/sk_ref_cnt_ext_debug.h b/chromium/skia/config/sk_ref_cnt_ext_debug.h
new file mode 100644
index 00000000000..b2b66adba72
--- /dev/null
+++ b/chromium/skia/config/sk_ref_cnt_ext_debug.h
@@ -0,0 +1,48 @@
+// 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 SK_REF_CNT_EXT_DEBUG_H_
+#define SK_REF_CNT_EXT_DEBUG_H_
+
+#ifdef SK_REF_CNT_EXT_RELEASE_H_
+#error Only one SkRefCnt should be used.
+#endif
+
+// Alternate implementation of SkRefCnt for Chromium debug builds
+class SK_API SkRefCnt : public SkRefCntBase {
+public:
+ SkRefCnt() : flags_(0) {}
+ void ref() const { SkASSERT(flags_ != AdoptionRequired_Flag); SkRefCntBase::ref(); }
+ void adopted() const { flags_ |= Adopted_Flag; }
+ void requireAdoption() const { flags_ |= AdoptionRequired_Flag; }
+ void deref() const { SkRefCntBase::unref(); }
+private:
+ enum {
+ Adopted_Flag = 0x1,
+ AdoptionRequired_Flag = 0x2,
+ };
+
+ mutable int flags_;
+};
+
+// Bootstrap for Blink's WTF::RefPtr
+
+namespace WTF {
+ inline void adopted(const SkRefCnt* object) {
+ if (!object)
+ return;
+ object->adopted();
+ }
+ inline void requireAdoption(const SkRefCnt* object) {
+ if (!object)
+ return;
+ object->requireAdoption();
+ }
+};
+
+using WTF::adopted;
+using WTF::requireAdoption;
+
+#endif
+
diff --git a/chromium/skia/config/sk_ref_cnt_ext_release.h b/chromium/skia/config/sk_ref_cnt_ext_release.h
new file mode 100644
index 00000000000..7736c84cf7e
--- /dev/null
+++ b/chromium/skia/config/sk_ref_cnt_ext_release.h
@@ -0,0 +1,19 @@
+// 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 SK_REF_CNT_EXT_RELEASE_H_
+#define SK_REF_CNT_EXT_RELEASE_H_
+
+#ifdef SK_REF_CNT_EXT_DEBUG_H_
+#error Only one SkRefCnt should be used.
+#endif
+
+// Alternate implementation of SkRefCnt for Chromium release builds
+class SK_API SkRefCnt : public SkRefCntBase {
+public:
+ void deref() const { SkRefCntBase::unref(); }
+};
+
+#endif
+
diff --git a/chromium/skia/ext/SkDiscardableMemory_chrome.cc b/chromium/skia/ext/SkDiscardableMemory_chrome.cc
index 2e78788febc..886c9950b81 100644
--- a/chromium/skia/ext/SkDiscardableMemory_chrome.cc
+++ b/chromium/skia/ext/SkDiscardableMemory_chrome.cc
@@ -4,15 +4,10 @@
#include "SkDiscardableMemory_chrome.h"
-SkDiscardableMemoryChrome::SkDiscardableMemoryChrome()
- : discardable_(new base::DiscardableMemory()) {
-}
-
-SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {
-}
+SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {}
bool SkDiscardableMemoryChrome::lock() {
- base::LockDiscardableMemoryStatus status = discardable_->Lock();
+ const base::LockDiscardableMemoryStatus status = discardable_->Lock();
switch (status) {
case base::DISCARDABLE_MEMORY_SUCCESS:
return true;
@@ -33,17 +28,15 @@ void SkDiscardableMemoryChrome::unlock() {
discardable_->Unlock();
}
-bool SkDiscardableMemoryChrome::InitializeAndLock(size_t bytes) {
- return discardable_->InitializeAndLock(bytes);
+SkDiscardableMemoryChrome::SkDiscardableMemoryChrome(
+ scoped_ptr<base::DiscardableMemory> memory)
+ : discardable_(memory.Pass()) {
}
SkDiscardableMemory* SkDiscardableMemory::Create(size_t bytes) {
- if (!base::DiscardableMemory::Supported()) {
+ scoped_ptr<base::DiscardableMemory> discardable(
+ base::DiscardableMemory::CreateLockedMemory(bytes));
+ if (!discardable)
return NULL;
- }
- scoped_ptr<SkDiscardableMemoryChrome> discardable(
- new SkDiscardableMemoryChrome());
- if (discardable->InitializeAndLock(bytes))
- return discardable.release();
- return NULL;
+ return new SkDiscardableMemoryChrome(discardable.Pass());
}
diff --git a/chromium/skia/ext/SkDiscardableMemory_chrome.h b/chromium/skia/ext/SkDiscardableMemory_chrome.h
index 13dfef83dc8..b251dc452db 100644
--- a/chromium/skia/ext/SkDiscardableMemory_chrome.h
+++ b/chromium/skia/ext/SkDiscardableMemory_chrome.h
@@ -13,20 +13,18 @@
// base::DiscardableMemory.
class SK_API SkDiscardableMemoryChrome : public SkDiscardableMemory {
public:
- SkDiscardableMemoryChrome();
virtual ~SkDiscardableMemoryChrome();
- // Initialize the SkDiscardableMemoryChrome object and lock the memory.
- // Returns true on success. No memory is allocated if this call returns
- // false. This call should only be called once.
- bool InitializeAndLock(size_t bytes);
-
- // Implementation of SkDiscardableMemory interface.
+ // SkDiscardableMemory:
virtual bool lock() OVERRIDE;
virtual void* data() OVERRIDE;
virtual void unlock() OVERRIDE;
private:
+ friend class SkDiscardableMemory;
+
+ SkDiscardableMemoryChrome(scoped_ptr<base::DiscardableMemory> memory);
+
scoped_ptr<base::DiscardableMemory> discardable_;
};
diff --git a/chromium/skia/ext/SkMemory_new_handler.cpp b/chromium/skia/ext/SkMemory_new_handler.cpp
index dbbc4944512..a142f2994e2 100644
--- a/chromium/skia/ext/SkMemory_new_handler.cpp
+++ b/chromium/skia/ext/SkMemory_new_handler.cpp
@@ -11,13 +11,21 @@
#include "third_party/skia/include/core/SkTypes.h"
#include "third_party/skia/include/core/SkThread.h"
-// This implementation of sk_malloc_flags() and friends is identical
-// to SkMemory_malloc.c, except that it disables the CRT's new_handler
-// during malloc(), when SK_MALLOC_THROW is not set (ie., when
-// sk_malloc_flags() would not abort on NULL).
+// This implementation of sk_malloc_flags() and friends is identical to
+// SkMemory_malloc.cpp, except that it disables the CRT's new_handler during
+// malloc() and calloc() when SK_MALLOC_THROW is not set (because our normal
+// new_handler itself will crash on failure when using tcmalloc).
SK_DECLARE_STATIC_MUTEX(gSkNewHandlerMutex);
+static inline void* throw_on_failure(size_t size, void* p) {
+ if (size > 0 && p == NULL) {
+ // If we've got a NULL here, the only reason we should have failed is running out of RAM.
+ sk_out_of_memory();
+ }
+ return p;
+}
+
void sk_throw() {
SkASSERT(!"sk_throw");
abort();
@@ -28,19 +36,8 @@ void sk_out_of_memory(void) {
abort();
}
-void* sk_malloc_throw(size_t size) {
- return sk_malloc_flags(size, SK_MALLOC_THROW);
-}
-
void* sk_realloc_throw(void* addr, size_t size) {
- void* p = realloc(addr, size);
- if (size == 0) {
- return p;
- }
- if (p == NULL) {
- sk_throw();
- }
- return p;
+ return throw_on_failure(size, realloc(addr, size));
}
void sk_free(void* p) {
@@ -49,29 +46,50 @@ void sk_free(void* p) {
}
}
-void* sk_malloc_flags(size_t size, unsigned flags) {
- void* p;
+void* sk_malloc_throw(size_t size) {
+ return throw_on_failure(size, malloc(size));
+}
+
+// Platform specific ways to try really hard to get a malloc that won't crash on failure.
+static void* sk_malloc_nothrow(size_t size) {
#if defined(ANDROID)
- // Android doesn't have std::set_new_handler.
- p = malloc(size);
+ // Android doesn't have std::set_new_handler, so we just call malloc.
+ return malloc(size);
+#elif defined(OS_MACOSX) && !defined(OS_IOS)
+ return base::UncheckedMalloc(size);
#else
- if (!(flags & SK_MALLOC_THROW)) {
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- p = base::UncheckedMalloc(size);
-#else
- SkAutoMutexAcquire lock(gSkNewHandlerMutex);
- std::new_handler old_handler = std::set_new_handler(NULL);
- p = malloc(size);
- std::set_new_handler(old_handler);
-#endif
- } else {
- p = malloc(size);
- }
+ // This is not really thread safe. It only won't collide with itself, but we're totally
+ // unprotected from races with other code that calls set_new_handler.
+ SkAutoMutexAcquire lock(gSkNewHandlerMutex);
+ std::new_handler old_handler = std::set_new_handler(NULL);
+ void* p = malloc(size);
+ std::set_new_handler(old_handler);
+ return p;
#endif
- if (p == NULL) {
- if (flags & SK_MALLOC_THROW) {
- sk_throw();
- }
+}
+
+void* sk_malloc_flags(size_t size, unsigned flags) {
+ if (flags & SK_MALLOC_THROW) {
+ return sk_malloc_throw(size);
}
+ return sk_malloc_nothrow(size);
+}
+
+void* sk_calloc_throw(size_t size) {
+ return throw_on_failure(size, calloc(size, 1));
+}
+
+// Jump through the same hoops as sk_malloc_nothrow to avoid a crash, but for calloc.
+void* sk_calloc(size_t size) {
+#if defined(ANDROID)
+ return calloc(size, 1);
+#elif defined(OS_MACOSX) && !defined(OS_IOS)
+ return base::UncheckedCalloc(size, 1);
+#else
+ SkAutoMutexAcquire lock(gSkNewHandlerMutex);
+ std::new_handler old_handler = std::set_new_handler(NULL);
+ void* p = calloc(size, 1);
+ std::set_new_handler(old_handler);
return p;
+#endif
}
diff --git a/chromium/skia/ext/SkThread_chrome.cc b/chromium/skia/ext/SkThread_chrome.cc
deleted file mode 100644
index f379bebee71..00000000000
--- a/chromium/skia/ext/SkThread_chrome.cc
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2012 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 "third_party/skia/include/core/SkThread.h"
-
-#include <new>
-
-#include "base/atomicops.h"
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "base/synchronization/lock.h"
-
-/** Adds one to the int specified by the address (in a thread-safe manner), and
- returns the previous value.
- No additional memory barrier is required.
- This must act as a compiler barrier.
-*/
-int32_t sk_atomic_inc(int32_t* addr) {
- // sk_atomic_inc is expected to return the old value,
- // Barrier_AtomicIncrement returns the new value.
- return base::subtle::NoBarrier_AtomicIncrement(addr, 1) - 1;
-}
-
-/* Subtracts one from the int specified by the address (in a thread-safe
- manner), and returns the previous value.
- Expected to act as a release (SL/S) memory barrier and a compiler barrier.
-*/
-int32_t sk_atomic_dec(int32_t* addr) {
- // sk_atomic_dec is expected to return the old value,
- // Barrier_AtomicIncrement returns the new value.
- return base::subtle::Barrier_AtomicIncrement(addr, -1) + 1;
-}
-/** If sk_atomic_dec does not act as an aquire (L/SL) barrier, this is expected
- to act as an aquire (L/SL) memory barrier and as a compiler barrier.
-*/
-void sk_membar_aquire__after_atomic_dec() { }
-
-/** Adds one to the int specified by the address iff the int specified by the
- address is not zero (in a thread-safe manner), and returns the previous
- value.
- No additional memory barrier is required.
- This must act as a compiler barrier.
-*/
-int32_t sk_atomic_conditional_inc(int32_t* addr) {
- int32_t value = *addr;
-
- while (true) {
- if (value == 0) {
- return 0;
- }
-
- int32_t before;
- before = base::subtle::Acquire_CompareAndSwap(addr, value, value + 1);
-
- if (before == value) {
- return value;
- } else {
- value = before;
- }
- }
-}
-/** If sk_atomic_conditional_inc does not act as an aquire (L/SL) barrier, this
- is expected to act as an aquire (L/SL) memory barrier and as a compiler
- barrier.
-*/
-void sk_membar_aquire__after_atomic_conditional_inc() { }
-
-SkMutex::SkMutex() {
- COMPILE_ASSERT(sizeof(base::Lock) <= sizeof(fStorage), Lock_is_too_big_for_SkMutex);
- base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage);
- new(lock) base::Lock();
-}
-
-SkMutex::~SkMutex() {
- base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage);
- lock->~Lock();
-}
-
-void SkMutex::acquire() {
- base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage);
- lock->Acquire();
-}
-
-void SkMutex::release() {
- base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage);
- lock->Release();
-}
diff --git a/chromium/skia/ext/analysis_canvas.cc b/chromium/skia/ext/analysis_canvas.cc
index 9db42f17ab6..e77ff2b72c7 100644
--- a/chromium/skia/ext/analysis_canvas.cc
+++ b/chromium/skia/ext/analysis_canvas.cc
@@ -182,6 +182,16 @@ void AnalysisDevice::drawOval(const SkDraw& draw,
is_transparent_ = false;
}
+void AnalysisDevice::drawRRect(const SkDraw& draw,
+ const SkRRect& rr,
+ const SkPaint& paint) {
+ // This should add the SkRRect to an SkPath, and call
+ // drawPath, but since drawPath ignores the SkPath, just
+ // do the same work here.
+ is_solid_color_ = false;
+ is_transparent_ = false;
+}
+
void AnalysisDevice::drawPath(const SkDraw& draw,
const SkPath& path,
const SkPaint& paint,
diff --git a/chromium/skia/ext/analysis_canvas.h b/chromium/skia/ext/analysis_canvas.h
index 78d72ff9381..909a19826d8 100644
--- a/chromium/skia/ext/analysis_canvas.h
+++ b/chromium/skia/ext/analysis_canvas.h
@@ -84,6 +84,9 @@ class SK_API AnalysisDevice : public SkBitmapDevice {
virtual void drawRect(const SkDraw& draw,
const SkRect& rect,
const SkPaint& paint) OVERRIDE;
+ virtual void drawRRect(const SkDraw& draw,
+ const SkRRect& rr,
+ const SkPaint& paint) OVERRIDE;
virtual void drawOval(const SkDraw& draw,
const SkRect& oval,
const SkPaint& paint) OVERRIDE;
diff --git a/chromium/skia/ext/bitmap_platform_device.h b/chromium/skia/ext/bitmap_platform_device.h
index 56e41763f8d..a0770f71717 100644
--- a/chromium/skia/ext/bitmap_platform_device.h
+++ b/chromium/skia/ext/bitmap_platform_device.h
@@ -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 {
diff --git a/chromium/skia/ext/bitmap_platform_device_linux.cc b/chromium/skia/ext/bitmap_platform_device_cairo.cc
index af26806fd30..3619eb25277 100644
--- a/chromium/skia/ext/bitmap_platform_device_linux.cc
+++ b/chromium/skia/ext/bitmap_platform_device_cairo.cc
@@ -1,9 +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_data.h"
+#include "skia/ext/bitmap_platform_device_cairo.h"
#include "skia/ext/platform_canvas.h"
#if defined(OS_OPENBSD)
@@ -16,6 +15,44 @@ namespace skia {
namespace {
+// CairoSurfacePixelRef is an SkPixelRef that is backed by a cairo surface.
+class SK_API CairoSurfacePixelRef : public SkPixelRef {
+ public:
+ // The constructor takes ownership of the passed-in surface.
+ explicit CairoSurfacePixelRef(const SkImageInfo& info,
+ cairo_surface_t* surface);
+ virtual ~CairoSurfacePixelRef();
+
+ SK_DECLARE_UNFLATTENABLE_OBJECT();
+
+ protected:
+ virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE;
+ virtual void onUnlockPixels() SK_OVERRIDE;
+
+ private:
+ cairo_surface_t* surface_;
+};
+
+CairoSurfacePixelRef::CairoSurfacePixelRef(const SkImageInfo& info,
+ cairo_surface_t* surface)
+ : SkPixelRef(info), surface_(surface) {
+}
+
+CairoSurfacePixelRef::~CairoSurfacePixelRef() {
+ if (surface_)
+ cairo_surface_destroy(surface_);
+}
+
+void* CairoSurfacePixelRef::onLockPixels(SkColorTable** color_table) {
+ *color_table = NULL;
+ return cairo_image_surface_get_data(surface_);
+}
+
+void CairoSurfacePixelRef::onUnlockPixels() {
+ // Nothing to do.
+ return;
+}
+
void LoadMatrixToContext(cairo_t* context, const SkMatrix& matrix) {
cairo_matrix_t cairo_matrix;
cairo_matrix_init(&cairo_matrix,
@@ -41,20 +78,7 @@ void LoadClipToContext(cairo_t* context, const SkRegion& clip) {
} // namespace
-BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData(
- cairo_surface_t* surface)
- : surface_(surface),
- config_dirty_(true),
- transform_(SkMatrix::I()) { // Want to load the config next time.
- bitmap_context_ = cairo_create(surface);
-}
-
-BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() {
- cairo_destroy(bitmap_context_);
- cairo_surface_destroy(surface_);
-}
-
-void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip(
+void BitmapPlatformDevice::SetMatrixClip(
const SkMatrix& transform,
const SkRegion& region) {
transform_ = transform;
@@ -62,18 +86,18 @@ void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip(
config_dirty_ = true;
}
-void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() {
- if (!config_dirty_ || !bitmap_context_)
+void BitmapPlatformDevice::LoadConfig() {
+ if (!config_dirty_ || !cairo_)
return; // Nothing to do.
config_dirty_ = false;
// Load the identity matrix since this is what our clip is relative to.
cairo_matrix_t cairo_matrix;
cairo_matrix_init_identity(&cairo_matrix);
- cairo_set_matrix(bitmap_context_, &cairo_matrix);
+ cairo_set_matrix(cairo_, &cairo_matrix);
- LoadClipToContext(bitmap_context_, clip_region_);
- LoadMatrixToContext(bitmap_context_, transform_);
+ LoadClipToContext(cairo_, clip_region_);
+ LoadMatrixToContext(cairo_, transform_);
}
// We use this static factory function instead of the regular constructor so
@@ -87,15 +111,22 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
cairo_surface_destroy(surface);
return NULL;
}
+
+ SkImageInfo info = {
+ width,
+ height,
+ kPMColor_SkColorType,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType
+ };
+
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height,
- cairo_image_surface_get_stride(surface));
- bitmap.setPixels(cairo_image_surface_get_data(surface));
- bitmap.setIsOpaque(is_opaque);
+ bitmap.setConfig(info, cairo_image_surface_get_stride(surface));
+ RefPtr<SkPixelRef> pixel_ref = AdoptRef(new CairoSurfacePixelRef(info,
+ surface));
+ bitmap.setPixelRef(pixel_ref.get());
// The device object will take ownership of the graphics context.
- return new BitmapPlatformDevice
- (bitmap, new BitmapPlatformDeviceData(surface));
+ return new BitmapPlatformDevice(bitmap, surface);
}
BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
@@ -136,13 +167,16 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
// data. Therefore, we do not transfer ownership to the SkBitmapDevice's bitmap.
BitmapPlatformDevice::BitmapPlatformDevice(
const SkBitmap& bitmap,
- BitmapPlatformDeviceData* data)
+ cairo_surface_t* surface)
: SkBitmapDevice(bitmap),
- data_(data) {
+ cairo_(cairo_create(surface)),
+ config_dirty_(true),
+ transform_(SkMatrix::I()) { // Want to load the config next time.
SetPlatformDevice(this, this);
}
BitmapPlatformDevice::~BitmapPlatformDevice() {
+ cairo_destroy(cairo_);
}
SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
@@ -153,15 +187,14 @@ SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
}
cairo_t* BitmapPlatformDevice::BeginPlatformPaint() {
- data_->LoadConfig();
- cairo_t* cairo = data_->bitmap_context();
- cairo_surface_t* surface = cairo_get_target(cairo);
+ LoadConfig();
+ cairo_surface_t* surface = cairo_get_target(cairo_);
// Tell cairo to flush anything it has pending.
cairo_surface_flush(surface);
// Tell Cairo that we (probably) modified (actually, will modify) its pixel
// buffer directly.
cairo_surface_mark_dirty(surface);
- return cairo;
+ return cairo_;
}
void BitmapPlatformDevice::DrawToNativeContext(
@@ -173,7 +206,7 @@ void BitmapPlatformDevice::DrawToNativeContext(
void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
const SkRegion& region,
const SkClipStack&) {
- data_->SetMatrixClip(transform, region);
+ SetMatrixClip(transform, region);
}
// PlatformCanvas impl
@@ -191,28 +224,29 @@ PlatformBitmap::~PlatformBitmap() {
}
bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
+ SkImageInfo info = {
+ width,
+ height,
+ kPMColor_SkColorType,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType
+ };
+
// The SkBitmap allocates and owns the bitmap memory; PlatformBitmap owns the
// cairo drawing context tied to the bitmap. The SkBitmap's pixelRef can
// outlive the PlatformBitmap if additional copies are made.
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
- bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, stride);
- if (!bitmap_.allocPixels()) // Using the default allocator.
- return false;
- bitmap_.setIsOpaque(is_opaque);
+ bitmap_.setConfig(info, stride);
- cairo_surface_t* surf = cairo_image_surface_create_for_data(
- reinterpret_cast<unsigned char*>(bitmap_.getPixels()),
+ cairo_surface_t* surf = cairo_image_surface_create(
CAIRO_FORMAT_ARGB32,
width,
- height,
- stride);
+ height);
if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) {
cairo_surface_destroy(surf);
return false;
}
-
- surface_ = cairo_create(surf);
- cairo_surface_destroy(surf);
+ RefPtr<SkPixelRef> pixel_ref = AdoptRef(new CairoSurfacePixelRef(info, surf));
+ bitmap_.setPixelRef(pixel_ref.get());
return true;
}
diff --git a/chromium/skia/ext/bitmap_platform_device_linux.h b/chromium/skia/ext/bitmap_platform_device_cairo.h
index 048092e076f..5b3c46ce8a3 100644
--- a/chromium/skia/ext/bitmap_platform_device_linux.h
+++ b/chromium/skia/ext/bitmap_platform_device_cairo.h
@@ -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"
@@ -57,9 +57,6 @@ namespace skia {
// case we'll probably create the buffer from a precreated region of memory.
// -----------------------------------------------------------------------------
class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {
- // A reference counted cairo surface
- class BitmapPlatformDeviceData;
-
public:
// Create a BitmapPlatformDeviceLinux from an already constructed bitmap;
// you should probably be using Create(). This may become private later if
@@ -67,7 +64,7 @@ class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {
// the Windows and Mac versions of this class do.
//
// This object takes ownership of @data.
- BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data);
+ BitmapPlatformDevice(const SkBitmap& other, cairo_surface_t* surface);
virtual ~BitmapPlatformDevice();
// Constructs a device with size |width| * |height| with contents initialized
@@ -104,11 +101,33 @@ class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {
static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
cairo_surface_t* surface);
- scoped_refptr<BitmapPlatformDeviceData> data_;
+ // Sets the transform and clip operations. This will not update the Cairo
+ // context, but will mark the config as dirty. The next call of LoadConfig
+ // will pick up these changes.
+ void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
+
+ // Loads the current transform and clip into the context.
+ void LoadConfig();
+
+ // Graphics context used to draw into the surface.
+ cairo_t* cairo_;
+
+ // True when there is a transform or clip that has not been set to the
+ // context. The context is retrieved for every text operation, and the
+ // transform and clip do not change as much. We can save time by not loading
+ // the clip and transform for every one.
+ bool config_dirty_;
+
+ // Translation assigned to the context: we need to keep track of this
+ // separately so it can be updated even if the context isn't created yet.
+ SkMatrix transform_;
+
+ // The current clipping
+ SkRegion clip_region_;
DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
};
} // namespace skia
-#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
+#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_CAIRO_H_
diff --git a/chromium/skia/ext/bitmap_platform_device_data.h b/chromium/skia/ext/bitmap_platform_device_data.h
deleted file mode 100644
index 81e81ed79ff..00000000000
--- a/chromium/skia/ext/bitmap_platform_device_data.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2011 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_DATA_H_
-#define SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
-
-#include "skia/ext/bitmap_platform_device.h"
-
-namespace skia {
-
-class BitmapPlatformDevice::BitmapPlatformDeviceData :
-#if defined(WIN32) || defined(__APPLE__)
- public SkRefCnt {
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
- // These objects are reference counted and own a Cairo surface. The surface
- // is the backing store for a Skia bitmap and we reference count it so that
- // we can copy BitmapPlatformDevice objects without having to copy all the
- // image data.
- public base::RefCounted<BitmapPlatformDeviceData> {
-#endif
-
- public:
-#if defined(WIN32)
- typedef HBITMAP PlatformContext;
-#elif defined(__APPLE__)
- typedef CGContextRef PlatformContext;
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
- typedef cairo_t* PlatformContext;
-#endif
-
-#if defined(WIN32) || defined(__APPLE__)
- explicit BitmapPlatformDeviceData(PlatformContext bitmap);
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
- explicit BitmapPlatformDeviceData(cairo_surface_t* surface);
-#endif
-
-#if defined(WIN32)
- // Create/destroy hdc_, which is the memory DC for our bitmap data.
- HDC GetBitmapDC();
- void ReleaseBitmapDC();
- bool IsBitmapDCCreated() const;
-#endif
-
-#if defined(__APPLE__)
- void ReleaseBitmapContext();
-#endif // defined(__APPLE__)
-
- // Sets the transform and clip operations. This will not update the CGContext,
- // but will mark the config as dirty. The next call of LoadConfig will
- // pick up these changes.
- void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
-
- // Loads the current transform and clip into the context. Can be called even
- // when |bitmap_context_| is NULL (will be a NOP).
- void LoadConfig();
-
- const SkMatrix& transform() const {
- return transform_;
- }
-
- PlatformContext bitmap_context() {
- return bitmap_context_;
- }
-
- private:
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
- friend class base::RefCounted<BitmapPlatformDeviceData>;
-#endif
- virtual ~BitmapPlatformDeviceData();
-
- // Lazily-created graphics context used to draw into the bitmap.
- PlatformContext bitmap_context_;
-
-#if defined(WIN32)
- // Lazily-created DC used to draw into the bitmap, see GetBitmapDC().
- HDC hdc_;
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
- cairo_surface_t *const surface_;
-#endif
-
- // True when there is a transform or clip that has not been set to the
- // context. The context is retrieved for every text operation, and the
- // transform and clip do not change as much. We can save time by not loading
- // the clip and transform for every one.
- bool config_dirty_;
-
- // Translation assigned to the context: we need to keep track of this
- // separately so it can be updated even if the context isn't created yet.
- SkMatrix transform_;
-
- // The current clipping
- SkRegion clip_region_;
-
- // Disallow copy & assign.
- BitmapPlatformDeviceData(const BitmapPlatformDeviceData&);
- BitmapPlatformDeviceData& operator=(const BitmapPlatformDeviceData&);
-};
-
-} // namespace skia
-
-#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
diff --git a/chromium/skia/ext/bitmap_platform_device_mac.cc b/chromium/skia/ext/bitmap_platform_device_mac.cc
index 66298b28f05..a62c3cf0abf 100644
--- a/chromium/skia/ext/bitmap_platform_device_mac.cc
+++ b/chromium/skia/ext/bitmap_platform_device_mac.cc
@@ -9,7 +9,7 @@
#include "base/mac/mac_util.h"
#include "base/memory/ref_counted.h"
-#include "skia/ext/bitmap_platform_device_data.h"
+#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/platform_canvas.h"
#include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkMatrix.h"
@@ -57,37 +57,13 @@ static CGContextRef CGContextForData(void* data, int width, int height) {
} // namespace
-BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData(
- CGContextRef bitmap)
- : bitmap_context_(bitmap),
- config_dirty_(true), // Want to load the config next time.
- transform_(SkMatrix::I()) {
- SkASSERT(bitmap_context_);
- // Initialize the clip region to the entire bitmap.
-
- SkIRect rect;
- rect.set(0, 0,
- CGBitmapContextGetWidth(bitmap_context_),
- CGBitmapContextGetHeight(bitmap_context_));
- clip_region_ = SkRegion(rect);
- CGContextRetain(bitmap_context_);
- // We must save the state once so that we can use the restore/save trick
- // in LoadConfig().
- CGContextSaveGState(bitmap_context_);
-}
-
-BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() {
- if (bitmap_context_)
- CGContextRelease(bitmap_context_);
-}
-
-void BitmapPlatformDevice::BitmapPlatformDeviceData::ReleaseBitmapContext() {
+void BitmapPlatformDevice::ReleaseBitmapContext() {
SkASSERT(bitmap_context_);
CGContextRelease(bitmap_context_);
bitmap_context_ = NULL;
}
-void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip(
+void BitmapPlatformDevice::SetMatrixClip(
const SkMatrix& transform,
const SkRegion& region) {
transform_ = transform;
@@ -95,7 +71,7 @@ void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip(
config_dirty_ = true;
}
-void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() {
+void BitmapPlatformDevice::LoadConfig() {
if (!config_dirty_ || !bitmap_context_)
return; // Nothing to do.
config_dirty_ = false;
@@ -127,7 +103,8 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
SkBitmap bitmap;
// TODO: verify that the CG Context's pixels will have tight rowbytes or pass in the correct
// rowbytes for the case when context != NULL.
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
void* data;
if (context) {
@@ -139,8 +116,6 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
data = bitmap.getPixels();
}
- bitmap.setIsOpaque(is_opaque);
-
// If we were given data, then don't clobber it!
#ifndef NDEBUG
if (!context && is_opaque) {
@@ -157,8 +132,7 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
} else
CGContextRetain(context);
- BitmapPlatformDevice* rv = new BitmapPlatformDevice(
- skia::AdoptRef(new BitmapPlatformDeviceData(context)), bitmap);
+ BitmapPlatformDevice* rv = new BitmapPlatformDevice(context, bitmap);
// The device object took ownership of the graphics context with its own
// CGContextRetain call.
@@ -197,37 +171,53 @@ BitmapPlatformDevice* BitmapPlatformDevice::CreateWithData(uint8_t* data,
// The device will own the bitmap, which corresponds to also owning the pixel
// data. Therefore, we do not transfer ownership to the SkBitmapDevice's bitmap.
BitmapPlatformDevice::BitmapPlatformDevice(
- const skia::RefPtr<BitmapPlatformDeviceData>& data, const SkBitmap& bitmap)
+ CGContextRef context, const SkBitmap& bitmap)
: SkBitmapDevice(bitmap),
- data_(data) {
+ bitmap_context_(context),
+ config_dirty_(true), // Want to load the config next time.
+ transform_(SkMatrix::I()) {
SetPlatformDevice(this, this);
+ SkASSERT(bitmap_context_);
+ // Initialize the clip region to the entire bitmap.
+
+ SkIRect rect;
+ rect.set(0, 0,
+ CGBitmapContextGetWidth(bitmap_context_),
+ CGBitmapContextGetHeight(bitmap_context_));
+ clip_region_ = SkRegion(rect);
+ CGContextRetain(bitmap_context_);
+ // We must save the state once so that we can use the restore/save trick
+ // in LoadConfig().
+ CGContextSaveGState(bitmap_context_);
}
BitmapPlatformDevice::~BitmapPlatformDevice() {
+ if (bitmap_context_)
+ CGContextRelease(bitmap_context_);
}
CGContextRef BitmapPlatformDevice::GetBitmapContext() {
- data_->LoadConfig();
- return data_->bitmap_context();
+ LoadConfig();
+ return bitmap_context_;
}
void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
const SkRegion& region,
const SkClipStack&) {
- data_->SetMatrixClip(transform, region);
+ SetMatrixClip(transform, region);
}
void BitmapPlatformDevice::DrawToNativeContext(CGContextRef context, int x,
int y, const CGRect* src_rect) {
bool created_dc = false;
- if (!data_->bitmap_context()) {
+ if (!bitmap_context_) {
created_dc = true;
GetBitmapContext();
}
// this should not make a copy of the bits, since we're not doing
// anything to trigger copy on write
- CGImageRef image = CGBitmapContextCreateImage(data_->bitmap_context());
+ CGImageRef image = CGBitmapContextCreateImage(bitmap_context_);
CGRect bounds;
bounds.origin.x = x;
bounds.origin.y = y;
@@ -245,7 +235,7 @@ void BitmapPlatformDevice::DrawToNativeContext(CGContextRef context, int x,
CGImageRelease(image);
if (created_dc)
- data_->ReleaseBitmapContext();
+ ReleaseBitmapContext();
}
SkBaseDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
@@ -285,13 +275,13 @@ bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
if (RasterDeviceTooBigToAllocate(width, height))
return false;
- bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4);
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap_.allocPixels())
return false;
if (!is_opaque)
bitmap_.eraseColor(0);
- bitmap_.setIsOpaque(is_opaque);
surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(),
bitmap_.height());
diff --git a/chromium/skia/ext/bitmap_platform_device_mac.h b/chromium/skia/ext/bitmap_platform_device_mac.h
index 07b008419c4..00b030930e4 100644
--- a/chromium/skia/ext/bitmap_platform_device_mac.h
+++ b/chromium/skia/ext/bitmap_platform_device_mac.h
@@ -60,21 +60,40 @@ class SK_API BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice
const SkClipStack&) OVERRIDE;
protected:
- // Reference counted data that can be shared between multiple devices. This
- // allows copy constructors and operator= for devices to work properly. The
- // bitmaps used by the base device class are already refcounted and copyable.
- class BitmapPlatformDeviceData;
-
- BitmapPlatformDevice(const skia::RefPtr<BitmapPlatformDeviceData>& data,
+ BitmapPlatformDevice(CGContextRef context,
const SkBitmap& bitmap);
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config, int width,
int height, bool isOpaque,
Usage usage) OVERRIDE;
- // Data associated with this device, guaranteed non-null.
- skia::RefPtr<BitmapPlatformDeviceData> data_;
+ private:
+ void ReleaseBitmapContext();
+
+ // Sets the transform and clip operations. This will not update the CGContext,
+ // but will mark the config as dirty. The next call of LoadConfig will
+ // pick up these changes.
+ void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
+
+ // Loads the current transform and clip into the context. Can be called even
+ // when |bitmap_context_| is NULL (will be a NOP).
+ void LoadConfig();
+
+ // Lazily-created graphics context used to draw into the bitmap.
+ CGContextRef bitmap_context_;
+
+ // True when there is a transform or clip that has not been set to the
+ // context. The context is retrieved for every text operation, and the
+ // transform and clip do not change as much. We can save time by not loading
+ // the clip and transform for every one.
+ bool config_dirty_;
+
+ // Translation assigned to the context: we need to keep track of this
+ // separately so it can be updated even if the context isn't created yet.
+ SkMatrix transform_;
+ // The current clipping
+ SkRegion clip_region_;
DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
};
diff --git a/chromium/skia/ext/bitmap_platform_device_android.cc b/chromium/skia/ext/bitmap_platform_device_skia.cc
index 32f447f4ac3..6f8370d6df9 100644
--- a/chromium/skia/ext/bitmap_platform_device_android.cc
+++ b/chromium/skia/ext/bitmap_platform_device_skia.cc
@@ -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 {
@@ -10,9 +10,9 @@ namespace skia {
BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (bitmap.allocPixels()) {
- bitmap.setIsOpaque(is_opaque);
// Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it
// is not opaque.
if (!is_opaque)
@@ -35,13 +35,13 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque,
uint8_t* data) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (data)
bitmap.setPixels(data);
else if (!bitmap.allocPixels())
return NULL;
- bitmap.setIsOpaque(is_opaque);
return new BitmapPlatformDevice(bitmap);
}
@@ -87,11 +87,11 @@ PlatformBitmap::~PlatformBitmap() {
}
bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
- bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap_.allocPixels())
return false;
- bitmap_.setIsOpaque(is_opaque);
surface_ = bitmap_.getPixels();
return true;
}
diff --git a/chromium/skia/ext/bitmap_platform_device_android.h b/chromium/skia/ext/bitmap_platform_device_skia.h
index 4e1735f1f5a..853f58bbe50 100644
--- a/chromium/skia/ext/bitmap_platform_device_android.h
+++ b/chromium/skia/ext/bitmap_platform_device_skia.h
@@ -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 {
@@ -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_
diff --git a/chromium/skia/ext/bitmap_platform_device_win.cc b/chromium/skia/ext/bitmap_platform_device_win.cc
index 0088403bbc2..ed01a35d229 100644
--- a/chromium/skia/ext/bitmap_platform_device_win.cc
+++ b/chromium/skia/ext/bitmap_platform_device_win.cc
@@ -5,8 +5,9 @@
#include <windows.h>
#include <psapi.h>
+#include "base/logging.h"
+#include "base/debug/alias.h"
#include "skia/ext/bitmap_platform_device_win.h"
-#include "skia/ext/bitmap_platform_device_data.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkRefCnt.h"
@@ -57,6 +58,62 @@ HBITMAP CreateHBitmap(int width, int height, bool is_opaque,
HBITMAP hbitmap = CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&hdr),
0, data, shared_section, 0);
+
+ // If this call fails, we're gonna crash hard. Try to get some useful
+ // information out before we crash for post-mortem analysis.
+ if (!hbitmap) {
+ // Make sure parameters are saved in the minidump.
+ base::debug::Alias(&width);
+ base::debug::Alias(&height);
+
+ int last_error = GetLastError();
+ base::debug::Alias(&last_error);
+
+ int num_gdi_handles = GetGuiResources(GetCurrentProcess(),
+ GR_GDIOBJECTS);
+ if (num_gdi_handles == 0) {
+ int get_gui_resources_error = GetLastError();
+ base::debug::Alias(&get_gui_resources_error);
+ CHECK(false);
+ }
+
+ base::debug::Alias(&num_gdi_handles);
+ const int kLotsOfHandles = 9990;
+ if (num_gdi_handles > kLotsOfHandles)
+ CHECK(false);
+
+ PROCESS_MEMORY_COUNTERS_EX pmc;
+ pmc.cb = sizeof(pmc);
+ if (!GetProcessMemoryInfo(GetCurrentProcess(),
+ reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmc),
+ sizeof(pmc))) {
+ CHECK(false);
+ }
+ const size_t kLotsOfMemory = 1500 * 1024 * 1024; // 1.5GB
+ if (pmc.PagefileUsage > kLotsOfMemory)
+ CHECK(false);
+ if (pmc.PrivateUsage > kLotsOfMemory)
+ CHECK(false);
+
+ // Huh, that's weird. We don't have crazy handle count, we don't have
+ // ridiculous memory usage. Try to allocate a small bitmap and see if that
+ // fails too.
+ hdr.biWidth = 5;
+ hdr.biHeight = 5;
+ void* small_data;
+ HBITMAP small_bitmap = CreateDIBSection(
+ NULL, reinterpret_cast<BITMAPINFO*>(&hdr),
+ 0, &small_data, shared_section, 0);
+ if (!small_bitmap)
+ CHECK(false);
+ BITMAP bitmap_data;
+ if (GetObject(small_bitmap, sizeof(BITMAP), &bitmap_data)) {
+ if (!DeleteObject(small_bitmap))
+ CHECK(false);
+ }
+ // No idea what's going on. Die!
+ CHECK(false);
+ }
return hbitmap;
}
@@ -86,57 +143,32 @@ void PlatformBitmapPixelRef::onUnlockPixels() {
namespace skia {
-BitmapPlatformDevice::BitmapPlatformDeviceData::BitmapPlatformDeviceData(
- HBITMAP hbitmap)
- : bitmap_context_(hbitmap),
- hdc_(NULL),
- config_dirty_(true), // Want to load the config next time.
- transform_(SkMatrix::I()) {
- // Initialize the clip region to the entire bitmap.
- BITMAP bitmap_data;
- if (GetObject(bitmap_context_, sizeof(BITMAP), &bitmap_data)) {
- SkIRect rect;
- rect.set(0, 0, bitmap_data.bmWidth, bitmap_data.bmHeight);
- clip_region_ = SkRegion(rect);
- }
-}
-
-BitmapPlatformDevice::BitmapPlatformDeviceData::~BitmapPlatformDeviceData() {
- if (hdc_)
- ReleaseBitmapDC();
-
- // this will free the bitmap data as well as the bitmap handle
- DeleteObject(bitmap_context_);
-}
-
-HDC BitmapPlatformDevice::BitmapPlatformDeviceData::GetBitmapDC() {
+HDC BitmapPlatformDevice::GetBitmapDC() {
if (!hdc_) {
hdc_ = CreateCompatibleDC(NULL);
InitializeDC(hdc_);
- HGDIOBJ old_bitmap = SelectObject(hdc_, bitmap_context_);
- // When the memory DC is created, its display surface is exactly one
- // monochrome pixel wide and one monochrome pixel high. Since we select our
- // own bitmap, we must delete the previous one.
- DeleteObject(old_bitmap);
+ old_hbitmap_ = static_cast<HBITMAP>(SelectObject(hdc_, hbitmap_));
}
LoadConfig();
return hdc_;
}
-void BitmapPlatformDevice::BitmapPlatformDeviceData::ReleaseBitmapDC() {
+void BitmapPlatformDevice::ReleaseBitmapDC() {
SkASSERT(hdc_);
+ SelectObject(hdc_, old_hbitmap_);
DeleteDC(hdc_);
hdc_ = NULL;
+ old_hbitmap_ = NULL;
}
-bool BitmapPlatformDevice::BitmapPlatformDeviceData::IsBitmapDCCreated()
+bool BitmapPlatformDevice::IsBitmapDCCreated()
const {
return hdc_ != NULL;
}
-void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip(
+void BitmapPlatformDevice::SetMatrixClip(
const SkMatrix& transform,
const SkRegion& region) {
transform_ = transform;
@@ -144,7 +176,7 @@ void BitmapPlatformDevice::BitmapPlatformDeviceData::SetMatrixClip(
config_dirty_ = true;
}
-void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() {
+void BitmapPlatformDevice::LoadConfig() {
if (!config_dirty_ || !hdc_)
return; // Nothing to do.
config_dirty_ = false;
@@ -171,9 +203,11 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(
return NULL;
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap.setPixels(data);
- bitmap.setIsOpaque(is_opaque);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
+ RefPtr<SkPixelRef> pixel_ref = AdoptRef(new PlatformBitmapPixelRef(hbitmap,
+ data));
+ bitmap.setPixelRef(pixel_ref.get());
#ifndef NDEBUG
// If we were given data, then don't clobber it!
@@ -185,8 +219,7 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(
// The device object will take ownership of the HBITMAP. The initial refcount
// of the data object will be 1, which is what the constructor expects.
- return new BitmapPlatformDevice(
- skia::AdoptRef(new BitmapPlatformDeviceData(hbitmap)), bitmap);
+ return new BitmapPlatformDevice(hbitmap, bitmap);
}
// static
@@ -209,22 +242,35 @@ BitmapPlatformDevice* BitmapPlatformDevice::CreateAndClear(int width,
// The device will own the HBITMAP, which corresponds to also owning the pixel
// data. Therefore, we do not transfer ownership to the SkBitmapDevice's bitmap.
BitmapPlatformDevice::BitmapPlatformDevice(
- const skia::RefPtr<BitmapPlatformDeviceData>& data,
+ HBITMAP hbitmap,
const SkBitmap& bitmap)
: SkBitmapDevice(bitmap),
- data_(data) {
+ hbitmap_(hbitmap),
+ old_hbitmap_(NULL),
+ hdc_(NULL),
+ config_dirty_(true), // Want to load the config next time.
+ transform_(SkMatrix::I()) {
// The data object is already ref'ed for us by create().
SkDEBUGCODE(begin_paint_count_ = 0);
SetPlatformDevice(this, this);
+ // Initialize the clip region to the entire bitmap.
+ BITMAP bitmap_data;
+ if (GetObject(hbitmap_, sizeof(BITMAP), &bitmap_data)) {
+ SkIRect rect;
+ rect.set(0, 0, bitmap_data.bmWidth, bitmap_data.bmHeight);
+ clip_region_ = SkRegion(rect);
+ }
}
BitmapPlatformDevice::~BitmapPlatformDevice() {
SkASSERT(begin_paint_count_ == 0);
+ if (hdc_)
+ ReleaseBitmapDC();
}
HDC BitmapPlatformDevice::BeginPlatformPaint() {
SkDEBUGCODE(begin_paint_count_++);
- return data_->GetBitmapDC();
+ return GetBitmapDC();
}
void BitmapPlatformDevice::EndPlatformPaint() {
@@ -235,12 +281,12 @@ void BitmapPlatformDevice::EndPlatformPaint() {
void BitmapPlatformDevice::setMatrixClip(const SkMatrix& transform,
const SkRegion& region,
const SkClipStack&) {
- data_->SetMatrixClip(transform, region);
+ SetMatrixClip(transform, region);
}
void BitmapPlatformDevice::DrawToNativeContext(HDC dc, int x, int y,
const RECT* src_rect) {
- bool created_dc = !data_->IsBitmapDCCreated();
+ bool created_dc = !IsBitmapDCCreated();
HDC source_dc = BeginPlatformPaint();
RECT temp_rect;
@@ -286,17 +332,17 @@ void BitmapPlatformDevice::DrawToNativeContext(HDC dc, int x, int y,
copy_height,
blend_function);
}
- LoadTransformToDC(source_dc, data_->transform());
+ LoadTransformToDC(source_dc, transform_);
EndPlatformPaint();
if (created_dc)
- data_->ReleaseBitmapDC();
+ ReleaseBitmapDC();
}
const SkBitmap& BitmapPlatformDevice::onAccessBitmap() {
// FIXME(brettw) OPTIMIZATION: We should only flush if we know a GDI
// operation has occurred on our DC.
- if (data_->IsBitmapDCCreated())
+ if (IsBitmapDCCreated())
GdiFlush();
return SkBitmapDevice::onAccessBitmap();
}
@@ -343,11 +389,12 @@ bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
HGDIOBJ stock_bitmap = SelectObject(surface_, hbitmap);
platform_extra_ = reinterpret_cast<intptr_t>(stock_bitmap);
- bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
// PlatformBitmapPixelRef takes ownership of |hbitmap|.
- bitmap_.setPixelRef(
- skia::AdoptRef(new PlatformBitmapPixelRef(hbitmap, data)).get());
- bitmap_.setIsOpaque(is_opaque);
+ RefPtr<SkPixelRef> pixel_ref = AdoptRef(new PlatformBitmapPixelRef(hbitmap,
+ data));
+ bitmap_.setPixelRef(pixel_ref.get());
bitmap_.lockPixels();
return true;
diff --git a/chromium/skia/ext/bitmap_platform_device_win.h b/chromium/skia/ext/bitmap_platform_device_win.h
index 1261e51b6c5..5d8afdc7781 100644
--- a/chromium/skia/ext/bitmap_platform_device_win.h
+++ b/chromium/skia/ext/bitmap_platform_device_win.h
@@ -19,13 +19,11 @@ namespace skia {
// This pixel data is provided to the bitmap that the device contains so that it
// can be shared.
//
-// The device owns the pixel data, when the device goes away, the pixel data
-// also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses
-// reference counting for the pixel data. In normal Skia, you could assign
-// another bitmap to this device's bitmap and everything will work properly.
-// For us, that other bitmap will become invalid as soon as the device becomes
-// invalid, which may lead to subtle bugs. Therefore, DO NOT ASSIGN THE
-// DEVICE'S PIXEL DATA TO ANOTHER BITMAP, make sure you copy instead.
+// The GDI bitmap created for drawing is actually owned by a
+// PlatformBitmapPixelRef, and stored in an SkBitmap via the normal skia
+// SkPixelRef refcounting mechanism. In this way, the GDI bitmap can outlive
+// the device created to draw into it. So it is safe to call accessBitmap() on
+// the device, and retain the returned SkBitmap.
class SK_API BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {
public:
// Factory function. is_opaque should be set if the caller knows the bitmap
@@ -75,17 +73,47 @@ class SK_API BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice
Usage usage) OVERRIDE;
private:
- // Reference counted data that can be shared between multiple devices. This
- // allows copy constructors and operator= for devices to work properly. The
- // bitmaps used by the base device class are already refcounted and copyable.
- class BitmapPlatformDeviceData;
-
// Private constructor.
- BitmapPlatformDevice(const skia::RefPtr<BitmapPlatformDeviceData>& data,
- const SkBitmap& bitmap);
-
- // Data associated with this device, guaranteed non-null.
- skia::RefPtr<BitmapPlatformDeviceData> data_;
+ BitmapPlatformDevice(HBITMAP hbitmap, const SkBitmap& bitmap);
+
+ // Bitmap into which the drawing will be done. This bitmap not owned by this
+ // class, but by the BitmapPlatformPixelRef inside the device's SkBitmap.
+ // It's only stored here in order to lazy-create the DC (below).
+ HBITMAP hbitmap_;
+
+ // Previous bitmap held by the DC. This will be selected back before the
+ // DC is destroyed.
+ HBITMAP old_hbitmap_;
+
+ // Lazily-created DC used to draw into the bitmap; see GetBitmapDC().
+ HDC hdc_;
+
+ // True when there is a transform or clip that has not been set to the
+ // context. The context is retrieved for every text operation, and the
+ // transform and clip do not change as much. We can save time by not loading
+ // the clip and transform for every one.
+ bool config_dirty_;
+
+ // Translation assigned to the context: we need to keep track of this
+ // separately so it can be updated even if the context isn't created yet.
+ SkMatrix transform_;
+
+ // The current clipping region.
+ SkRegion clip_region_;
+
+ // Create/destroy hdc_, which is the memory DC for our bitmap data.
+ HDC GetBitmapDC();
+ void ReleaseBitmapDC();
+ bool IsBitmapDCCreated() const;
+
+ // Sets the transform and clip operations. This will not update the DC,
+ // but will mark the config as dirty. The next call of LoadConfig will
+ // pick up these changes.
+ void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
+
+ // Loads the current transform and clip into the context. Can be called even
+ // when |hbitmap_| is NULL (will be a NOP).
+ void LoadConfig();
#ifdef SK_DEBUG
int begin_paint_count_;
diff --git a/chromium/skia/ext/image_operations.cc b/chromium/skia/ext/image_operations.cc
index c61da0cfa53..3bb765ff289 100644
--- a/chromium/skia/ext/image_operations.cc
+++ b/chromium/skia/ext/image_operations.cc
@@ -394,7 +394,7 @@ SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
// Render into subpixels.
SkBitmap result;
result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(),
- dest_subset.height());
+ dest_subset.height(), 0, img.alphaType());
result.allocPixels(allocator, NULL);
if (!result.readyToDraw())
return img;
@@ -455,7 +455,6 @@ SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
src_row += h * row_words;
dst_row += result.rowBytes() / 4;
}
- result.setIsOpaque(img.isOpaque());
return result;
#else
return SkBitmap();
@@ -510,8 +509,8 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
// Convolve into the result.
SkBitmap result;
- result.setConfig(SkBitmap::kARGB_8888_Config,
- dest_subset.width(), dest_subset.height());
+ result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(),
+ dest_subset.height(), 0, source.alphaType());
result.allocPixels(allocator, NULL);
if (!result.readyToDraw())
return SkBitmap();
@@ -522,9 +521,6 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
static_cast<unsigned char*>(result.getPixels()),
true);
- // Preserve the "opaque" flag for use as an optimization later.
- result.setIsOpaque(source.isOpaque());
-
base::TimeDelta delta = base::TimeTicks::Now() - resize_start;
UMA_HISTOGRAM_TIMES("Image.ResampleMS", delta);
diff --git a/chromium/skia/ext/lazy_pixel_ref.cc b/chromium/skia/ext/lazy_pixel_ref.cc
index 784fae47419..ef74089f3e7 100644
--- a/chromium/skia/ext/lazy_pixel_ref.cc
+++ b/chromium/skia/ext/lazy_pixel_ref.cc
@@ -6,7 +6,13 @@
namespace skia {
-LazyPixelRef::LazyPixelRef() : SkPixelRef(0) {
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
+// DEPRECATED -- will remove after blink updates to pass info
+LazyPixelRef::LazyPixelRef() {
+}
+#endif
+
+LazyPixelRef::LazyPixelRef(const SkImageInfo& info) : SkPixelRef(info) {
}
LazyPixelRef::~LazyPixelRef() {
diff --git a/chromium/skia/ext/lazy_pixel_ref.h b/chromium/skia/ext/lazy_pixel_ref.h
index fff4c385add..d25fc7167ee 100644
--- a/chromium/skia/ext/lazy_pixel_ref.h
+++ b/chromium/skia/ext/lazy_pixel_ref.h
@@ -14,7 +14,12 @@ namespace skia {
// thread.
class SK_API LazyPixelRef : public SkPixelRef {
public:
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
+ // DEPRECATED -- will remove once blink updates to pass info
LazyPixelRef();
+#endif
+
+ explicit LazyPixelRef(const SkImageInfo& info);
virtual ~LazyPixelRef();
struct PrepareParams {
diff --git a/chromium/skia/ext/lazy_pixel_ref_utils.cc b/chromium/skia/ext/lazy_pixel_ref_utils.cc
index 00ccda22fa2..4b3d297e025 100644
--- a/chromium/skia/ext/lazy_pixel_ref_utils.cc
+++ b/chromium/skia/ext/lazy_pixel_ref_utils.cc
@@ -61,11 +61,7 @@ class GatherPixelRefDevice : public SkBitmapDevice {
SkBitmap bitmap;
if (GetBitmapFromPaint(paint, &bitmap)) {
SkRect clip_rect = SkRect::Make(draw.fRC->getBounds());
- SkRect canvas_rect = SkRect::MakeWH(width(), height());
- SkRect paint_rect = SkRect::MakeEmpty();
- paint_rect.intersect(canvas_rect, clip_rect);
-
- AddBitmap(bitmap, paint_rect);
+ AddBitmap(bitmap, clip_rect);
}
}
@@ -334,7 +330,10 @@ class GatherPixelRefDevice : public SkBitmapDevice {
LazyPixelRefSet* lazy_pixel_ref_set_;
void AddBitmap(const SkBitmap& bm, const SkRect& rect) {
- lazy_pixel_ref_set_->Add(bm.pixelRef(), rect);
+ SkRect canvas_rect = SkRect::MakeWH(width(), height());
+ SkRect paint_rect = SkRect::MakeEmpty();
+ paint_rect.intersect(rect, canvas_rect);
+ lazy_pixel_ref_set_->Add(bm.pixelRef(), paint_rect);
}
bool GetBitmapFromPaint(const SkPaint& paint, SkBitmap* bm) {
diff --git a/chromium/skia/ext/lazy_pixel_ref_utils_unittest.cc b/chromium/skia/ext/lazy_pixel_ref_utils_unittest.cc
index a9f60a23ab1..054613341fd 100644
--- a/chromium/skia/ext/lazy_pixel_ref_utils_unittest.cc
+++ b/chromium/skia/ext/lazy_pixel_ref_utils_unittest.cc
@@ -29,7 +29,7 @@ class TestPixelRef : public SkPixelRef {
TestPixelRef(int width, int height);
virtual ~TestPixelRef();
- virtual SkFlattenable::Factory getFactory() OVERRIDE;
+ virtual SkFlattenable::Factory getFactory() const OVERRIDE;
virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE;
virtual void onUnlockPixels() OVERRIDE {}
virtual SkPixelRef* deepCopy(SkBitmap::Config config, const SkIRect* subset)
@@ -44,7 +44,7 @@ class TestLazyPixelRef : public skia::LazyPixelRef {
TestLazyPixelRef(int width, int height);
virtual ~TestLazyPixelRef();
- virtual SkFlattenable::Factory getFactory() OVERRIDE;
+ virtual SkFlattenable::Factory getFactory() const OVERRIDE;
virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE;
virtual void onUnlockPixels() OVERRIDE {}
virtual bool PrepareToDecode(const PrepareParams& params) OVERRIDE;
@@ -94,7 +94,7 @@ TestPixelRef::TestPixelRef(int width, int height)
TestPixelRef::~TestPixelRef() {}
-SkFlattenable::Factory TestPixelRef::getFactory() { return NULL; }
+SkFlattenable::Factory TestPixelRef::getFactory() const { return NULL; }
void* TestPixelRef::onLockPixels(SkColorTable** color_table) {
return pixels_.get();
@@ -111,7 +111,7 @@ TestLazyPixelRef::TestLazyPixelRef(int width, int height)
TestLazyPixelRef::~TestLazyPixelRef() {}
-SkFlattenable::Factory TestLazyPixelRef::getFactory() { return NULL; }
+SkFlattenable::Factory TestLazyPixelRef::getFactory() const { return NULL; }
void* TestLazyPixelRef::onLockPixels(SkColorTable** color_table) {
return pixels_.get();
@@ -474,8 +474,9 @@ TEST(LazyPixelRefUtilsTest, DrawBitmap) {
canvas->restore();
canvas->save();
+ canvas->translate(1, 0);
canvas->rotate(90);
- // At (0, 0), rotated 90 degrees
+ // At (1, 0), rotated 90 degrees
canvas->drawBitmap(fourth, 0, 0);
canvas->restore();
@@ -496,7 +497,7 @@ TEST(LazyPixelRefUtilsTest, DrawBitmap) {
gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect));
EXPECT_FLOAT_RECT_EQ(gfx::RectF(50, 50, 50, 50),
gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect));
- EXPECT_FLOAT_RECT_EQ(gfx::RectF(-1, 0, 1, 50),
+ EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 1, 50),
gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect));
EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 60),
gfx::SkRectToRectF(pixel_refs[4].pixel_ref_rect));
diff --git a/chromium/skia/ext/platform_canvas_unittest.cc b/chromium/skia/ext/platform_canvas_unittest.cc
index d0d83dd3130..a9ae148af4f 100644
--- a/chromium/skia/ext/platform_canvas_unittest.cc
+++ b/chromium/skia/ext/platform_canvas_unittest.cc
@@ -187,9 +187,6 @@ const int kInnerY = 5;
const int kInnerW = 2;
const int kInnerH = 3;
-// Radius used by some tests to draw a rounded-corner rectangle.
-const SkScalar kRadius = 2.0;
-
}
// This just checks that our checking code is working properly, it just uses
@@ -381,6 +378,7 @@ TEST(PlatformCanvas, TranslateLayer) {
SkRect rect;
rect.iset(kInnerX - 1, kInnerY - 1,
kInnerX + kInnerW, kInnerY + kInnerH);
+ const SkScalar kRadius = 2.0;
path.addRoundRect(rect, kRadius, kRadius);
canvas->clipPath(path);
diff --git a/chromium/skia/ext/platform_device.h b/chromium/skia/ext/platform_device.h
index d46b5d47a3c..7e77ff1a4c7 100644
--- a/chromium/skia/ext/platform_device.h
+++ b/chromium/skia/ext/platform_device.h
@@ -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)
@@ -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
diff --git a/chromium/skia/ext/skia_utils_ios.mm b/chromium/skia/ext/skia_utils_ios.mm
index 80c50fdec21..6f4814a2dd3 100644
--- a/chromium/skia/ext/skia_utils_ios.mm
+++ b/chromium/skia/ext/skia_utils_ios.mm
@@ -18,11 +18,15 @@ SkBitmap CGImageToSkBitmap(CGImageRef image, CGSize size, bool is_opaque) {
if (!image)
return bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width, size.height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ size.width,
+ size.height,
+ 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
+
if (!bitmap.allocPixels())
return bitmap;
- bitmap.setIsOpaque(is_opaque);
void* data = bitmap.getPixels();
// Allocate a bitmap context with 4 components per pixel (BGRA). Apple
diff --git a/chromium/skia/ext/skia_utils_mac.h b/chromium/skia/ext/skia_utils_mac.h
index e6f7b35bbc2..fd000f3543d 100644
--- a/chromium/skia/ext/skia_utils_mac.h
+++ b/chromium/skia/ext/skia_utils_mac.h
@@ -78,11 +78,15 @@ SK_API NSColor* SkColorToSRGBNSColor(SkColor color);
SK_API SkBitmap CGImageToSkBitmap(CGImageRef image);
// Draws an NSImage with a given size into a SkBitmap.
-SK_API SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque);
+SK_API SkBitmap NSImageToSkBitmapWithColorSpace(NSImage* image,
+ bool is_opaque,
+ CGColorSpaceRef color_space);
// Draws an NSImageRep with a given size into a SkBitmap.
-SK_API SkBitmap NSImageRepToSkBitmap(
- NSImageRep* image, NSSize size, bool is_opaque);
+SK_API SkBitmap NSImageRepToSkBitmapWithColorSpace(NSImageRep* image,
+ NSSize size,
+ bool is_opaque,
+ CGColorSpaceRef colorspace);
// Given an SkBitmap, return an autoreleased NSBitmapImageRep in the generic
// color space.
diff --git a/chromium/skia/ext/skia_utils_mac.mm b/chromium/skia/ext/skia_utils_mac.mm
index 50217d00599..dcc2cccffc6 100644
--- a/chromium/skia/ext/skia_utils_mac.mm
+++ b/chromium/skia/ext/skia_utils_mac.mm
@@ -17,23 +17,26 @@
namespace {
// Draws an NSImage or an NSImageRep with a given size into a SkBitmap.
-SkBitmap NSImageOrNSImageRepToSkBitmap(
+SkBitmap NSImageOrNSImageRepToSkBitmapWithColorSpace(
NSImage* image,
NSImageRep* image_rep,
NSSize size,
- bool is_opaque) {
+ bool is_opaque,
+ CGColorSpaceRef color_space) {
// Only image or image_rep should be provided, not both.
DCHECK((image != 0) ^ (image_rep != 0));
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width, size.height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ size.width,
+ size.height,
+ 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
+
if (!bitmap.allocPixels())
return bitmap; // Return |bitmap| which should respond true to isNull().
- bitmap.setIsOpaque(is_opaque);
- base::ScopedCFTypeRef<CGColorSpaceRef> color_space(
- CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
void* data = bitmap.getPixels();
// Allocate a bitmap context with 4 components per pixel (BGRA). Apple
@@ -217,13 +220,18 @@ SkBitmap CGImageToSkBitmap(CGImageRef image) {
return bitmap;
}
-SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque) {
- return NSImageOrNSImageRepToSkBitmap(image, nil, size, is_opaque);
+SkBitmap NSImageToSkBitmapWithColorSpace(
+ NSImage* image, bool is_opaque, CGColorSpaceRef color_space) {
+ return NSImageOrNSImageRepToSkBitmapWithColorSpace(
+ image, nil, [image size], is_opaque, color_space);
}
-SkBitmap NSImageRepToSkBitmap(
- NSImageRep* image_rep, NSSize size, bool is_opaque) {
- return NSImageOrNSImageRepToSkBitmap(nil, image_rep, size, is_opaque);
+SkBitmap NSImageRepToSkBitmapWithColorSpace(NSImageRep* image_rep,
+ NSSize size,
+ bool is_opaque,
+ CGColorSpaceRef color_space) {
+ return NSImageOrNSImageRepToSkBitmapWithColorSpace(
+ nil, image_rep, size, is_opaque, color_space);
}
NSBitmapImageRep* SkBitmapToNSBitmapImageRep(const SkBitmap& skiaBitmap) {
diff --git a/chromium/skia/ext/skia_utils_mac_unittest.mm b/chromium/skia/ext/skia_utils_mac_unittest.mm
index 51b957eb384..bc0d422502e 100644
--- a/chromium/skia/ext/skia_utils_mac_unittest.mm
+++ b/chromium/skia/ext/skia_utils_mac_unittest.mm
@@ -4,6 +4,7 @@
#include "skia/ext/skia_utils_mac.mm"
+#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsobject.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -102,17 +103,15 @@ void SkiaUtilsMacTest::TestSkBitmap(const SkBitmap& bitmap, bool isred) {
int y = bitmap.height() > 17 ? 17 : 0;
SkColor color = bitmap.getColor(x, y);
- // Be tolerant of lossy color space conversions.
- // TODO(sail): Fix color space conversion issues, http://crbug.com/79946
if (isred) {
- EXPECT_GT(SkColorGetR(color), 245u);
- EXPECT_LT(SkColorGetB(color), 10u);
+ EXPECT_EQ(255u, SkColorGetR(color));
+ EXPECT_EQ(0u, SkColorGetB(color));
} else {
- EXPECT_LT(SkColorGetR(color), 10u);
- EXPECT_GT(SkColorGetB(color), 245u);
+ EXPECT_EQ(0u, SkColorGetR(color));
+ EXPECT_EQ(255u, SkColorGetB(color));
}
- EXPECT_LT(SkColorGetG(color), 10u);
- EXPECT_GT(SkColorGetA(color), 245u);
+ EXPECT_EQ(0u, SkColorGetG(color));
+ EXPECT_EQ(255u, SkColorGetA(color));
}
// setBitmapDevice has been deprecated/removed. Is this test still useful?
@@ -206,7 +205,9 @@ TEST_F(SkiaUtilsMacTest, NSImageRepToSkBitmap) {
NSImage* image = CreateNSImage(width, height, isred);
EXPECT_EQ(1u, [[image representations] count]);
NSBitmapImageRep* imageRep = [[image representations] lastObject];
- SkBitmap bitmap(gfx::NSImageRepToSkBitmap(imageRep, [image size], false));
+ NSColorSpace* colorSpace = [NSColorSpace deviceRGBColorSpace];
+ SkBitmap bitmap(gfx::NSImageRepToSkBitmapWithColorSpace(
+ imageRep, [image size], false, [colorSpace CGColorSpace]));
TestSkBitmap(bitmap, isred);
}
diff --git a/chromium/skia/ext/vector_canvas_unittest.cc b/chromium/skia/ext/vector_canvas_unittest.cc
index b12363329b9..b7e9105cce0 100644
--- a/chromium/skia/ext/vector_canvas_unittest.cc
+++ b/chromium/skia/ext/vector_canvas_unittest.cc
@@ -135,11 +135,11 @@ class Image {
std::vector<gfx::PNGCodec::Comment>(),
&compressed));
ASSERT_TRUE(compressed.size());
- FILE* f = file_util::OpenFile(filename, "wb");
+ FILE* f = base::OpenFile(filename, "wb");
ASSERT_TRUE(f);
ASSERT_EQ(fwrite(&*compressed.begin(), 1, compressed.size(), f),
compressed.size());
- file_util::CloseFile(f);
+ base::CloseFile(f);
}
// Returns the percentage of the image that is different from the other,
@@ -245,7 +245,7 @@ class ImageTest : public testing::Test {
if (action_ == GENERATE) {
// Make sure the directory exist.
- file_util::CreateDirectory(test_dir_);
+ base::CreateDirectory(test_dir_);
}
}
diff --git a/chromium/skia/ext/vector_platform_device_emf_win.cc b/chromium/skia/ext/vector_platform_device_emf_win.cc
index fe1ba2927db..3356f217adf 100644
--- a/chromium/skia/ext/vector_platform_device_emf_win.cc
+++ b/chromium/skia/ext/vector_platform_device_emf_win.cc
@@ -211,6 +211,13 @@ void VectorPlatformDeviceEmf::drawRect(const SkDraw& draw,
Cleanup();
}
+void VectorPlatformDeviceEmf::drawRRect(const SkDraw& draw, const SkRRect& rr,
+ const SkPaint& paint) {
+ SkPath path;
+ path.addRRect(rr);
+ this->drawPath(draw, path, paint, NULL, true);
+}
+
void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw,
const SkPath& path,
const SkPaint& paint,
diff --git a/chromium/skia/ext/vector_platform_device_emf_win.h b/chromium/skia/ext/vector_platform_device_emf_win.h
index 61ea4413f34..df8315c4fc0 100644
--- a/chromium/skia/ext/vector_platform_device_emf_win.h
+++ b/chromium/skia/ext/vector_platform_device_emf_win.h
@@ -42,6 +42,8 @@ class VectorPlatformDeviceEmf : public SkBitmapDevice, public PlatformDevice {
const SkPaint& paint) OVERRIDE;
virtual void drawRect(const SkDraw& draw, const SkRect& r,
const SkPaint& paint) OVERRIDE;
+ virtual void drawRRect(const SkDraw&, const SkRRect& rr,
+ const SkPaint& paint) OVERRIDE;
virtual void drawPath(const SkDraw& draw, const SkPath& path,
const SkPaint& paint,
const SkMatrix* prePathMatrix = NULL,
diff --git a/chromium/skia/skia.gyp b/chromium/skia/skia.gyp
index af1cc531d44..4a5d62e5b43 100644
--- a/chromium/skia/skia.gyp
+++ b/chromium/skia/skia.gyp
@@ -66,10 +66,12 @@
'defines': [
'SKIA_DLL',
'SKIA_IMPLEMENTATION=1',
+ 'GR_GL_IGNORE_ES3_MSAA=0',
],
'direct_dependent_settings': {
'defines': [
'SKIA_DLL',
+ 'GR_GL_IGNORE_ES3_MSAA=0',
],
},
},
@@ -93,7 +95,6 @@
'include_dirs': [
'..',
'config',
- '../third_party/skia/include/config',
'../third_party/skia/include/core',
],
'conditions': [
@@ -132,5 +133,16 @@
'ext/image_operations_bench.cc',
],
},
+ {
+ 'target_name': 'filter_fuzz_stub',
+ 'type': 'executable',
+ 'dependencies': [
+ '../base/base.gyp:base',
+ 'skia.gyp:skia',
+ ],
+ 'sources': [
+ 'tools/filter_fuzz_stub/filter_fuzz_stub.cc',
+ ],
+ },
],
}
diff --git a/chromium/skia/skia_chrome.gypi b/chromium/skia/skia_chrome.gypi
index a0cd3bbbf19..6dcc6654fdd 100644
--- a/chromium/skia/skia_chrome.gypi
+++ b/chromium/skia/skia_chrome.gypi
@@ -20,23 +20,18 @@
],
},
- 'include_dirs': [
- '..',
- ],
-
'sources': [
'ext/analysis_canvas.cc',
'ext/analysis_canvas.h',
'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_data.h',
- 'ext/bitmap_platform_device_linux.cc',
- 'ext/bitmap_platform_device_linux.h',
+ 'ext/bitmap_platform_device_cairo.cc',
+ 'ext/bitmap_platform_device_cairo.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',
@@ -48,7 +43,6 @@
'ext/lazy_pixel_ref.h',
'ext/lazy_pixel_ref_utils.cc',
'ext/lazy_pixel_ref_utils.h',
- 'ext/SkThread_chrome.cc',
'ext/opacity_draw_filter.cc',
'ext/opacity_draw_filter.h',
'ext/paint_simplifier.cc',
@@ -83,17 +77,13 @@
'ext/vector_platform_device_skia.h',
],
'conditions': [
- # For POSIX platforms, prefer the Mutex implementation provided by Skia
- # since it does not generate static initializers.
- # TODO: should check if SK_USE_POSIX_THREADS is defined instead
- [ 'OS == "android" or OS == "linux" or OS == "mac" or OS == "ios"', {
+ [ 'OS == "android" and enable_printing == 0', {
'sources!': [
- 'ext/SkThread_chrome.cc',
+ 'ext/skia_utils_base.cc',
],
}],
- [ 'OS == "android" and enable_printing == 0', {
+ [ 'enable_printing == 0', {
'sources!': [
- 'ext/skia_utils_base.cc',
'ext/vector_platform_device_skia.cc',
],
}],
@@ -105,11 +95,6 @@
'skia_chrome_opts',
],
}],
- [ 'OS == "win"', {
- 'sources!': [
- 'ext/SkThread_chrome.cc',
- ],
- }],
# TODO(scottmg): http://crbug.com/177306
['clang==1', {
'xcode_settings': {
@@ -122,6 +107,11 @@
'-Wstring-conversion',
],
}],
+ [ 'OS != "android" and (OS != "linux" or use_cairo==1)', {
+ 'sources!': [
+ 'ext/bitmap_platform_device_skia.cc',
+ ],
+ }],
],
'target_conditions': [
diff --git a/chromium/skia/skia_common.gypi b/chromium/skia/skia_common.gypi
index 616ae5bb31b..0f5f9767241 100644
--- a/chromium/skia/skia_common.gypi
+++ b/chromium/skia/skia_common.gypi
@@ -5,12 +5,22 @@
# This gypi file handles the removal of platform-specific files from the
# Skia build.
{
+ 'include_dirs': [
+ '..',
+ 'config',
+ ],
+
'conditions': [
[ 'OS != "android"', {
'sources/': [
['exclude', '_android\\.(cc|cpp)$'],
],
}],
+ [ 'OS == "android"', {
+ 'defines': [
+ 'SK_FONTHOST_DOES_NOT_USE_FONTMGR',
+ ],
+ }],
[ 'OS != "ios"', {
'sources/': [
['exclude', '_ios\\.(cc|cpp|mm?)$'],
@@ -24,10 +34,23 @@
[ 'OS != "win"', {
'sources/': [ ['exclude', '_win\\.(cc|cpp)$'] ],
}],
- [ 'use_glib == 0', {
+ [ '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,
+ # however we currently have no means to enforce that direct dependents
+ # re-export if they include Skia headers in their public headers.
+ 'all_dependent_settings': {
+ 'include_dirs': [
+ '..',
+ 'config',
+ ],
+ },
+
'msvs_disabled_warnings': [4244, 4267, 4341, 4345, 4390, 4554, 4748, 4800],
}
diff --git a/chromium/skia/skia_library.gypi b/chromium/skia/skia_library.gypi
index 2ed1854c31e..b957fa665b5 100644
--- a/chromium/skia/skia_library.gypi
+++ b/chromium/skia/skia_library.gypi
@@ -41,9 +41,13 @@
'SK_SUPPORT_GPU=<(skia_support_gpu)',
'GR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"',
'SK_ENABLE_LEGACY_API_ALIASING=1',
+ 'SK_ATTR_DEPRECATED=SK_NOTHING_ARG1',
+ 'SK_SUPPORT_LEGACY_COLORTYPE=1',
+ 'GR_GL_IGNORE_ES3_MSAA=0',
+ 'SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR=1'
],
- 'default_font_cache_limit': '(20*1024*1024)',
+ 'default_font_cache_limit%': '(20*1024*1024)',
'conditions': [
['OS== "android"', {
@@ -67,9 +71,6 @@
'sources': [
# this should likely be moved into src/utils in skia
'../third_party/skia/src/core/SkFlate.cpp',
- # We don't want to add this to Skia's core.gypi since it is
- # Android only. Include it here and remove it for everyone
- # but Android later.
'../third_party/skia/src/core/SkPaintOptionsAndroid.cpp',
'../third_party/skia/src/ports/SkImageDecoder_empty.cpp',
@@ -152,9 +153,6 @@
'../third_party/skia/include/utils/SkProxyCanvas.h',
],
'include_dirs': [
- '..',
- 'config',
- '../third_party/skia/include/config',
'../third_party/skia/include/core',
'../third_party/skia/include/effects',
'../third_party/skia/include/images',
@@ -165,6 +163,7 @@
'../third_party/skia/include/ports',
'../third_party/skia/include/utils',
'../third_party/skia/src/core',
+ '../third_party/skia/src/opts',
'../third_party/skia/src/image',
'../third_party/skia/src/ports',
'../third_party/skia/src/sfnt',
@@ -224,7 +223,7 @@
# For POSIX platforms, prefer the Mutex implementation provided by Skia
# since it does not generate static initializers.
- [ 'OS == "android" or OS == "linux" or OS == "mac" or OS == "ios"', {
+ [ 'os_posix == 1', {
'defines+': [
'SK_USE_POSIX_THREADS',
],
@@ -235,11 +234,6 @@
},
}],
- [ 'OS != "android"', {
- 'sources!': [
- '../third_party/skia/src/core/SkPaintOptionsAndroid.cpp',
- ],
- }],
[ 'OS != "ios"', {
'dependencies': [
'../third_party/WebKit/public/blink_skia_config.gyp:blink_skia_config',
@@ -276,11 +270,10 @@
'../third_party/skia/src/opts/opts_check_SSE2.cpp'
],
}],
- [ 'use_glib == 1', {
+ [ 'desktop_linux == 1 or chromeos == 1', {
'dependencies': [
'../build/linux/system.gyp:fontconfig',
'../build/linux/system.gyp:freetype2',
- '../build/linux/system.gyp:pangocairo',
'../third_party/icu/icu.gyp:icuuc',
],
'cflags': [
@@ -288,13 +281,18 @@
'-Wno-unused-function',
],
}],
- [ 'use_glib == 0', {
+ [ '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',
'../third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp',
],
}],
- [ 'use_glib == 0 and OS != "android"', {
+ [ 'OS=="win" or OS=="mac" or OS=="ios"', {
'sources!': [
'../third_party/skia/src/ports/SkFontHost_FreeType.cpp',
'../third_party/skia/src/ports/SkFontHost_FreeType_common.cpp',
@@ -381,9 +379,6 @@
'../third_party/skia/include/utils/win',
'../third_party/skia/src/utils/win',
],
- 'defines': [
- 'SK_FONTHOST_USES_FONTMGR',
- ],
},{ # not 'OS == "win"'
'sources!': [
'../third_party/skia/src/ports/SkFontHost_win_dw.cpp',
@@ -408,6 +403,15 @@
'-Wstring-conversion',
],
}],
+ # On windows, GDI handles are a scarse system-wide resource so we have to keep
+ # the glyph cache, which holds up to 4 GDI handles per entry, to a fairly small
+ # size.
+ # http://crbug.com/314387
+ [ 'OS == "win"', {
+ 'defines': [
+ 'SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256',
+ ],
+ }],
],
'target_conditions': [
# Pull in specific Mac files for iOS (which have been filtered out
@@ -430,13 +434,19 @@
# SkGraphics::Init().
'SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0',
+ # Forcing the unoptimized path for the offset image filter in skia until
+ # all filters used in Blink support the optimized path properly
+ 'SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION',
+
# Disable this check because it is too strict for some Chromium-specific
# subclasses of SkPixelRef. See bug: crbug.com/171776.
'SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK',
'IGNORE_ROT_AA_RECT_OPT',
- 'SKIA_IGNORE_GPU_MIPMAPS',
+ 'SK_IGNORE_BLURRED_RRECT_OPT',
+
+ 'SK_IGNORE_QUAD_RR_CORNERS_OPT',
# this flag forces Skia not to use typographic metrics with GDI.
'SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS',
@@ -449,8 +459,6 @@
#temporary until we can hide SkFontHost
'../third_party/skia/src/core',
- 'config',
- '../third_party/skia/include/config',
'../third_party/skia/include/core',
'../third_party/skia/include/effects',
'../third_party/skia/include/pdf',
diff --git a/chromium/skia/skia_library_opts.gyp b/chromium/skia/skia_library_opts.gyp
index 15263764741..5e93c6d4ca8 100644
--- a/chromium/skia/skia_library_opts.gyp
+++ b/chromium/skia/skia_library_opts.gyp
@@ -27,9 +27,10 @@
{
'target_name': 'skia_opts',
'type': 'static_library',
+ 'includes': [
+ 'skia_common.gypi',
+ ],
'include_dirs': [
- 'config',
- '../third_party/skia/include/config',
'../third_party/skia/include/core',
'../third_party/skia/src/core',
'../third_party/skia/src/opts',
@@ -47,7 +48,10 @@
'../third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp',
'../third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp',
'../third_party/skia/src/opts/SkUtils_opts_SSE2.cpp',
+ '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
'../third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp',
+ '../third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp',
+ '../third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp',
],
'dependencies': [
'skia_opts_ssse3',
@@ -104,6 +108,9 @@
'../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
'../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
'../third_party/skia/src/opts/SkUtils_opts_none.cpp',
+ '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
+ '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
+ '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
],
}],
[ 'target_arch == "arm" and arm_version >= 6', {
@@ -112,6 +119,7 @@
'../third_party/skia/src/opts/SkBlitRow_opts_arm.cpp',
'../third_party/skia/src/opts/SkBlitRow_opts_arm.h',
'../third_party/skia/src/opts/opts_check_arm.cpp',
+ '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
],
}],
[ 'target_arch == "mipsel"',{
@@ -123,6 +131,9 @@
'../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
'../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
'../third_party/skia/src/opts/SkUtils_opts_none.cpp',
+ '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
+ '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
+ '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
],
}],
],
@@ -134,10 +145,10 @@
{
'target_name': 'skia_opts_ssse3',
'type': 'static_library',
+ 'includes': [
+ 'skia_common.gypi',
+ ],
'include_dirs': [
- '..',
- 'config',
- '../third_party/skia/include/config',
'../third_party/skia/include/core',
'../third_party/skia/src/core',
],
@@ -172,10 +183,10 @@
{
'target_name': 'skia_opts_none',
'type': 'static_library',
+ 'includes': [
+ 'skia_common.gypi',
+ ],
'include_dirs': [
- '..',
- 'config',
- '../third_party/skia/include/config',
'../third_party/skia/include/core',
'../third_party/skia/src/core',
],
@@ -184,6 +195,9 @@
'../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
'../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
'../third_party/skia/src/opts/SkUtils_opts_none.cpp',
+ '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
+ '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
+ '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
],
},
],
@@ -197,9 +211,10 @@
{
'target_name': 'skia_opts_neon',
'type': 'static_library',
+ 'includes': [
+ 'skia_common.gypi',
+ ],
'include_dirs': [
- '..',
- 'config',
'../third_party/skia/include/core',
'../third_party/skia/src/core',
'../third_party/skia/src/opts',
@@ -225,7 +240,11 @@
'../third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
'../third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h',
'../third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h',
+ '../third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp',
'../third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp',
+ '../third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp',
+ '../third_party/skia/src/opts/SkBlurImage_opts_neon.cpp',
+ '../third_party/skia/src/opts/SkMorphology_opts_neon.cpp',
],
'conditions': [
['arm_neon == 1', {
diff --git a/chromium/skia/skia_test_expectations.txt b/chromium/skia/skia_test_expectations.txt
index bfae6eecbc9..3272ffb9d91 100644
--- a/chromium/skia/skia_test_expectations.txt
+++ b/chromium/skia/skia_test_expectations.txt
@@ -48,24 +48,13 @@
#
# START OVERRIDES HERE
-# The Skia roll to r11121 altered this layout test
-crbug.com/286312 virtual/gpu/fast/canvas/canvas-composite-transformclip.html [ ImageOnlyFailure ]
+# the Skia roll to 12018 again altered the way roundrects are drawn
+crbug.com/314499 fast/canvas/image-object-in-canvas.html [ ImageOnlyFailure ]
-# Skia CL r11158 improved GPU-base gradient rendering (and changed three baseline images)
-crbug.com/288674 css3/filters/effect-reference-zoom-hw.html [ ImageOnlyFailure ]
-crbug.com/288674 virtual/gpu/fast/canvas/canvas-text-alignment.html [ ImageOnlyFailure ]
-crbug.com/288674 virtual/gpu/fast/canvas/fillrect_gradient.html [ ImageOnlyFailure ]
-# This image difference is related to the recent oval rendering changes
-crbug.com/288674 virtual/gpu/fast/canvas/canvas-composite.html [ ImageOnlyFailure ]
-
-# Skia CL r11249 altered some of the parameters to the spot light filter
-crbug.com/292656 css3/filters/effect-reference-colorspace-hw.html [ ImageOnlyFailure ]
-crbug.com/292656 css3/filters/effect-reference-hw.html [ ImageOnlyFailure ]
-crbug.com/292656 css3/filters/effect-reference-subregion-hw.html [ ImageOnlyFailure ]
-
-# Skia r11365 slightly changed how the GPU draws lines
-crbug.com/295579 virtual/gpu/fast/canvas/canvas-text-baseline.html [ ImageOnlyFailure ]
-crbug.com/295579 virtual/gpu/fast/canvas/canvas-transforms-during-path.html [ ImageOnlyFailure ]
-crbug.com/295579 virtual/gpu/fast/canvas/quadraticCurveTo.xml [ ImageOnlyFailure ]
+# the Skia roll to r12494 altered convex path rendering on the GPU
+crbug.com/326138 virtual/gpu/fast/canvas/canvas-composite-transformclip.html [ ImageOnlyFailure ]
+crbug.com/326138 virtual/gpu/fast/canvas/canvas-composite.html [ ImageOnlyFailure ]
+crbug.com/326138 virtual/gpu/fast/canvas/image-object-in-canvas.html [ ImageOnlyFailure ]
+crbug.com/326138 virtual/gpu/fast/canvas/quadraticCurveTo.xml [ ImageOnlyFailure ]
# END OVERRIDES HERE (this line ensures that the file is newline-terminated)
diff --git a/chromium/skia/tools/filter_fuzz_stub/filter_fuzz_stub.cc b/chromium/skia/tools/filter_fuzz_stub/filter_fuzz_stub.cc
new file mode 100644
index 00000000000..1cb4d7f6ebd
--- /dev/null
+++ b/chromium/skia/tools/filter_fuzz_stub/filter_fuzz_stub.cc
@@ -0,0 +1,93 @@
+// 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 "base/file_util.h"
+#include "base/logging.h"
+#include "third_party/skia/include/core/SkBitmapDevice.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkFlattenableSerialization.h"
+#include "third_party/skia/include/core/SkImageFilter.h"
+
+namespace {
+
+static const int BitmapSize = 24;
+
+bool ReadTestCase(const char* filename, std::string* ipc_filter_message) {
+ base::FilePath filepath = base::FilePath::FromUTF8Unsafe(filename);
+
+ if (!base::ReadFileToString(filepath, ipc_filter_message)) {
+ LOG(ERROR) << filename << ": couldn't read file.";
+ return false;
+ }
+
+ return true;
+}
+
+void RunTestCase(std::string& ipc_filter_message, SkBitmap& bitmap,
+ SkCanvas* canvas) {
+ // This call shouldn't crash or cause ASAN to flag any memory issues
+ // If nothing bad happens within this call, everything is fine
+ SkFlattenable* flattenable = SkValidatingDeserializeFlattenable(
+ ipc_filter_message.c_str(), ipc_filter_message.size(),
+ SkImageFilter::GetFlattenableType());
+
+ // Adding some info, but the test passed if we got here without any trouble
+ if (flattenable != NULL) {
+ LOG(INFO) << "Valid stream detected.";
+ // Let's see if using the filters can cause any trouble...
+ SkPaint paint;
+ paint.setImageFilter(static_cast<SkImageFilter*>(flattenable))->unref();
+ canvas->save();
+ canvas->clipRect(SkRect::MakeXYWH(
+ 0, 0, SkIntToScalar(BitmapSize), SkIntToScalar(BitmapSize)));
+
+ // This call shouldn't crash or cause ASAN to flag any memory issues
+ // If nothing bad happens within this call, everything is fine
+ canvas->drawBitmap(bitmap, 0, 0, &paint);
+
+ LOG(INFO) << "Filter DAG rendered successfully";
+ canvas->restore();
+ } else {
+ LOG(INFO) << "Invalid stream detected.";
+ }
+}
+
+bool ReadAndRunTestCase(const char* filename, SkBitmap& bitmap,
+ SkCanvas* canvas) {
+ std::string ipc_filter_message;
+
+ LOG(INFO) << "Test case: " << filename;
+
+ // ReadTestCase will print a useful error message if it fails.
+ if (!ReadTestCase(filename, &ipc_filter_message))
+ return false;
+
+ RunTestCase(ipc_filter_message, bitmap, canvas);
+
+ return true;
+}
+
+}
+
+int main(int argc, char** argv) {
+ int ret = 0;
+
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, BitmapSize, BitmapSize);
+ bitmap.allocPixels();
+ SkBitmapDevice device(bitmap);
+ SkCanvas canvas(&device);
+ canvas.clear(0x00000000);
+
+ for (int i = 1; i < argc; i++)
+ if (!ReadAndRunTestCase(argv[i], bitmap, &canvas))
+ ret = 2;
+
+ // Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish
+ // successful runs from crashes.
+ printf("#EOF\n");
+
+ return ret;
+}
+