| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 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/browser/compositor/buffer_queue.h" |    5 #include "content/browser/compositor/buffer_queue.h" | 
|    6  |    6  | 
|    7 #include "content/browser/compositor/image_transport_factory.h" |    7 #include "content/browser/compositor/image_transport_factory.h" | 
|    8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |    8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 
|    9 #include "content/common/gpu/client/context_provider_command_buffer.h" |    9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 
|   10 #include "content/common/gpu/client/gl_helper.h" |   10 #include "content/common/gpu/client/gl_helper.h" | 
|   11 #include "gpu/GLES2/gl2extchromium.h" |   11 #include "gpu/GLES2/gl2extchromium.h" | 
|   12 #include "gpu/command_buffer/client/gles2_interface.h" |   12 #include "gpu/command_buffer/client/gles2_interface.h" | 
|   13 #include "gpu/command_buffer/service/image_factory.h" |   13 #include "gpu/command_buffer/service/image_factory.h" | 
|   14 #include "third_party/skia/include/core/SkRect.h" |   14 #include "third_party/skia/include/core/SkRect.h" | 
|   15 #include "third_party/skia/include/core/SkRegion.h" |   15 #include "third_party/skia/include/core/SkRegion.h" | 
|   16 #include "ui/gfx/gpu_memory_buffer.h" |   16 #include "ui/gfx/gpu_memory_buffer.h" | 
 |   17 #include "ui/gfx/skia_util.h" | 
|   17  |   18  | 
|   18 namespace content { |   19 namespace content { | 
|   19  |   20  | 
|   20 BufferQueue::BufferQueue( |   21 BufferQueue::BufferQueue( | 
|   21     scoped_refptr<cc::ContextProvider> context_provider, |   22     scoped_refptr<cc::ContextProvider> context_provider, | 
|   22     unsigned int internalformat, |   23     unsigned int internalformat, | 
|   23     GLHelper* gl_helper, |   24     GLHelper* gl_helper, | 
|   24     BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager, |   25     BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager, | 
|   25     int surface_id) |   26     int surface_id) | 
|   26     : context_provider_(context_provider), |   27     : context_provider_(context_provider), | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|   56                              GL_TEXTURE_2D, |   57                              GL_TEXTURE_2D, | 
|   57                              current_surface_.texture, |   58                              current_surface_.texture, | 
|   58                              0); |   59                              0); | 
|   59   } |   60   } | 
|   60 } |   61 } | 
|   61  |   62  | 
|   62 void BufferQueue::CopyBufferDamage(int texture, |   63 void BufferQueue::CopyBufferDamage(int texture, | 
|   63                                    int source_texture, |   64                                    int source_texture, | 
|   64                                    const gfx::Rect& new_damage, |   65                                    const gfx::Rect& new_damage, | 
|   65                                    const gfx::Rect& old_damage) { |   66                                    const gfx::Rect& old_damage) { | 
 |   67   gfx::Rect new_damage_mutable = new_damage; | 
 |   68   gfx::Rect old_damage_mutable = old_damage; | 
 |   69 #if defined(ARCH_CPU_ARM_FAMILY) | 
 |   70   // TODO(dnicoara): Remove ARM workaround once partial swap is enabled. | 
 |   71   new_damage_mutable = gfx::Rect(size_); | 
 |   72   old_damage_mutable = gfx::Rect(); | 
 |   73 #endif | 
 |   74  | 
|   66   gl_helper_->CopySubBufferDamage( |   75   gl_helper_->CopySubBufferDamage( | 
|   67       texture, |   76       texture, source_texture, | 
|   68       source_texture, |   77       SkRegion(gfx::RectToSkIRect(new_damage_mutable)), | 
|   69       SkRegion(SkIRect::MakeXYWH(new_damage.x(), |   78       SkRegion(gfx::RectToSkIRect(old_damage_mutable))); | 
|   70                                  new_damage.y(), |  | 
|   71                                  new_damage.width(), |  | 
|   72                                  new_damage.height())), |  | 
|   73       SkRegion(SkIRect::MakeXYWH(old_damage.x(), |  | 
|   74                                  old_damage.y(), |  | 
|   75                                  old_damage.width(), |  | 
|   76                                  old_damage.height()))); |  | 
|   77 } |   79 } | 
|   78  |   80  | 
|   79 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { |   81 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { | 
|   80   displayed_surface_.damage.Union(damage); |   82   displayed_surface_.damage.Union(damage); | 
|   81   for (size_t i = 0; i < available_surfaces_.size(); i++) |   83   for (size_t i = 0; i < available_surfaces_.size(); i++) | 
|   82     available_surfaces_[i].damage.Union(damage); |   84     available_surfaces_[i].damage.Union(damage); | 
|   83  |   85  | 
|   84   for (std::deque<AllocatedSurface>::iterator it = |   86   for (std::deque<AllocatedSurface>::iterator it = | 
|   85            in_flight_surfaces_.begin(); |   87            in_flight_surfaces_.begin(); | 
|   86        it != in_flight_surfaces_.end(); |   88        it != in_flight_surfaces_.end(); | 
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  235     gl->DeleteTextures(1, &texture); |  237     gl->DeleteTextures(1, &texture); | 
|  236     return AllocatedSurface(); |  238     return AllocatedSurface(); | 
|  237   } |  239   } | 
|  238   allocated_count_++; |  240   allocated_count_++; | 
|  239   gl->BindTexture(GL_TEXTURE_2D, texture); |  241   gl->BindTexture(GL_TEXTURE_2D, texture); | 
|  240   gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); |  242   gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); | 
|  241   return AllocatedSurface(texture, id, gfx::Rect(size_)); |  243   return AllocatedSurface(texture, id, gfx::Rect(size_)); | 
|  242 } |  244 } | 
|  243  |  245  | 
|  244 }  // namespace content |  246 }  // namespace content | 
| OLD | NEW |