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

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

Issue 9564008: Aura: PostSubBuffer implementation for --ui-use-gpu-process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/texture_image_transport_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/common/gpu/texture_image_transport_surface.h" 5 #include "content/common/gpu/texture_image_transport_surface.h"
6 6
7 #include "content/common/gpu/gpu_channel.h" 7 #include "content/common/gpu/gpu_channel.h"
8 #include "content/common/gpu/gpu_channel_manager.h" 8 #include "content/common/gpu/gpu_channel_manager.h"
9 #include "content/common/gpu/gpu_messages.h" 9 #include "content/common/gpu/gpu_messages.h"
10 #include "gpu/command_buffer/service/context_group.h" 10 #include "gpu/command_buffer/service/context_group.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 CHECK_GL_ERROR(); 183 CHECK_GL_ERROR();
184 fbo_id_ = 0; 184 fbo_id_ = 0;
185 185
186 stub->RemoveDestructionObserver(this); 186 stub->RemoveDestructionObserver(this);
187 stub_destroyed_ = true; 187 stub_destroyed_ = true;
188 } 188 }
189 189
190 bool TextureImageTransportSurface::SwapBuffers() { 190 bool TextureImageTransportSurface::SwapBuffers() {
191 glFlush(); 191 glFlush();
192 front_ = back(); 192 front_ = back();
193 previous_damage_rect_ = gfx::Rect(textures_[front_].size);
193 194
194 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 195 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
195 params.surface_handle = textures_[front_].client_id; 196 params.surface_handle = textures_[front_].client_id;
196 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 197 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
197 helper_->SetScheduled(false); 198 helper_->SetScheduled(false);
198 return true; 199 return true;
199 } 200 }
200 201
201 bool TextureImageTransportSurface::PostSubBuffer( 202 bool TextureImageTransportSurface::PostSubBuffer(
202 int x, int y, int width, int height) { 203 int x, int y, int width, int height) {
203 // TODO(piman): implement this, similarly to EGLImageTransportSurface. 204 if (!parent_stub_.get())
204 NOTREACHED(); 205 return false;
205 return false; 206
207 TextureInfo* info = GetParentInfo(textures_[back()].client_id);
208 if (!info)
209 return false;
210 int back_texture_service_id = info->service_id();
211
212 info = GetParentInfo(textures_[front_].client_id);
213 if (!info)
214 return false;
215 int front_texture_service_id = info->service_id();
216
217 gfx::Size expected_size = textures_[back()].size;
218 bool surfaces_same_size = textures_[front_].size == expected_size;
219
220 const gfx::Rect new_damage_rect(x, y, width, height);
221 if (surfaces_same_size) {
222 std::vector<gfx::Rect> regions_to_copy;
223 GetRegionsToCopy(previous_damage_rect_, new_damage_rect, &regions_to_copy);
224
225 ScopedFrameBufferBinder fbo_binder(fbo_id_);
226 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
227 GL_COLOR_ATTACHMENT0,
228 GL_TEXTURE_2D,
229 front_texture_service_id,
230 0);
231 ScopedTextureBinder texture_binder(back_texture_service_id);
232
233 for (size_t i = 0; i < regions_to_copy.size(); ++i) {
234 const gfx::Rect& region_to_copy = regions_to_copy[i];
235 if (!region_to_copy.IsEmpty()) {
236 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, region_to_copy.x(),
237 region_to_copy.y(), region_to_copy.x(), region_to_copy.y(),
238 region_to_copy.width(), region_to_copy.height());
239 }
240 }
241 } else {
242 DCHECK(new_damage_rect == gfx::Rect(expected_size));
243 }
244
245 glFlush();
246 front_ = back();
247
248 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params;
249 params.surface_handle = textures_[front_].client_id;
250 params.x = x;
251 params.y = y;
252 params.width = width;
253 params.height = height;
254 helper_->SendAcceleratedSurfacePostSubBuffer(params);
255 helper_->SetScheduled(false);
256
257 previous_damage_rect_ = new_damage_rect;
258 return true;
206 } 259 }
207 260
208 std::string TextureImageTransportSurface::GetExtensions() { 261 std::string TextureImageTransportSurface::GetExtensions() {
209 std::string extensions = gfx::GLSurface::GetExtensions(); 262 std::string extensions = gfx::GLSurface::GetExtensions();
210 extensions += extensions.empty() ? "" : " "; 263 extensions += extensions.empty() ? "" : " ";
211 extensions += "GL_CHROMIUM_front_buffer_cached"; 264 extensions += "GL_CHROMIUM_front_buffer_cached ";
265 extensions += "GL_CHROMIUM_post_sub_buffer";
212 return extensions; 266 return extensions;
213 } 267 }
214 268
215 gfx::Size TextureImageTransportSurface::GetSize() { 269 gfx::Size TextureImageTransportSurface::GetSize() {
216 return textures_[back()].size; 270 return textures_[back()].size;
217 } 271 }
218 272
219 void* TextureImageTransportSurface::GetHandle() { 273 void* TextureImageTransportSurface::GetHandle() {
220 return parent_stub_.get() ? parent_stub_->surface()->GetHandle() : NULL; 274 return parent_stub_.get() ? parent_stub_->surface()->GetHandle() : NULL;
221 } 275 }
(...skipping 11 matching lines...) Expand all
233 AttachBackTextureToFBO(); 287 AttachBackTextureToFBO();
234 } 288 }
235 } 289 }
236 290
237 // Even if MakeCurrent fails, schedule anyway, to trigger the lost context 291 // Even if MakeCurrent fails, schedule anyway, to trigger the lost context
238 // logic. 292 // logic.
239 helper_->SetScheduled(true); 293 helper_->SetScheduled(true);
240 } 294 }
241 295
242 void TextureImageTransportSurface::OnPostSubBufferACK() { 296 void TextureImageTransportSurface::OnPostSubBufferACK() {
243 NOTREACHED(); 297 OnBuffersSwappedACK();
244 } 298 }
245 299
246 void TextureImageTransportSurface::OnResizeViewACK() { 300 void TextureImageTransportSurface::OnResizeViewACK() {
247 NOTREACHED(); 301 NOTREACHED();
248 } 302 }
249 303
250 void TextureImageTransportSurface::ReleaseBackTexture() { 304 void TextureImageTransportSurface::ReleaseBackTexture() {
251 if (!parent_stub_.get()) 305 if (!parent_stub_.get())
252 return; 306 return;
253 TextureInfo* info = GetParentInfo(textures_[back()].client_id); 307 TextureInfo* info = GetParentInfo(textures_[back()].client_id);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 #endif 403 #endif
350 } 404 }
351 405
352 TextureInfo* TextureImageTransportSurface::GetParentInfo(uint32 client_id) { 406 TextureInfo* TextureImageTransportSurface::GetParentInfo(uint32 client_id) {
353 DCHECK(parent_stub_.get()); 407 DCHECK(parent_stub_.get());
354 TextureManager* texture_manager = 408 TextureManager* texture_manager =
355 parent_stub_->decoder()->GetContextGroup()->texture_manager(); 409 parent_stub_->decoder()->GetContextGroup()->texture_manager();
356 TextureInfo* info = texture_manager->GetTextureInfo(client_id); 410 TextureInfo* info = texture_manager->GetTextureInfo(client_id);
357 return info; 411 return info;
358 } 412 }
OLDNEW
« no previous file with comments | « content/common/gpu/texture_image_transport_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698