OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/gpu/gpu_channel.h" | 5 #include "content/common/gpu/gpu_channel.h" |
6 #include "content/common/gpu/gpu_messages.h" | 6 #include "content/common/gpu/gpu_messages.h" |
7 #include "content/common/gpu/transport_texture.h" | 7 #include "content/common/gpu/transport_texture.h" |
8 | 8 |
9 TransportTexture::TransportTexture(GpuChannel* channel, | 9 TransportTexture::TransportTexture(GpuChannel* channel, |
10 IPC::Message::Sender* sender, | 10 IPC::Message::Sender* sender, |
(...skipping 14 matching lines...) Expand all Loading... |
25 void TransportTexture::CreateTextures( | 25 void TransportTexture::CreateTextures( |
26 int n, int width, int height, Format format, std::vector<int>* textures, | 26 int n, int width, int height, Format format, std::vector<int>* textures, |
27 Task* done_task) { | 27 Task* done_task) { |
28 output_textures_ = textures; | 28 output_textures_ = textures; |
29 DCHECK(!create_task_.get()); | 29 DCHECK(!create_task_.get()); |
30 create_task_.reset(done_task); | 30 create_task_.reset(done_task); |
31 | 31 |
32 bool ret = sender_->Send(new GpuTransportTextureHostMsg_CreateTextures( | 32 bool ret = sender_->Send(new GpuTransportTextureHostMsg_CreateTextures( |
33 host_id_, n, width, height, static_cast<int>(format))); | 33 host_id_, n, width, height, static_cast<int>(format))); |
34 if (!ret) { | 34 if (!ret) { |
35 LOG(ERROR) << "GpuTransportTexture_CreateTextures failed"; | 35 DLOG(ERROR) << "GpuTransportTexture_CreateTextures failed"; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 void TransportTexture::ReleaseTextures() { | 39 void TransportTexture::ReleaseTextures() { |
40 texture_map_.clear(); | 40 texture_map_.clear(); |
41 | 41 |
42 bool ret = sender_->Send(new GpuTransportTextureHostMsg_ReleaseTextures( | 42 bool ret = sender_->Send(new GpuTransportTextureHostMsg_ReleaseTextures( |
43 host_id_)); | 43 host_id_)); |
44 if (!ret) { | 44 if (!ret) { |
45 LOG(ERROR) << "GpuTransportTexture_ReleaseTextures failed"; | 45 DLOG(ERROR) << "GpuTransportTexture_ReleaseTextures failed"; |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 void TransportTexture::TextureUpdated(int texture_id) { | 49 void TransportTexture::TextureUpdated(int texture_id) { |
50 TextureMap::iterator iter = texture_map_.find(texture_id); | 50 TextureMap::iterator iter = texture_map_.find(texture_id); |
51 if (iter == texture_map_.end()) { | 51 if (iter == texture_map_.end()) { |
52 LOG(ERROR) << "Texture not found: " << texture_id; | 52 DLOG(ERROR) << "Texture not found: " << texture_id; |
53 return; | 53 return; |
54 } | 54 } |
55 | 55 |
56 bool ret = sender_->Send(new GpuTransportTextureHostMsg_TextureUpdated( | 56 bool ret = sender_->Send(new GpuTransportTextureHostMsg_TextureUpdated( |
57 host_id_, iter->second)); | 57 host_id_, iter->second)); |
58 if (!ret) { | 58 if (!ret) { |
59 LOG(ERROR) << "GpuTransportTexture_TextureUpdated failed"; | 59 DLOG(ERROR) << "GpuTransportTexture_TextureUpdated failed"; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 void TransportTexture::OnChannelConnected(int32 peer_pid) { | 63 void TransportTexture::OnChannelConnected(int32 peer_pid) { |
64 } | 64 } |
65 | 65 |
66 void TransportTexture::OnChannelError() { | 66 void TransportTexture::OnChannelError() { |
67 } | 67 } |
68 | 68 |
69 bool TransportTexture::OnMessageReceived(const IPC::Message& msg) { | 69 bool TransportTexture::OnMessageReceived(const IPC::Message& msg) { |
70 bool handled = true; | 70 bool handled = true; |
71 IPC_BEGIN_MESSAGE_MAP(TransportTexture, msg) | 71 IPC_BEGIN_MESSAGE_MAP(TransportTexture, msg) |
72 IPC_MESSAGE_HANDLER(GpuTransportTextureMsg_Destroy, | 72 IPC_MESSAGE_HANDLER(GpuTransportTextureMsg_Destroy, |
73 OnDestroy) | 73 OnDestroy) |
74 IPC_MESSAGE_HANDLER(GpuTransportTextureMsg_TexturesCreated, | 74 IPC_MESSAGE_HANDLER(GpuTransportTextureMsg_TexturesCreated, |
75 OnTexturesCreated) | 75 OnTexturesCreated) |
76 IPC_MESSAGE_UNHANDLED(handled = false) | 76 IPC_MESSAGE_UNHANDLED(handled = false) |
77 IPC_END_MESSAGE_MAP() | 77 IPC_END_MESSAGE_MAP() |
78 DCHECK(handled); | 78 DCHECK(handled); |
79 return handled; | 79 return handled; |
80 } | 80 } |
81 | 81 |
82 void TransportTexture::OnDestroy() { | 82 void TransportTexture::OnDestroy() { |
83 channel_->DestroyTransportTexture(route_id_); | 83 channel_->DestroyTransportTexture(route_id_); |
84 } | 84 } |
85 | 85 |
86 void TransportTexture::OnTexturesCreated(const std::vector<int>& textures) { | 86 void TransportTexture::OnTexturesCreated(const std::vector<int>& textures) { |
87 bool ret = decoder_->MakeCurrent(); | 87 bool ret = decoder_->MakeCurrent(); |
88 if (!ret) { | 88 if (!ret) { |
89 LOG(ERROR) << "Failed to switch context"; | 89 DLOG(ERROR) << "Failed to switch context"; |
90 return; | 90 return; |
91 } | 91 } |
92 | 92 |
93 output_textures_->clear(); | 93 output_textures_->clear(); |
94 for (size_t i = 0; i < textures.size(); ++i) { | 94 for (size_t i = 0; i < textures.size(); ++i) { |
95 uint32 gl_texture = 0; | 95 uint32 gl_texture = 0; |
96 | 96 |
97 // Translate the client texture id to service texture id. | 97 // Translate the client texture id to service texture id. |
98 ret = decoder_->GetServiceTextureId(textures[i], &gl_texture); | 98 ret = decoder_->GetServiceTextureId(textures[i], &gl_texture); |
99 DCHECK(ret) << "Cannot translate client texture ID to service ID"; | 99 DCHECK(ret) << "Cannot translate client texture ID to service ID"; |
100 output_textures_->push_back(gl_texture); | 100 output_textures_->push_back(gl_texture); |
101 texture_map_.insert(std::make_pair(gl_texture, textures[i])); | 101 texture_map_.insert(std::make_pair(gl_texture, textures[i])); |
102 } | 102 } |
103 | 103 |
104 // Notify user that textures are ready. | 104 // Notify user that textures are ready. |
105 create_task_->Run(); | 105 create_task_->Run(); |
106 create_task_.reset(); | 106 create_task_.reset(); |
107 output_textures_ = NULL; | 107 output_textures_ = NULL; |
108 } | 108 } |
OLD | NEW |