| OLD | NEW |
| 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
| 10 | 10 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 return false; | 571 return false; |
| 572 } | 572 } |
| 573 stubs_.AddWithID(stub.release(), route_id); | 573 stubs_.AddWithID(stub.release(), route_id); |
| 574 return true; | 574 return true; |
| 575 } | 575 } |
| 576 | 576 |
| 577 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) { | 577 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) { |
| 578 return stubs_.Lookup(route_id); | 578 return stubs_.Lookup(route_id); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void GpuChannel::CreateImage( | 581 bool GpuChannel::CreateImage( |
| 582 gfx::PluginWindowHandle window, | 582 const gfx::GpuMemoryBufferHandle& handle, |
| 583 int32 image_id, | 583 const gfx::Size& size, |
| 584 gfx::Size* size) { | 584 unsigned internalformat, |
| 585 int32 image_id) { |
| 585 TRACE_EVENT1("gpu", | 586 TRACE_EVENT1("gpu", |
| 586 "GpuChannel::CreateImage", | 587 "GpuChannel::CreateImage", |
| 587 "image_id", | 588 "image_id", |
| 588 image_id); | 589 image_id); |
| 589 | 590 |
| 590 *size = gfx::Size(); | |
| 591 | |
| 592 if (image_manager_->LookupImage(image_id)) { | 591 if (image_manager_->LookupImage(image_id)) { |
| 593 LOG(ERROR) << "CreateImage failed, image_id already in use."; | 592 LOG(ERROR) << "CreateImage failed, image_id already in use."; |
| 594 return; | 593 return false; |
| 595 } | 594 } |
| 596 | 595 |
| 597 scoped_refptr<gfx::GLImage> image = gfx::GLImage::CreateGLImage(window); | 596 scoped_refptr<gfx::GLImage> image = |
| 597 gfx::GLImage::CreateGLImageForGpuMemoryBuffer( |
| 598 handle, size, internalformat); |
| 598 if (!image.get()) | 599 if (!image.get()) |
| 599 return; | 600 return false; |
| 600 | 601 |
| 601 image_manager_->AddImage(image.get(), image_id); | 602 image_manager_->AddImage(image.get(), image_id); |
| 602 *size = image->GetSize(); | 603 return true; |
| 603 } | 604 } |
| 604 | 605 |
| 605 void GpuChannel::DeleteImage(int32 image_id) { | 606 void GpuChannel::DeleteImage(int32 image_id) { |
| 606 TRACE_EVENT1("gpu", | 607 TRACE_EVENT1("gpu", |
| 607 "GpuChannel::DeleteImage", | 608 "GpuChannel::DeleteImage", |
| 608 "image_id", | 609 "image_id", |
| 609 image_id); | 610 image_id); |
| 610 | 611 |
| 611 image_manager_->RemoveImage(image_id); | 612 image_manager_->RemoveImage(image_id); |
| 612 } | 613 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 uint64 GpuChannel::GetMemoryUsage() { | 837 uint64 GpuChannel::GetMemoryUsage() { |
| 837 uint64 size = 0; | 838 uint64 size = 0; |
| 838 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); | 839 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); |
| 839 !it.IsAtEnd(); it.Advance()) { | 840 !it.IsAtEnd(); it.Advance()) { |
| 840 size += it.GetCurrentValue()->GetMemoryUsage(); | 841 size += it.GetCurrentValue()->GetMemoryUsage(); |
| 841 } | 842 } |
| 842 return size; | 843 return size; |
| 843 } | 844 } |
| 844 | 845 |
| 845 } // namespace content | 846 } // namespace content |
| OLD | NEW |