Commit eec4d53d authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

bitmaps

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@56510 954022d7-b5bf-4e40-9824-e11837661b57
parent 5c3bb713
......@@ -28,7 +28,9 @@ INCLUDEPATH += \
/usr/include/gtk-2.0 \
/usr/include/glib-2.0 \
../../src/third_party/skia/include/core \
../../src/third_party/skia/include/config
../../src/third_party/skia/include/config \
../../src/third_party/skia/include/pathops \
../../src/third_party/skia/src/image
SOURCES += main.cpp \
../../src/ui/base/clipboard/clipboard.cc \
......@@ -55,7 +57,45 @@ SOURCES += main.cpp \
../../src/base/message_pump_gtk.cc \
../../src/base/message_pump_glib.cc \
../../src/base/message_pump_default.cc \
../../src/base/message_pump_libevent.cc
../../src/base/message_pump_libevent.cc \
../../src/third_party/skia/src/core/SkDebug.cpp \
../../src/ui/gfx/image/image.cc \
../../src/ui/gfx/gtk_util.cc \
../../src/base/threading/thread_restrictions.cc \
../../src/base/at_exit.cc \
../../src/base/memory/singleton.cc \
../../src/base/atomicops_internals_x86_gcc.cc \
../../src/base/message_loop.cc \
../../src/ui/base/keycodes/keyboard_code_conversion.cc \
../../src/ui/base/keycodes/keyboard_code_conversion_gtk.cc \
../../src/ui/base/keycodes/keyboard_code_conversion_x.cc \
../../src/base/location.cc \
../../src/ui/gfx/rect.cc \
../../src/ui/gfx/rect_conversions.cc \
../../src/ui/gfx/rect_f.cc \
../../src/ui/gfx/point.cc \
../../src/ui/gfx/point3_f.cc \
../../src/ui/gfx/point_conversions.cc \
../../src/ui/gfx/point_f.cc \
../../src/base/memory/ref_counted.cc \
../../src/base/memory/ref_counted_memory.cc \
../../src/base/callback_internal.cc \
../../src/third_party/skia/src/ports/SkDebug_stdio.cpp \
../../src/third_party/skia/src/core/Sk64.cpp \
../../src/third_party/skia/src/core/SkPixelRef.cpp \
../../src/third_party/skia/src/core/SkMallocPixelRef.cpp \
../../src/third_party/skia/src/ports/SkMemory_malloc.cpp \
../../src/third_party/skia/src/core/SkCanvas.cpp \
../../src/third_party/skia/src/core/SkColor.cpp \
../../src/third_party/skia/src/core/SkColorTable.cpp \
../../src/third_party/skia/src/core/SkMask.cpp \
../../src/third_party/skia/src/core/SkMatrix.cpp \
../../src/third_party/skia/src/core/SkUnPreMultiply.cpp \
../../src/third_party/skia/src/core/SkPackBits.cpp \
../../src/third_party/skia/src/core/SkPoint.cpp \
../../src/third_party/skia/src/core/SkRect.cpp \
../../src/third_party/skia/src/core/SkUtils.cpp \
../../src/third_party/skia/src/core/SkPaint.cpp
HEADERS += \
../../src/ui/base/clipboard/clipboard.h \
......@@ -182,4 +222,36 @@ HEADERS += \
../../src/base/message_pump_glib.h \
../../src/base/message_pump_default.h \
../../src/base/message_pump_dispatcher.h \
../../src/base/message_pump_libevent.h
../../src/base/message_pump_libevent.h \
../../src/ui/gfx/image/image.h \
../../src/ui/gfx/gtk_util.h \
../../src/base/threading/thread_restrictions.h \
../../src/base/at_exit.h \
../../src/base/memory/singleton.h \
../../src/base/atomicops.h \
../../src/base/atomicops_internals_atomicword_compat.h \
../../src/base/atomicops_internals_gcc.h \
../../src/base/atomicops_internals_x86_gcc.h \
../../src/base/message_loop.h \
../../src/base/message_loop_proxy.h \
../../src/ui/base/keycodes/keyboard_code_conversion.h \
../../src/ui/base/keycodes/keyboard_code_conversion_gtk.h \
../../src/ui/base/keycodes/keyboard_code_conversion_x.h \
../../src/ui/base/keycodes/keyboard_codes.h \
../../src/ui/base/keycodes/keyboard_codes_posix.h \
../../src/ui/base/keycodes/usb_keycode_map.h \
../../src/base/location.h \
../../src/ui/gfx/rect.h \
../../src/ui/gfx/rect_base.h \
../../src/ui/gfx/rect_conversions.h \
../../src/ui/gfx/rect_f.h \
../../src/ui/gfx/point.h \
../../src/ui/gfx/point3_f.h \
../../src/ui/gfx/point_base.h \
../../src/ui/gfx/point_conversions.h \
../../src/ui/gfx/point_f.h \
../../src/base/memory/ref_counted.h \
../../src/base/memory/ref_counted_memory.h \
../../src/base/callback_internal.h \
../../src/third_party/skia/include/pathops/SkPathOps.h \
../../src/third_party/skia/src/image/SkSurface_Base.h
......@@ -25,17 +25,17 @@ AtExitManager::AtExitManager() : next_manager_(g_top_manager) {
// If multiple modules instantiate AtExitManagers they'll end up living in this
// module... they have to coexist.
#if !defined(COMPONENT_BUILD)
DCHECK(!g_top_manager);
//DCHECK(!g_top_manager);
#endif
g_top_manager = this;
}
AtExitManager::~AtExitManager() {
if (!g_top_manager) {
NOTREACHED() << "Tried to ~AtExitManager without an AtExitManager";
//NOTREACHED() << "Tried to ~AtExitManager without an AtExitManager";
return;
}
DCHECK_EQ(this, g_top_manager);
//DCHECK_EQ(this, g_top_manager);
ProcessCallbacksNow();
g_top_manager = next_manager_;
......@@ -43,14 +43,14 @@ AtExitManager::~AtExitManager() {
// static
void AtExitManager::RegisterCallback(AtExitCallbackType func, void* param) {
DCHECK(func);
//DCHECK(func);
RegisterTask(base::Bind(func, param));
}
// static
void AtExitManager::RegisterTask(base::Closure task) {
if (!g_top_manager) {
NOTREACHED() << "Tried to RegisterCallback without an AtExitManager";
//NOTREACHED() << "Tried to RegisterCallback without an AtExitManager";
return;
}
......@@ -61,7 +61,7 @@ void AtExitManager::RegisterTask(base::Closure task) {
// static
void AtExitManager::ProcessCallbacksNow() {
if (!g_top_manager) {
NOTREACHED() << "Tried to ProcessCallbacksNow without an AtExitManager";
//NOTREACHED() << "Tried to ProcessCallbacksNow without an AtExitManager";
return;
}
......@@ -75,7 +75,7 @@ void AtExitManager::ProcessCallbacksNow() {
}
AtExitManager::AtExitManager(bool shadow) : next_manager_(g_top_manager) {
DCHECK(shadow || !g_top_manager);
//DCHECK(shadow || !g_top_manager);
g_top_manager = this;
}
......
......@@ -28,7 +28,7 @@ bool CallbackBase::Equals(const CallbackBase& other) const {
CallbackBase::CallbackBase(BindStateBase* bind_state)
: bind_state_(bind_state),
polymorphic_invoke_(NULL) {
DCHECK(!bind_state_ || bind_state_->HasOneRef());
//DCHECK(!bind_state_ || bind_state_->HasOneRef());
}
CallbackBase::~CallbackBase() {
......
......@@ -21,7 +21,7 @@ RefCountedBase::RefCountedBase()
RefCountedBase::~RefCountedBase() {
#ifndef NDEBUG
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
//DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
#endif
}
......@@ -30,7 +30,7 @@ void RefCountedBase::AddRef() const {
// Current thread books the critical section "AddRelease" without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#ifndef NDEBUG
DCHECK(!in_dtor_);
//DCHECK(!in_dtor_);
#endif
++ref_count_;
}
......@@ -40,7 +40,7 @@ bool RefCountedBase::Release() const {
// Current thread books the critical section "AddRelease" without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#ifndef NDEBUG
DCHECK(!in_dtor_);
//DCHECK(!in_dtor_);
#endif
if (--ref_count_ == 0) {
#ifndef NDEBUG
......@@ -64,22 +64,22 @@ RefCountedThreadSafeBase::RefCountedThreadSafeBase() : ref_count_(0) {
RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
#ifndef NDEBUG
DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
"calling Release()";
//DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
// "calling Release()";
#endif
}
void RefCountedThreadSafeBase::AddRef() const {
#ifndef NDEBUG
DCHECK(!in_dtor_);
//DCHECK(!in_dtor_);
#endif
AtomicRefCountInc(&ref_count_);
}
bool RefCountedThreadSafeBase::Release() const {
#ifndef NDEBUG
DCHECK(!in_dtor_);
DCHECK(!AtomicRefCountIsZero(&ref_count_));
//DCHECK(!in_dtor_);
//DCHECK(!AtomicRefCountIsZero(&ref_count_));
#endif
if (!AtomicRefCountDec(&ref_count_)) {
#ifndef NDEBUG
......
......@@ -144,7 +144,7 @@ MessageLoop::MessageLoop(Type type)
os_modal_loop_(false),
#endif // OS_WIN
next_sequence_num_(0) {
DCHECK(!current()) << "should only have one message loop per thread";
//DCHECK(!current()) << "should only have one message loop per thread";
lazy_tls_ptr.Pointer()->Set(this);
message_loop_proxy_ = new MessageLoopProxyImpl();
......@@ -183,15 +183,15 @@ MessageLoop::MessageLoop(Type type)
} else if (type_ == TYPE_IO) {
pump_ = MESSAGE_PUMP_IO;
} else {
DCHECK_EQ(TYPE_DEFAULT, type_);
//DCHECK_EQ(TYPE_DEFAULT, type_);
pump_ = new MessagePumpDefault();
}
}
MessageLoop::~MessageLoop() {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
DCHECK(!run_loop_);
//DCHECK(!run_loop_);
// Clean up any unprocessed tasks, but take care: deleting a task could
// result in the addition of more tasks (e.g., via DeleteSoon). We set a
......@@ -208,7 +208,7 @@ MessageLoop::~MessageLoop() {
if (!did_work)
break;
}
DCHECK(!did_work);
//DCHECK(!did_work);
// Let interested parties have one last shot at accessing this.
FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_,
......@@ -259,20 +259,20 @@ bool MessageLoop::InitMessagePumpForUIFactory(MessagePumpFactory* factory) {
void MessageLoop::AddDestructionObserver(
DestructionObserver* destruction_observer) {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
destruction_observers_.AddObserver(destruction_observer);
}
void MessageLoop::RemoveDestructionObserver(
DestructionObserver* destruction_observer) {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
destruction_observers_.RemoveObserver(destruction_observer);
}
void MessageLoop::PostTask(
const tracked_objects::Location& from_here,
const Closure& task) {
DCHECK(!task.is_null()) << from_here.ToString();
//DCHECK(!task.is_null()) << from_here.ToString();
PendingTask pending_task(
from_here, task, CalculateDelayedRuntime(TimeDelta()), true);
AddToIncomingQueue(&pending_task, false);
......@@ -281,7 +281,7 @@ void MessageLoop::PostTask(
bool MessageLoop::TryPostTask(
const tracked_objects::Location& from_here,
const Closure& task) {
DCHECK(!task.is_null()) << from_here.ToString();
//DCHECK(!task.is_null()) << from_here.ToString();
PendingTask pending_task(
from_here, task, CalculateDelayedRuntime(TimeDelta()), true);
return AddToIncomingQueue(&pending_task, true);
......@@ -291,7 +291,7 @@ void MessageLoop::PostDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
TimeDelta delay) {
DCHECK(!task.is_null()) << from_here.ToString();
//DCHECK(!task.is_null()) << from_here.ToString();
PendingTask pending_task(
from_here, task, CalculateDelayedRuntime(delay), true);
AddToIncomingQueue(&pending_task, false);
......@@ -300,7 +300,7 @@ void MessageLoop::PostDelayedTask(
void MessageLoop::PostNonNestableTask(
const tracked_objects::Location& from_here,
const Closure& task) {
DCHECK(!task.is_null()) << from_here.ToString();
//DCHECK(!task.is_null()) << from_here.ToString();
PendingTask pending_task(
from_here, task, CalculateDelayedRuntime(TimeDelta()), false);
AddToIncomingQueue(&pending_task, false);
......@@ -310,7 +310,7 @@ void MessageLoop::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
TimeDelta delay) {
DCHECK(!task.is_null()) << from_here.ToString();
//DCHECK(!task.is_null()) << from_here.ToString();
PendingTask pending_task(
from_here, task, CalculateDelayedRuntime(delay), false);
AddToIncomingQueue(&pending_task, false);
......@@ -327,20 +327,20 @@ void MessageLoop::RunUntilIdle() {
}
void MessageLoop::QuitWhenIdle() {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
if (run_loop_) {
run_loop_->quit_when_idle_received_ = true;
} else {
NOTREACHED() << "Must be inside Run to call Quit";
//NOTREACHED() << "Must be inside Run to call Quit";
}
}
void MessageLoop::QuitNow() {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
if (run_loop_) {
pump_->Quit();
} else {
NOTREACHED() << "Must be inside Run to call Quit";
//NOTREACHED() << "Must be inside Run to call Quit";
}
}
......@@ -376,23 +376,23 @@ bool MessageLoop::IsNested() {
}
void MessageLoop::AddTaskObserver(TaskObserver* task_observer) {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
task_observers_.AddObserver(task_observer);
}
void MessageLoop::RemoveTaskObserver(TaskObserver* task_observer) {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
task_observers_.RemoveObserver(task_observer);
}
void MessageLoop::AssertIdle() const {
// We only check |incoming_queue_|, since we don't want to lock |work_queue_|.
AutoLock lock(incoming_queue_lock_);
DCHECK(incoming_queue_.empty());
//DCHECK(incoming_queue_.empty());
}
bool MessageLoop::is_running() const {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
return run_loop_ != NULL;
}
......@@ -426,7 +426,7 @@ __declspec(noinline) void MessageLoop::RunInternalInSEHFrame() {
#endif
void MessageLoop::RunInternal() {
DCHECK_EQ(this, current());
//DCHECK_EQ(this, current());
StartHistogrammer();
......@@ -461,7 +461,7 @@ void MessageLoop::RunTask(const PendingTask& pending_task) {
TRACE_EVENT2("task", "MessageLoop::RunTask",
"src_file", pending_task.posted_from.file_name(),
"src_func", pending_task.posted_from.function_name());
DCHECK(nestable_tasks_allowed_);
//DCHECK(nestable_tasks_allowed_);
// Execute the task and assume the worst: It is probably not reentrant.
nestable_tasks_allowed_ = false;
......@@ -524,7 +524,7 @@ void MessageLoop::ReloadWorkQueue() {
if (incoming_queue_.empty())
return;
incoming_queue_.Swap(&work_queue_); // Constant time
DCHECK(incoming_queue_.empty());
//DCHECK(incoming_queue_.empty());
}
}
......@@ -580,7 +580,7 @@ TimeTicks MessageLoop::CalculateDelayedRuntime(TimeDelta delay) {
}
#endif
} else {
DCHECK_EQ(delay.InMilliseconds(), 0) << "delay should not be negative";
//DCHECK_EQ(delay.InMilliseconds(), 0) << "delay should not be negative";
}
#if defined(OS_WIN)
......@@ -646,7 +646,7 @@ void MessageLoop::StartHistogrammer() {
#if !defined(OS_NACL) // NaCl build has no metrics code.
if (enable_histogrammer_ && !message_histogram_
&& StatisticsRecorder::IsActive()) {
DCHECK(!thread_name_.empty());
//DCHECK(!thread_name_.empty());
message_histogram_ = LinearHistogram::FactoryGetWithRangeDescription(
"MsgLoop:" + thread_name_,
kLeastNonZeroMessageId, kMaxMessageId,
......
......@@ -80,8 +80,8 @@ bool MessagePumpLibevent::FileDescriptorWatcher::StopWatchingFileDescriptor() {
}
void MessagePumpLibevent::FileDescriptorWatcher::Init(event *e) {
DCHECK(e);
DCHECK(!event_);
//DCHECK(e);
//DCHECK(!event_);
event_ = e;
}
......@@ -105,7 +105,7 @@ void MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking(
void MessagePumpLibevent::FileDescriptorWatcher::OnFileCanWriteWithoutBlocking(
int fd, MessagePumpLibevent* pump) {
DCHECK(watcher_);
//DCHECK(watcher_);
pump->WillProcessIOEvent();
watcher_->OnFileCanWriteWithoutBlocking(fd);
pump->DidProcessIOEvent();
......@@ -119,21 +119,27 @@ MessagePumpLibevent::MessagePumpLibevent()
wakeup_pipe_in_(-1),
wakeup_pipe_out_(-1) {
if (!Init())
NOTREACHED();
{
//NOTREACHED();
}
}
MessagePumpLibevent::~MessagePumpLibevent() {
DCHECK(wakeup_event_);
DCHECK(event_base_);
//DCHECK(wakeup_event_);
//DCHECK(event_base_);
event_del(wakeup_event_);
delete wakeup_event_;
if (wakeup_pipe_in_ >= 0) {
if (HANDLE_EINTR(close(wakeup_pipe_in_)) < 0)
DPLOG(ERROR) << "close";
{
//DPLOG(ERROR) << "close";
}
}
if (wakeup_pipe_out_ >= 0) {
if (HANDLE_EINTR(close(wakeup_pipe_out_)) < 0)
DPLOG(ERROR) << "close";
{
//DPLOG(ERROR) << "close";
}
}
event_base_free(event_base_);
}
......@@ -143,13 +149,13 @@ bool MessagePumpLibevent::WatchFileDescriptor(int fd,
int mode,
FileDescriptorWatcher *controller,
Watcher *delegate) {
DCHECK_GE(fd, 0);
DCHECK(controller);
DCHECK(delegate);
DCHECK(mode == WATCH_READ || mode == WATCH_WRITE || mode == WATCH_READ_WRITE);
//DCHECK_GE(fd, 0);
//DCHECK(controller);
//DCHECK(delegate);
//DCHECK(mode == WATCH_READ || mode == WATCH_WRITE || mode == WATCH_READ_WRITE);
// WatchFileDescriptor should be called on the pump thread. It is not
// threadsafe, and your watcher may never be registered.
DCHECK(watch_file_descriptor_caller_checker_.CalledOnValidThread());
//DCHECK(watch_file_descriptor_caller_checker_.CalledOnValidThread());
int event_mask = persistent ? EV_PERSIST : 0;
if (mode & WATCH_READ) {
......@@ -177,7 +183,7 @@ bool MessagePumpLibevent::WatchFileDescriptor(int fd,
// It's illegal to use this function to listen on 2 separate fds with the
// same |controller|.
if (EVENT_FD(evt.get()) != fd) {
NOTREACHED() << "FDs don't match" << EVENT_FD(evt.get()) << "!=" << fd;
//NOTREACHED() << "FDs don't match" << EVENT_FD(evt.get()) << "!=" << fd;
return false;
}
}
......@@ -220,7 +226,7 @@ static void timer_callback(int fd, short events, void *context)
// Reentrant!
void MessagePumpLibevent::Run(Delegate* delegate) {
DCHECK(keep_running_) << "Quit must have been called outside of Run!";
//DCHECK(keep_running_) << "Quit must have been called outside of Run!";
base::AutoReset<bool> auto_reset_in_run(&in_run_, true);
// event_base_loopexit() + EVLOOP_ONCE is leaky, see http://crbug.com/25641.
......@@ -283,7 +289,7 @@ void MessagePumpLibevent::Run(Delegate* delegate) {
}
void MessagePumpLibevent::Quit() {
DCHECK(in_run_);
//DCHECK(in_run_);
// Tell both libevent and Run that they should break out of their loops.
keep_running_ = false;
ScheduleWork();
......@@ -293,8 +299,8 @@ void MessagePumpLibevent::ScheduleWork() {
// Tell libevent (in a threadsafe way) that it should break out of its loop.
char buf = 0;
int nwrite = HANDLE_EINTR(write(wakeup_pipe_in_, &buf, 1));
DCHECK(nwrite == 1 || errno == EAGAIN)
<< "[nwrite:" << nwrite << "] [errno:" << errno << "]";
//DCHECK(nwrite == 1 || errno == EAGAIN)
// << "[nwrite:" << nwrite << "] [errno:" << errno << "]";
}
void MessagePumpLibevent::ScheduleDelayedWork(
......@@ -316,15 +322,15 @@ void MessagePumpLibevent::DidProcessIOEvent() {
bool MessagePumpLibevent::Init() {
int fds[2];
if (pipe(fds)) {
DLOG(ERROR) << "pipe() failed, errno: " << errno;
//DLOG(ERROR) << "pipe() failed, errno: " << errno;
return false;
}
if (SetNonBlocking(fds[0])) {
DLOG(ERROR) << "SetNonBlocking for pipe fd[0] failed, errno: " << errno;
//DLOG(ERROR) << "SetNonBlocking for pipe fd[0] failed, errno: " << errno;
return false;
}
if (SetNonBlocking(fds[1])) {
DLOG(ERROR) << "SetNonBlocking for pipe fd[1] failed, errno: " << errno;
//DLOG(ERROR) << "SetNonBlocking for pipe fd[1] failed, errno: " << errno;
return false;
}
wakeup_pipe_out_ = fds[0];
......@@ -345,7 +351,7 @@ void MessagePumpLibevent::OnLibeventNotification(int fd, short flags,
void* context) {
base::WeakPtr<FileDescriptorWatcher> controller =
static_cast<FileDescriptorWatcher*>(context)->weak_factory_.GetWeakPtr();
DCHECK(controller.get());
//DCHECK(controller.get());
MessagePumpLibevent* pump = controller->pump();
pump->processed_io_events_ = true;
......@@ -365,12 +371,12 @@ void MessagePumpLibevent::OnLibeventNotification(int fd, short flags,
void MessagePumpLibevent::OnWakeup(int socket, short flags, void* context) {
base::MessagePumpLibevent* that =
static_cast<base::MessagePumpLibevent*>(context);
DCHECK(that->wakeup_pipe_out_ == socket);
//DCHECK(that->wakeup_pipe_out_ == socket);
// Remove and discard the wakeup byte.
char buf;
int nread = HANDLE_EINTR(read(socket, &buf, 1));
DCHECK_EQ(nread, 1);
//DCHECK_EQ(nread, 1);
that->processed_io_events_ = true;
// Tell libevent to break out of inner loop.
event_base_loopbreak(that->event_base_);
......
......@@ -35,12 +35,12 @@ bool ThreadRestrictions::SetIOAllowed(bool allowed) {
// static
void ThreadRestrictions::AssertIOAllowed() {
if (g_io_disallowed.Get().Get()) {
LOG(FATAL) <<
"Function marked as IO-only was called from a thread that "
"disallows IO! If this thread really should be allowed to "
"make IO calls, adjust the call to "
"base::ThreadRestrictions::SetIOAllowed() in this thread's "
"startup.";
//LOG(FATAL) <<
// "Function marked as IO-only was called from a thread that "
// "disallows IO! If this thread really should be allowed to "
// "make IO calls, adjust the call to "
// "base::ThreadRestrictions::SetIOAllowed() in this thread's "
// "startup.";
}
}
......@@ -54,10 +54,10 @@ bool ThreadRestrictions::SetSingletonAllowed(bool allowed) {
// static
void ThreadRestrictions::AssertSingletonAllowed() {
if (g_singleton_disallowed.Get().Get()) {
LOG(FATAL) << "LazyInstance/Singleton is not allowed to be used on this "
<< "thread. Most likely it's because this thread is not "
<< "joinable, so AtExitManager may have deleted the object "
<< "on shutdown, leading to a potential shutdown crash.";
//LOG(FATAL) << "LazyInstance/Singleton is not allowed to be used on this "
// << "thread. Most likely it's because this thread is not "
// << "joinable, so AtExitManager may have deleted the object "
// << "on shutdown, leading to a potential shutdown crash.";
}
}
......@@ -69,8 +69,8 @@ void ThreadRestrictions::DisallowWaiting() {
// static
void ThreadRestrictions::AssertWaitAllowed() {
if (g_wait_disallowed.Get().Get()) {
LOG(FATAL) << "Waiting is not allowed to be used on this thread to prevent"
<< "jank and deadlock.";
//LOG(FATAL) << "Waiting is not allowed to be used on this thread to prevent"
// << "jank and deadlock.";
}
}
......
......@@ -314,6 +314,7 @@ void Clipboard::WriteWebSmartPaste() {
void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) {
const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data);
/*
// Adopt the pixels into a SkBitmap. Note that the pixel order in memory is
// actually BGRA.
SkBitmap bitmap;
......@@ -325,6 +326,7 @@ void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) {
// Note that this contrasts with the vast majority of entries in our target
// map, which directly store the data and its length.
InsertMapping(kMimeTypeBitmap, reinterpret_cast<char*>(pixbuf), 0);
*/
}
void Clipboard::WriteBookmark(const char* title_data, size_t title_len,
......
......@@ -424,14 +424,14 @@ KeyboardCode KeyboardCodeFromXKeysym(unsigned int keysym) {
// TODO(sad): some keycodes are still missing.
}
DLOG(WARNING) << "Unknown keysym: " << base::StringPrintf("0x%x", keysym);
//DLOG(WARNING) << "Unknown keysym: " << base::StringPrintf("0x%x", keysym);
return VKEY_UNKNOWN;
}
uint16 GetCharacterFromXEvent(XEvent* xev) {
char buf[6];
int bytes_written = XLookupString(&xev->xkey, buf, 6, NULL, NULL);
DCHECK_LE(bytes_written, 6);
//DCHECK_LE(bytes_written, 6);
string16 result;
return (bytes_written > 0 && UTF8ToUTF16(buf, bytes_written, &result) &&
......@@ -783,7 +783,7 @@ int XKeysymForWindowsKeyCode(KeyboardCode keycode, bool shift) {
return XF86XK_KbdBrightnessUp;
default:
LOG(WARNING) << "Unknown keycode:" << keycode;
//LOG(WARNING) << "Unknown keycode:" << keycode;
return 0;
}
}
......
......@@ -40,7 +40,7 @@ namespace internal {
#if defined(TOOLKIT_GTK)
const ImageSkia ImageSkiaFromGdkPixbuf(GdkPixbuf* pixbuf) {
CHECK(pixbuf);
//CHECK(pixbuf);
gfx::Canvas canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf)),
ui::SCALE_FACTOR_100P,
......@@ -55,7 +55,7 @@ const ImageSkia ImageSkiaFromGdkPixbuf(GdkPixbuf* pixbuf) {
// Returns a 16x16 red pixbuf to visually show error in decoding PNG.
// Also logs error to console.
GdkPixbuf* GetErrorPixbuf() {
LOG(ERROR) << "Unable to decode PNG.";
//LOG(ERROR) << "Unable to decode PNG.";
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 16, 16);
gdk_pixbuf_fill(pixbuf, 0xff0000ff);
return pixbuf;
......@@ -102,8 +102,10 @@ scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromPixbuf(
gchar* image = NULL;
gsize image_size;
GError* error = NULL;
CHECK(gdk_pixbuf_save_to_buffer(
pixbuf, &image, &image_size, "png", &error, NULL));
//CHECK(
gdk_pixbuf_save_to_buffer(
pixbuf, &image, &image_size, "png", &error, NULL);
//);
scoped_refptr<base::RefCountedBytes> png_bytes(
new base::RefCountedBytes());
png_bytes->data().assign(image, image + image_size);
......@@ -153,13 +155,13 @@ ImageSkia* ImageSkiaFromPNG(
for (size_t i = 0; i < image_png_reps.size(); ++i) {
scoped_refptr<base::RefCountedMemory> raw_data =
image_png_reps[i].raw_data;
CHECK(raw_data.get());
//CHECK(raw_data.get());
SkBitmap bitmap;
if (!gfx::PNGCodec::Decode(raw_data->front(), raw_data->size(),
&bitmap)) {
LOG(ERROR) << "Unable to decode PNG for "
<< ui::GetScaleFactorScale(image_png_reps[i].scale_factor)
<< ".";
//LOG(ERROR) << "Unable to decode PNG for "
// << ui::GetScaleFactorScale(image_png_reps[i].scale_factor)
// << ".";
return GetErrorImageSkia();
}
image_skia->AddRepresentation(gfx::ImageSkiaRep(
......@@ -204,35 +206,35 @@ class ImageRep {
// Cast helpers ("fake RTTI").
ImageRepPNG* AsImageRepPNG() {
CHECK_EQ(type_, Image::kImageRepPNG);
//CHECK_EQ(type_, Image::kImageRepPNG);
return reinterpret_cast<ImageRepPNG*>(this);
}
ImageRepSkia* AsImageRepSkia() {
CHECK_EQ(type_, Image::kImageRepSkia);
//CHECK_EQ(type_, Image::kImageRepSkia);
return reinterpret_cast<ImageRepSkia*>(this);
}
#if defined(TOOLKIT_GTK)
ImageRepGdk* AsImageRepGdk() {
CHECK_EQ(type_, Image::kImageRepGdk);
//CHECK_EQ(type_, Image::kImageRepGdk);
return reinterpret_cast<ImageRepGdk*>(this);
}
ImageRepCairo* AsImageRepCairo() {
CHECK_EQ(type_, Image::kImageRepCairo);
//CHECK_EQ(type_, Image::kImageRepCairo);
return reinterpret_cast<ImageRepCairo*>(this);
}
#endif
#if defined(OS_IOS)
ImageRepCocoaTouch* AsImageRepCocoaTouch() {
CHECK_EQ(type_, Image::kImageRepCocoaTouch);
//CHECK_EQ(type_, Image::kImageRepCocoaTouch);
return reinterpret_cast<ImageRepCocoaTouch*>(this);
}
#elif defined(OS_MACOSX)
ImageRepCocoa* AsImageRepCocoa() {
CHECK_EQ(type_, Image::kImageRepCocoa);
//CHECK_EQ(type_, Image::kImageRepCocoa);
return reinterpret_cast<ImageRepCocoa*>(this);
}
#endif
......@@ -332,7 +334,7 @@ class ImageRepGdk : public ImageRep {
explicit ImageRepGdk(GdkPixbuf* pixbuf)
: ImageRep(Image::kImageRepGdk),
pixbuf_(pixbuf) {
CHECK(pixbuf);
//CHECK(pixbuf);
}
virtual ~ImageRepGdk() {
......@@ -368,7 +370,7 @@ class ImageRepCairo : public ImageRep {
explicit ImageRepCairo(GdkPixbuf* pixbuf)
: ImageRep(Image::kImageRepCairo),
cairo_cache_(new CairoCachedSurface) {
CHECK(pixbuf);
//CHECK(pixbuf);
cairo_cache_->UsePixbuf(pixbuf);
}
......@@ -629,9 +631,12 @@ const ImageSkia* Image::ToImageSkia() const {
}
#endif
default:
NOTREACHED();
{
//NOTREACHED();
}
break;
}
CHECK(rep);
//CHECK(rep);
AddRepresentation(rep);
}
return rep->AsImageRepSkia()->image();
......@@ -657,9 +662,10 @@ GdkPixbuf* Image::ToGdkPixbuf() const {
break;
}
default:
NOTREACHED();
//NOTREACHED();
break;
}
CHECK(rep);
//CHECK(rep);
AddRepresentation(rep);
}
return rep->AsImageRepGdk()->pixbuf();
......@@ -671,7 +677,7 @@ CairoCachedSurface* const Image::ToCairo() const {
// Handle any-to-Cairo conversion. This may create and cache an intermediate
// pixbuf before sending the data to the display server.
rep = new internal::ImageRepCairo(ToGdkPixbuf());
CHECK(rep);
//CHECK(rep);
AddRepresentation(rep);
}
return rep->AsImageRepCairo()->surface();
......@@ -699,9 +705,10 @@ UIImage* Image::ToUIImage() const {
break;
}
default:
NOTREACHED();
//NOTREACHED();
break;
}
CHECK(rep);
//CHECK(rep);
AddRepresentation(rep);
}
return rep->AsImageRepCocoaTouch()->image();
......@@ -727,9 +734,10 @@ NSImage* Image::ToNSImage() const {
break;
}
default:
NOTREACHED();
//NOTREACHED();
break;
}
CHECK(rep);
//CHECK(rep);
AddRepresentation(rep);
}
return rep->AsImageRepCocoa()->image();
......@@ -785,7 +793,8 @@ scoped_refptr<base::RefCountedMemory> Image::As1xPNGBytes() const {
break;
}
default:
NOTREACHED();
//NOTREACHED();
break;
}
if (!png_bytes.get() || !png_bytes->size()) {
// Add an ImageRepPNG with no data such that the conversion is not
......@@ -897,27 +906,27 @@ void Image::SwapRepresentations(gfx::Image* other) {
}
Image::RepresentationType Image::DefaultRepresentationType() const {
CHECK(storage_.get());
//CHECK(storage_.get());
RepresentationType default_type = storage_->default_representation_type();
// The conversions above assume that the default representation type is never
// kImageRepCairo.
DCHECK_NE(default_type, kImageRepCairo);
//DCHECK_NE(default_type, kImageRepCairo);
return default_type;
}
internal::ImageRep* Image::GetRepresentation(
RepresentationType rep_type, bool must_exist) const {
CHECK(storage_.get());
//CHECK(storage_.get());
RepresentationMap::iterator it = storage_->representations().find(rep_type);
if (it == storage_->representations().end()) {
CHECK(!must_exist);
//CHECK(!must_exist);
return NULL;
}
return it->second;
}
void Image::AddRepresentation(internal::ImageRep* rep) const {
CHECK(storage_.get());
//CHECK(storage_.get());
storage_->representations().insert(std::make_pair(rep->type(), rep));
}
......
......@@ -15,7 +15,7 @@
#include "base/logging.h"
#include "base/stringprintf.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/rect_base_impl.h"
//#include "ui/gfx/rect_base_impl.h"
namespace gfx {
......
// 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 "ui/gfx/rect_base.h"
#include "base/logging.h"
#include "base/stringprintf.h"
// This file provides the implementation for RectBaese template and
// used to instantiate the base class for Rect and RectF classes.
#if !defined(UI_IMPLEMENTATION)
#error "This file is intended for UI implementation only"
#endif
namespace {
template<typename Type>
void AdjustAlongAxis(Type dst_origin, Type dst_size, Type* origin, Type* size) {
*size = std::min(dst_size, *size);
if (*origin < dst_origin)
*origin = dst_origin;
else
*origin = std::min(dst_origin + dst_size, *origin + *size) - *size;
}
} // namespace
namespace gfx {
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
SetRect(Type x, Type y, Type width, Type height) {
origin_.SetPoint(x, y);
set_width(width);
set_height(height);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Inset(const InsetsClass& insets) {
Inset(insets.left(), insets.top(), insets.right(), insets.bottom());
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Inset(Type left, Type top, Type right, Type bottom) {
origin_ += VectorClass(left, top);
set_width(std::max(width() - left - right, static_cast<Type>(0)));
set_height(std::max(height() - top - bottom, static_cast<Type>(0)));
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Offset(Type horizontal, Type vertical) {
origin_ += VectorClass(horizontal, vertical);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
operator+=(const VectorClass& offset) {
origin_ += offset;
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
operator-=(const VectorClass& offset) {
origin_ -= offset;
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
bool RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
operator<(const Class& other) const {
if (origin_ == other.origin_) {
if (width() == other.width()) {
return height() < other.height();
} else {
return width() < other.width();
}
} else {
return origin_ < other.origin_;
}
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
bool RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Contains(Type point_x, Type point_y) const {
return (point_x >= x()) && (point_x < right()) &&
(point_y >= y()) && (point_y < bottom());
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
bool RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Contains(const Class& rect) const {
return (rect.x() >= x() && rect.right() <= right() &&
rect.y() >= y() && rect.bottom() <= bottom());
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
bool RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Intersects(const Class& rect) const {
return !(rect.x() >= right() || rect.right() <= x() ||
rect.y() >= bottom() || rect.bottom() <= y());
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Intersect(const Class& rect) {
if (IsEmpty() || rect.IsEmpty()) {
SetRect(0, 0, 0, 0);
return;
}
Type rx = std::max(x(), rect.x());
Type ry = std::max(y(), rect.y());
Type rr = std::min(right(), rect.right());
Type rb = std::min(bottom(), rect.bottom());
if (rx >= rr || ry >= rb)
rx = ry = rr = rb = 0; // non-intersecting
SetRect(rx, ry, rr - rx, rb - ry);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Union(const Class& rect) {
if (IsEmpty()) {
*this = rect;
return;
}
if (rect.IsEmpty())
return;
Type rx = std::min(x(), rect.x());
Type ry = std::min(y(), rect.y());
Type rr = std::max(right(), rect.right());
Type rb = std::max(bottom(), rect.bottom());
SetRect(rx, ry, rr - rx, rb - ry);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
Subtract(const Class& rect) {
if (!Intersects(rect))
return;
if (rect.Contains(*static_cast<const Class*>(this))) {
SetRect(0, 0, 0, 0);
return;
}
Type rx = x();
Type ry = y();
Type rr = right();
Type rb = bottom();
if (rect.y() <= y() && rect.bottom() >= bottom()) {
// complete intersection in the y-direction
if (rect.x() <= x()) {
rx = rect.right();
} else {
rr = rect.x();
}
} else if (rect.x() <= x() && rect.right() >= right()) {
// complete intersection in the x-direction
if (rect.y() <= y()) {
ry = rect.bottom();
} else {
rb = rect.y();
}
}
SetRect(rx, ry, rr - rx, rb - ry);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
AdjustToFit(const Class& rect) {
Type new_x = x();
Type new_y = y();
Type new_width = width();
Type new_height = height();
AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width);
AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height);
SetRect(new_x, new_y, new_width, new_height);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
PointClass RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass,
Type>::CenterPoint() const {
return PointClass(x() + width() / 2, y() + height() / 2);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
ClampToCenteredSize(const SizeClass& size) {
Type new_width = std::min(width(), size.width());
Type new_height = std::min(height(), size.height());
Type new_x = x() + (width() - new_width) / 2;
Type new_y = y() + (height() - new_height) / 2;
SetRect(new_x, new_y, new_width, new_height);
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
void RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
SplitVertically(Class* left_half, Class* right_half) const {
DCHECK(left_half);
DCHECK(right_half);
left_half->SetRect(x(), y(), width() / 2, height());
right_half->SetRect(left_half->right(),
y(),
width() - left_half->width(),
height());
}
template<typename Class,
typename PointClass,
typename SizeClass,
typename InsetsClass,
typename VectorClass,
typename Type>
bool RectBase<Class, PointClass, SizeClass, InsetsClass, VectorClass, Type>::
SharesEdgeWith(const Class& rect) const {
return (y() == rect.y() && height() == rect.height() &&
(x() == rect.right() || right() == rect.x())) ||
(x() == rect.x() && width() == rect.width() &&
(y() == rect.bottom() || bottom() == rect.y()));
}
} // namespace gfx
......@@ -44,10 +44,10 @@ Rect ToNearestRect(const RectF& rect) {
// If these DCHECKs fail, you're using the wrong method, consider using
// ToEnclosingRect or ToEnclosedRect instead.
DCHECK(std::abs(min_x - float_min_x) < 0.01f);
DCHECK(std::abs(min_y - float_min_y) < 0.01f);
DCHECK(std::abs(max_x - float_max_x) < 0.01f);
DCHECK(std::abs(max_y - float_max_y) < 0.01f);
//DCHECK(std::abs(min_x - float_min_x) < 0.01f);
//DCHECK(std::abs(min_y - float_min_y) < 0.01f);
//DCHECK(std::abs(max_x - float_max_x) < 0.01f);
//DCHECK(std::abs(max_y - float_max_y) < 0.01f);
return Rect(min_x, min_y, max_x - min_x, max_y - min_y);
}
......
......@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "base/stringprintf.h"
#include "ui/gfx/insets_f.h"
#include "ui/gfx/rect_base_impl.h"
//#include "ui/gfx/rect_base_impl.h"
#include "ui/gfx/safe_integer_conversions.h"
namespace gfx {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment