#include "base/bind.h"
#include "base/debug/trace_event.h"
+#include "base/debug/trace_event_synthetic_delay.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "gpu/command_buffer/service/async_pixel_transfer_delegate.h"
-#include "gpu/command_buffer/service/safe_shared_memory_pool.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/scoped_binders.h"
void PerformNotifyCompletion(
AsyncMemoryParams mem_params,
- ScopedSafeSharedMemory* safe_shared_memory,
scoped_refptr<AsyncPixelTransferCompletionObserver> observer) {
TRACE_EVENT0("gpu", "PerformNotifyCompletion");
- AsyncMemoryParams safe_mem_params = mem_params;
- safe_mem_params.shared_memory = safe_shared_memory->shared_memory();
- observer->DidComplete(safe_mem_params);
+ observer->DidComplete(mem_params);
}
class TransferThread : public base::Thread {
context_ = NULL;
}
- SafeSharedMemoryPool* safe_shared_memory_pool() {
- return &safe_shared_memory_pool_;
- }
-
private:
scoped_refptr<gfx::GLContext> context_;
scoped_refptr<gfx::GLSurface> surface_;
- SafeSharedMemoryPool safe_shared_memory_pool_;
-
DISALLOW_COPY_AND_ASSIGN(TransferThread);
};
return g_transfer_thread.Pointer()->message_loop_proxy().get();
}
-SafeSharedMemoryPool* safe_shared_memory_pool() {
- return g_transfer_thread.Pointer()->safe_shared_memory_pool();
-}
-
// Class which holds async pixel transfers state (EGLImage).
// The EGLImage is accessed by either thread, but everything
// else accessed only on the main thread.
}
void MarkAsTransferIsInProgress() {
+ TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("gpu.AsyncTexImage");
transfer_completion_.Reset();
}
void MarkAsCompleted() {
+ TRACE_EVENT_SYNTHETIC_DELAY_END("gpu.AsyncTexImage");
transfer_completion_.Signal();
}
void PerformAsyncTexImage2D(
AsyncTexImage2DParams tex_params,
AsyncMemoryParams mem_params,
- ScopedSafeSharedMemory* safe_shared_memory,
scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats) {
TRACE_EVENT2("gpu",
"PerformAsyncTexImage",
return;
}
- void* data =
- AsyncPixelTransferDelegate::GetAddress(safe_shared_memory, mem_params);
+ void* data = mem_params.GetDataAddress();
base::TimeTicks begin_time;
if (texture_upload_stats.get())
void PerformAsyncTexSubImage2D(
AsyncTexSubImage2DParams tex_params,
AsyncMemoryParams mem_params,
- ScopedSafeSharedMemory* safe_shared_memory,
scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats) {
TRACE_EVENT2("gpu",
"PerformAsyncTexSubImage2D",
DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
DCHECK_EQ(0, tex_params.level);
- void* data =
- AsyncPixelTransferDelegate::GetAddress(safe_shared_memory, mem_params);
+ void* data = mem_params.GetDataAddress();
base::TimeTicks begin_time;
if (texture_upload_stats.get())
if (WorkAroundAsyncTexImage2D(tex_params, mem_params, bind_callback))
return;
- DCHECK(mem_params.shared_memory);
- DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
- mem_params.shm_size);
DCHECK(!state_->TransferIsInProgress());
DCHECK_EQ(state_->egl_image_, EGL_NO_IMAGE_KHR);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), tex_params.target);
state_,
tex_params,
mem_params,
- base::Owned(new ScopedSafeSharedMemory(safe_shared_memory_pool(),
- mem_params.shared_memory,
- mem_params.shm_size)),
shared_state_->texture_upload_stats));
DCHECK(CHECK_GL());
if (WorkAroundAsyncTexSubImage2D(tex_params, mem_params))
return;
DCHECK(!state_->TransferIsInProgress());
- DCHECK(mem_params.shared_memory);
- DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
- mem_params.shm_size);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), tex_params.target);
DCHECK_EQ(tex_params.level, 0);
state_,
tex_params,
mem_params,
- base::Owned(new ScopedSafeSharedMemory(safe_shared_memory_pool(),
- mem_params.shared_memory,
- mem_params.shm_size)),
shared_state_->texture_upload_stats));
DCHECK(CHECK_GL());
// On imagination we allocate synchronously all the time, even
// if the dimensions support fast uploads. This is for part a.)
// above, so allocations occur on a different thread/context as uploads.
- void* data = GetAddress(mem_params);
+ void* data = mem_params.GetDataAddress();
SetGlParametersForEglImageTexture();
{
DCHECK_EQ(state_->define_params_.format, tex_params.format);
DCHECK_EQ(state_->define_params_.type, tex_params.type);
- void* data = GetAddress(mem_params);
+ void* data = mem_params.GetDataAddress();
base::TimeTicks begin_time;
if (shared_state_->texture_upload_stats.get())
begin_time = base::TimeTicks::HighResNow();
void AsyncPixelTransferManagerEGL::AsyncNotifyCompletion(
const AsyncMemoryParams& mem_params,
AsyncPixelTransferCompletionObserver* observer) {
- DCHECK(mem_params.shared_memory);
- DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
- mem_params.shm_size);
// Post a PerformNotifyCompletion task to the upload thread. This task
// will run after all async transfers are complete.
transfer_message_loop_proxy()->PostTask(
FROM_HERE,
base::Bind(&PerformNotifyCompletion,
mem_params,
- base::Owned(
- new ScopedSafeSharedMemory(safe_shared_memory_pool(),
- mem_params.shared_memory,
- mem_params.shm_size)),
make_scoped_refptr(observer)));
}
return false;
}
+void AsyncPixelTransferManagerEGL::WaitAllAsyncTexImage2D() {
+ if (shared_state_.pending_allocations.empty())
+ return;
+
+ AsyncPixelTransferDelegateEGL* delegate =
+ shared_state_.pending_allocations.back().get();
+ if (delegate)
+ delegate->WaitForTransferCompletion();
+}
+
AsyncPixelTransferDelegate*
AsyncPixelTransferManagerEGL::CreatePixelTransferDelegateImpl(
gles2::TextureRef* ref,