Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 177953004: Enable SurfaceTexture based zero-copy texture uploading on Android platform Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/hash.h" 9 #include "base/hash.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 23 matching lines...) Expand all
34 #include "gpu/command_buffer/service/query_manager.h" 34 #include "gpu/command_buffer/service/query_manager.h"
35 #include "ui/gl/gl_bindings.h" 35 #include "ui/gl/gl_bindings.h"
36 #include "ui/gl/gl_switches.h" 36 #include "ui/gl/gl_switches.h"
37 37
38 #if defined(OS_WIN) 38 #if defined(OS_WIN)
39 #include "content/public/common/sandbox_init.h" 39 #include "content/public/common/sandbox_init.h"
40 #endif 40 #endif
41 41
42 #if defined(OS_ANDROID) 42 #if defined(OS_ANDROID)
43 #include "content/common/gpu/stream_texture_android.h" 43 #include "content/common/gpu/stream_texture_android.h"
44 #include "content/common/gpu/surface_texture_bridge_android.h"
44 #endif 45 #endif
45 46
46 namespace content { 47 namespace content {
47 namespace { 48 namespace {
48 49
49 // The GpuCommandBufferMemoryTracker class provides a bridge between the 50 // The GpuCommandBufferMemoryTracker class provides a bridge between the
50 // ContextGroup's memory type managers and the GpuMemoryManager class. 51 // ContextGroup's memory type managers and the GpuMemoryManager class.
51 class GpuCommandBufferMemoryTracker : public gpu::gles2::MemoryTracker { 52 class GpuCommandBufferMemoryTracker : public gpu::gles2::MemoryTracker {
52 public: 53 public:
53 explicit GpuCommandBufferMemoryTracker(GpuChannel* channel) : 54 explicit GpuCommandBufferMemoryTracker(GpuChannel* channel) :
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 OnReceivedClientManagedMemoryStats) 219 OnReceivedClientManagedMemoryStats)
219 IPC_MESSAGE_HANDLER( 220 IPC_MESSAGE_HANDLER(
220 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, 221 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback,
221 OnSetClientHasMemoryAllocationChangedCallback) 222 OnSetClientHasMemoryAllocationChangedCallback)
222 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterGpuMemoryBuffer, 223 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RegisterGpuMemoryBuffer,
223 OnRegisterGpuMemoryBuffer); 224 OnRegisterGpuMemoryBuffer);
224 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyGpuMemoryBuffer, 225 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyGpuMemoryBuffer,
225 OnDestroyGpuMemoryBuffer); 226 OnDestroyGpuMemoryBuffer);
226 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture, 227 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture,
227 OnCreateStreamTexture) 228 OnCreateStreamTexture)
229 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateSurfaceTexture,
230 OnCreateSurfaceTexture)
228 IPC_MESSAGE_UNHANDLED(handled = false) 231 IPC_MESSAGE_UNHANDLED(handled = false)
229 IPC_END_MESSAGE_MAP() 232 IPC_END_MESSAGE_MAP()
230 233
231 // Ensure that any delayed work that was created will be handled. 234 // Ensure that any delayed work that was created will be handled.
232 ScheduleDelayedWork(kHandleMoreWorkPeriodMs); 235 ScheduleDelayedWork(kHandleMoreWorkPeriodMs);
233 236
234 DCHECK(handled); 237 DCHECK(handled);
235 return handled; 238 return handled;
236 } 239 }
237 240
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 577
575 void GpuCommandBufferStub::OnCreateStreamTexture(uint32 texture_id, 578 void GpuCommandBufferStub::OnCreateStreamTexture(uint32 texture_id,
576 int32* stream_id) { 579 int32* stream_id) {
577 #if defined(OS_ANDROID) 580 #if defined(OS_ANDROID)
578 *stream_id = StreamTexture::Create(this, texture_id); 581 *stream_id = StreamTexture::Create(this, texture_id);
579 #else 582 #else
580 *stream_id = 0; 583 *stream_id = 0;
581 #endif 584 #endif
582 } 585 }
583 586
587 void GpuCommandBufferStub::OnCreateSurfaceTexture(
588 uint32 gpu_memory_buffer,
589 uint32* surface_texture_handle,
590 uint32* gpu_texture_id) {
591 #if defined(OS_ANDROID)
592 gfx::SurfaceTexture* surface_texture =
593 SurfaceTextureBridge::CreateSurfaceTexture(this, gpu_texture_id);
594 surface_texture->AddRef();
595 SurfaceTextureBridge::SetupSurfaceTexturePeer(
596 this, reinterpret_cast<void*>(gpu_memory_buffer), surface_texture);
597 *surface_texture_handle = reinterpret_cast<uint32>(surface_texture);
598 #else
599 *surface_texture_handle = 0;
600 *gpu_texture_id = 0;
601 #endif
602 }
603
584 void GpuCommandBufferStub::SetLatencyInfoCallback( 604 void GpuCommandBufferStub::SetLatencyInfoCallback(
585 const LatencyInfoCallback& callback) { 605 const LatencyInfoCallback& callback) {
586 latency_info_callback_ = callback; 606 latency_info_callback_ = callback;
587 } 607 }
588 608
589 int32 GpuCommandBufferStub::GetRequestedAttribute(int attr) const { 609 int32 GpuCommandBufferStub::GetRequestedAttribute(int attr) const {
590 // The command buffer is pairs of enum, value 610 // The command buffer is pairs of enum, value
591 // search for the requested attribute, return the value. 611 // search for the requested attribute, return the value.
592 for (std::vector<int32>::const_iterator it = requested_attribs_.begin(); 612 for (std::vector<int32>::const_iterator it = requested_attribs_.begin();
593 it != requested_attribs_.end(); ++it) { 613 it != requested_attribs_.end(); ++it) {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 if (decoder_) 994 if (decoder_)
975 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); 995 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
976 command_buffer_->SetParseError(gpu::error::kLostContext); 996 command_buffer_->SetParseError(gpu::error::kLostContext);
977 } 997 }
978 998
979 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 999 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
980 return GetMemoryManager()->GetClientMemoryUsage(this); 1000 return GetMemoryManager()->GetClientMemoryUsage(this);
981 } 1001 }
982 1002
983 } // namespace content 1003 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698