| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "skia/ext/texture_handle.h" | 34 #include "skia/ext/texture_handle.h" |
| 35 #include "third_party/khronos/GLES2/gl2.h" | 35 #include "third_party/khronos/GLES2/gl2.h" |
| 36 #include "third_party/khronos/GLES2/gl2ext.h" | 36 #include "third_party/khronos/GLES2/gl2ext.h" |
| 37 #include "third_party/skia/include/core/SkCanvas.h" | 37 #include "third_party/skia/include/core/SkCanvas.h" |
| 38 #include "third_party/skia/include/core/SkSurface.h" | 38 #include "third_party/skia/include/core/SkSurface.h" |
| 39 #include "third_party/skia/include/gpu/GrContext.h" | 39 #include "third_party/skia/include/gpu/GrContext.h" |
| 40 #include "third_party/skia/include/gpu/GrTextureProvider.h" | 40 #include "third_party/skia/include/gpu/GrTextureProvider.h" |
| 41 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 41 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 42 #include "ui/gfx/geometry/rect.h" | 42 #include "ui/gfx/geometry/rect.h" |
| 43 #include "ui/gfx/geometry/vector2d.h" | 43 #include "ui/gfx/geometry/vector2d.h" |
| 44 #include "ui/gfx/icc_profile.h" |
| 44 #include "ui/gl/trace_util.h" | 45 #include "ui/gl/trace_util.h" |
| 45 | 46 |
| 46 using gpu::gles2::GLES2Interface; | 47 using gpu::gles2::GLES2Interface; |
| 47 | 48 |
| 48 namespace cc { | 49 namespace cc { |
| 49 | 50 |
| 50 class IdAllocator { | 51 class IdAllocator { |
| 51 public: | 52 public: |
| 52 virtual ~IdAllocator() {} | 53 virtual ~IdAllocator() {} |
| 53 | 54 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 385 |
| 385 ResourceProvider::ResourceProvider( | 386 ResourceProvider::ResourceProvider( |
| 386 ContextProvider* compositor_context_provider, | 387 ContextProvider* compositor_context_provider, |
| 387 SharedBitmapManager* shared_bitmap_manager, | 388 SharedBitmapManager* shared_bitmap_manager, |
| 388 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 389 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 389 BlockingTaskRunner* blocking_main_thread_task_runner, | 390 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 390 int highp_threshold_min, | 391 int highp_threshold_min, |
| 391 size_t id_allocation_chunk_size, | 392 size_t id_allocation_chunk_size, |
| 392 bool delegated_sync_points_required, | 393 bool delegated_sync_points_required, |
| 393 bool use_gpu_memory_buffer_resources, | 394 bool use_gpu_memory_buffer_resources, |
| 395 bool enable_color_correct_rendering, |
| 394 const BufferToTextureTargetMap& buffer_to_texture_target_map) | 396 const BufferToTextureTargetMap& buffer_to_texture_target_map) |
| 395 : compositor_context_provider_(compositor_context_provider), | 397 : compositor_context_provider_(compositor_context_provider), |
| 396 shared_bitmap_manager_(shared_bitmap_manager), | 398 shared_bitmap_manager_(shared_bitmap_manager), |
| 397 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 399 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 398 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 400 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
| 399 lost_output_surface_(false), | 401 lost_output_surface_(false), |
| 400 highp_threshold_min_(highp_threshold_min), | 402 highp_threshold_min_(highp_threshold_min), |
| 401 next_id_(1), | 403 next_id_(1), |
| 402 next_child_(1), | 404 next_child_(1), |
| 403 delegated_sync_points_required_(delegated_sync_points_required), | 405 delegated_sync_points_required_(delegated_sync_points_required), |
| 404 default_resource_type_(use_gpu_memory_buffer_resources | 406 default_resource_type_(use_gpu_memory_buffer_resources |
| 405 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER | 407 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER |
| 406 : RESOURCE_TYPE_GL_TEXTURE), | 408 : RESOURCE_TYPE_GL_TEXTURE), |
| 407 use_texture_storage_ext_(false), | 409 use_texture_storage_ext_(false), |
| 408 use_texture_format_bgra_(false), | 410 use_texture_format_bgra_(false), |
| 409 use_texture_usage_hint_(false), | 411 use_texture_usage_hint_(false), |
| 410 use_compressed_texture_etc1_(false), | 412 use_compressed_texture_etc1_(false), |
| 411 yuv_resource_format_(LUMINANCE_8), | 413 yuv_resource_format_(LUMINANCE_8), |
| 412 max_texture_size_(0), | 414 max_texture_size_(0), |
| 413 best_texture_format_(RGBA_8888), | 415 best_texture_format_(RGBA_8888), |
| 414 best_render_buffer_format_(RGBA_8888), | 416 best_render_buffer_format_(RGBA_8888), |
| 417 enable_color_correct_rendering_(enable_color_correct_rendering), |
| 415 id_allocation_chunk_size_(id_allocation_chunk_size), | 418 id_allocation_chunk_size_(id_allocation_chunk_size), |
| 416 use_sync_query_(false), | 419 use_sync_query_(false), |
| 417 buffer_to_texture_target_map_(buffer_to_texture_target_map), | 420 buffer_to_texture_target_map_(buffer_to_texture_target_map), |
| 418 tracing_id_(g_next_resource_provider_tracing_id.GetNext()) { | 421 tracing_id_(g_next_resource_provider_tracing_id.GetNext()) { |
| 419 DCHECK(id_allocation_chunk_size_); | 422 DCHECK(id_allocation_chunk_size_); |
| 420 DCHECK(thread_checker_.CalledOnValidThread()); | 423 DCHECK(thread_checker_.CalledOnValidThread()); |
| 421 | 424 |
| 422 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 425 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
| 423 // Don't register a dump provider in these cases. | 426 // Don't register a dump provider in these cases. |
| 424 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 | 427 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 } | 816 } |
| 814 | 817 |
| 815 GLenum ResourceProvider::GetResourceTextureTarget(ResourceId id) { | 818 GLenum ResourceProvider::GetResourceTextureTarget(ResourceId id) { |
| 816 return GetResource(id)->target; | 819 return GetResource(id)->target; |
| 817 } | 820 } |
| 818 | 821 |
| 819 ResourceProvider::TextureHint ResourceProvider::GetTextureHint(ResourceId id) { | 822 ResourceProvider::TextureHint ResourceProvider::GetTextureHint(ResourceId id) { |
| 820 return GetResource(id)->hint; | 823 return GetResource(id)->hint; |
| 821 } | 824 } |
| 822 | 825 |
| 823 static sk_sp<SkColorSpace> ColorSpaceToSkColorSpace( | 826 sk_sp<SkColorSpace> ResourceProvider::ColorSpaceToSkColorSpace( |
| 824 const gfx::ColorSpace& color_space) { | 827 const gfx::ColorSpace& color_space) { |
| 825 // TODO(crbug.com/634102): Implement conversion for skia-based compositing to | 828 // TODO(crbug.com/634102): Implement conversion for skia-based compositing to |
| 826 // be color-managed | 829 // be color-managed |
| 827 return nullptr; | 830 return nullptr; |
| 828 } | 831 } |
| 829 | 832 |
| 830 void ResourceProvider::CopyToResource(ResourceId id, | 833 void ResourceProvider::CopyToResource(ResourceId id, |
| 831 const uint8_t* image, | 834 const uint8_t* image, |
| 832 const gfx::Size& image_size) { | 835 const gfx::Size& image_size) { |
| 833 Resource* resource = GetResource(id); | 836 Resource* resource = GetResource(id); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 resource_provider_->BindImageForSampling(resource); | 1093 resource_provider_->BindImageForSampling(resource); |
| 1091 if (create_mailbox) { | 1094 if (create_mailbox) { |
| 1092 resource_provider_->CreateMailboxAndBindResource( | 1095 resource_provider_->CreateMailboxAndBindResource( |
| 1093 resource_provider_->ContextGL(), resource); | 1096 resource_provider_->ContextGL(), resource); |
| 1094 } | 1097 } |
| 1095 texture_id_ = resource->gl_id; | 1098 texture_id_ = resource->gl_id; |
| 1096 target_ = resource->target; | 1099 target_ = resource->target; |
| 1097 format_ = resource->format; | 1100 format_ = resource->format; |
| 1098 size_ = resource->size; | 1101 size_ = resource->size; |
| 1099 mailbox_ = resource->mailbox(); | 1102 mailbox_ = resource->mailbox(); |
| 1103 sk_color_space_ = |
| 1104 resource_provider->ColorSpaceToSkColorSpace(resource->color_space); |
| 1100 } | 1105 } |
| 1101 | 1106 |
| 1102 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() { | 1107 ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() { |
| 1103 DCHECK(thread_checker_.CalledOnValidThread()); | 1108 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1104 Resource* resource = resource_provider_->GetResource(resource_id_); | 1109 Resource* resource = resource_provider_->GetResource(resource_id_); |
| 1105 DCHECK(resource->locked_for_write); | 1110 DCHECK(resource->locked_for_write); |
| 1106 if (sync_token_.HasData()) | 1111 if (sync_token_.HasData()) |
| 1107 resource->UpdateSyncToken(sync_token_); | 1112 resource->UpdateSyncToken(sync_token_); |
| 1108 if (synchronized_) | 1113 if (synchronized_) |
| 1109 resource->SetSynchronized(); | 1114 resource->SetSynchronized(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 uint32_t flags = | 1159 uint32_t flags = |
| 1155 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; | 1160 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; |
| 1156 // Use unknown pixel geometry to disable LCD text. | 1161 // Use unknown pixel geometry to disable LCD text. |
| 1157 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); | 1162 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); |
| 1158 if (can_use_lcd_text) { | 1163 if (can_use_lcd_text) { |
| 1159 // LegacyFontHost will get LCD text and skia figures out what type to use. | 1164 // LegacyFontHost will get LCD text and skia figures out what type to use. |
| 1160 surface_props = | 1165 surface_props = |
| 1161 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); | 1166 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
| 1162 } | 1167 } |
| 1163 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( | 1168 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( |
| 1164 context_provider->GrContext(), desc, &surface_props); | 1169 context_provider->GrContext(), desc, resource_lock->sk_color_space(), |
| 1170 &surface_props); |
| 1165 } | 1171 } |
| 1166 | 1172 |
| 1167 ResourceProvider::ScopedSkSurfaceProvider::~ScopedSkSurfaceProvider() { | 1173 ResourceProvider::ScopedSkSurfaceProvider::~ScopedSkSurfaceProvider() { |
| 1168 if (sk_surface_.get()) { | 1174 if (sk_surface_.get()) { |
| 1169 sk_surface_->prepareForExternalIO(); | 1175 sk_surface_->prepareForExternalIO(); |
| 1170 sk_surface_.reset(); | 1176 sk_surface_.reset(); |
| 1171 } | 1177 } |
| 1172 } | 1178 } |
| 1173 | 1179 |
| 1174 void ResourceProvider::PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 1180 void ResourceProvider::PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
| 1175 const Resource* resource) { | 1181 const Resource* resource) { |
| 1176 DCHECK_EQ(RGBA_8888, resource->format); | 1182 DCHECK_EQ(RGBA_8888, resource->format); |
| 1177 SkImageInfo info = SkImageInfo::MakeN32Premul( | 1183 SkImageInfo info = SkImageInfo::MakeN32Premul( |
| 1178 resource->size.width(), resource->size.height(), | 1184 resource->size.width(), resource->size.height(), |
| 1179 ColorSpaceToSkColorSpace(resource->color_space)); | 1185 ColorSpaceToSkColorSpace(resource->color_space)); |
| 1180 sk_bitmap->installPixels(info, resource->pixels, info.minRowBytes()); | 1186 sk_bitmap->installPixels(info, resource->pixels, info.minRowBytes()); |
| 1181 } | 1187 } |
| 1182 | 1188 |
| 1183 ResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware( | 1189 ResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware( |
| 1184 ResourceProvider* resource_provider, | 1190 ResourceProvider* resource_provider, |
| 1185 ResourceId resource_id) | 1191 ResourceId resource_id) |
| 1186 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1192 : resource_provider_(resource_provider), resource_id_(resource_id) { |
| 1187 const Resource* resource = resource_provider->LockForRead(resource_id); | 1193 const Resource* resource = resource_provider->LockForRead(resource_id); |
| 1188 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource); | 1194 resource_provider->PopulateSkBitmapWithResource(&sk_bitmap_, resource); |
| 1189 } | 1195 } |
| 1190 | 1196 |
| 1191 ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware() { | 1197 ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware() { |
| 1192 resource_provider_->UnlockForRead(resource_id_); | 1198 resource_provider_->UnlockForRead(resource_id_); |
| 1193 } | 1199 } |
| 1194 | 1200 |
| 1195 ResourceProvider::ScopedReadLockSkImage::ScopedReadLockSkImage( | 1201 ResourceProvider::ScopedReadLockSkImage::ScopedReadLockSkImage( |
| 1196 ResourceProvider* resource_provider, | 1202 ResourceProvider* resource_provider, |
| 1197 ResourceId resource_id) | 1203 ResourceId resource_id) |
| 1198 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1204 : resource_provider_(resource_provider), resource_id_(resource_id) { |
| 1199 const Resource* resource = resource_provider->LockForRead(resource_id); | 1205 const Resource* resource = resource_provider->LockForRead(resource_id); |
| 1200 if (resource->gl_id) { | 1206 if (resource->gl_id) { |
| 1201 GrGLTextureInfo texture_info; | 1207 GrGLTextureInfo texture_info; |
| 1202 texture_info.fID = resource->gl_id; | 1208 texture_info.fID = resource->gl_id; |
| 1203 texture_info.fTarget = resource->target; | 1209 texture_info.fTarget = resource->target; |
| 1204 GrBackendTextureDesc desc; | 1210 GrBackendTextureDesc desc; |
| 1205 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 1211 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 1206 desc.fWidth = resource->size.width(); | 1212 desc.fWidth = resource->size.width(); |
| 1207 desc.fHeight = resource->size.height(); | 1213 desc.fHeight = resource->size.height(); |
| 1208 desc.fConfig = ToGrPixelConfig(resource->format); | 1214 desc.fConfig = ToGrPixelConfig(resource->format); |
| 1209 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 1215 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 1210 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); | 1216 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); |
| 1211 sk_image_ = SkImage::MakeFromTexture( | 1217 sk_image_ = SkImage::MakeFromTexture( |
| 1212 resource_provider->compositor_context_provider_->GrContext(), desc, | 1218 resource_provider->compositor_context_provider_->GrContext(), desc, |
| 1213 kPremul_SkAlphaType, ColorSpaceToSkColorSpace(resource->color_space), | 1219 kPremul_SkAlphaType, |
| 1220 resource_provider->ColorSpaceToSkColorSpace(resource->color_space), |
| 1214 nullptr, nullptr); | 1221 nullptr, nullptr); |
| 1215 } else if (resource->pixels) { | 1222 } else if (resource->pixels) { |
| 1216 SkBitmap sk_bitmap; | 1223 SkBitmap sk_bitmap; |
| 1217 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap, resource); | 1224 resource_provider->PopulateSkBitmapWithResource(&sk_bitmap, resource); |
| 1218 sk_bitmap.setImmutable(); | 1225 sk_bitmap.setImmutable(); |
| 1219 sk_image_ = SkImage::MakeFromBitmap(sk_bitmap); | 1226 sk_image_ = SkImage::MakeFromBitmap(sk_bitmap); |
| 1220 } else { | 1227 } else { |
| 1221 // During render process shutdown, ~RenderMessageFilter which calls | 1228 // During render process shutdown, ~RenderMessageFilter which calls |
| 1222 // ~HostSharedBitmapClient (which deletes shared bitmaps from child) | 1229 // ~HostSharedBitmapClient (which deletes shared bitmaps from child) |
| 1223 // can race with OnBeginFrameDeadline which draws a frame. | 1230 // can race with OnBeginFrameDeadline which draws a frame. |
| 1224 // In these cases, shared bitmaps (and this read lock) won't be valid. | 1231 // In these cases, shared bitmaps (and this read lock) won't be valid. |
| 1225 // Renderers need to silently handle locks failing until this race | 1232 // Renderers need to silently handle locks failing until this race |
| 1226 // is fixed. DCHECK that this is the only case where there are no pixels. | 1233 // is fixed. DCHECK that this is the only case where there are no pixels. |
| 1227 DCHECK(!resource->shared_bitmap_id.IsZero()); | 1234 DCHECK(!resource->shared_bitmap_id.IsZero()); |
| 1228 } | 1235 } |
| 1229 } | 1236 } |
| 1230 | 1237 |
| 1231 ResourceProvider::ScopedReadLockSkImage::~ScopedReadLockSkImage() { | 1238 ResourceProvider::ScopedReadLockSkImage::~ScopedReadLockSkImage() { |
| 1232 resource_provider_->UnlockForRead(resource_id_); | 1239 resource_provider_->UnlockForRead(resource_id_); |
| 1233 } | 1240 } |
| 1234 | 1241 |
| 1235 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware( | 1242 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware( |
| 1236 ResourceProvider* resource_provider, | 1243 ResourceProvider* resource_provider, |
| 1237 ResourceId resource_id) | 1244 ResourceId resource_id) |
| 1238 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1245 : resource_provider_(resource_provider), resource_id_(resource_id) { |
| 1239 ResourceProvider::PopulateSkBitmapWithResource( | 1246 resource_provider->PopulateSkBitmapWithResource( |
| 1240 &sk_bitmap_, resource_provider->LockForWrite(resource_id)); | 1247 &sk_bitmap_, resource_provider->LockForWrite(resource_id)); |
| 1241 DCHECK(valid()); | 1248 DCHECK(valid()); |
| 1242 } | 1249 } |
| 1243 | 1250 |
| 1244 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { | 1251 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { |
| 1245 DCHECK(thread_checker_.CalledOnValidThread()); | 1252 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1246 Resource* resource = resource_provider_->GetResource(resource_id_); | 1253 Resource* resource = resource_provider_->GetResource(resource_id_); |
| 1247 DCHECK(resource); | 1254 DCHECK(resource); |
| 1248 resource->SetSynchronized(); | 1255 resource->SetSynchronized(); |
| 1249 resource_provider_->UnlockForWrite(resource); | 1256 resource_provider_->UnlockForWrite(resource); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1261 gpu_memory_buffer_ = std::move(resource->gpu_memory_buffer); | 1268 gpu_memory_buffer_ = std::move(resource->gpu_memory_buffer); |
| 1262 resource->gpu_memory_buffer = nullptr; | 1269 resource->gpu_memory_buffer = nullptr; |
| 1263 } | 1270 } |
| 1264 | 1271 |
| 1265 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: | 1272 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: |
| 1266 ~ScopedWriteLockGpuMemoryBuffer() { | 1273 ~ScopedWriteLockGpuMemoryBuffer() { |
| 1267 DCHECK(thread_checker_.CalledOnValidThread()); | 1274 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1268 Resource* resource = resource_provider_->GetResource(resource_id_); | 1275 Resource* resource = resource_provider_->GetResource(resource_id_); |
| 1269 DCHECK(resource); | 1276 DCHECK(resource); |
| 1270 if (gpu_memory_buffer_) { | 1277 if (gpu_memory_buffer_) { |
| 1278 if (resource_provider_->enable_color_correct_rendering_) |
| 1279 gpu_memory_buffer_->SetColorSpaceForScanout(resource->color_space); |
| 1271 DCHECK(!resource->gpu_memory_buffer); | 1280 DCHECK(!resource->gpu_memory_buffer); |
| 1272 resource_provider_->LazyCreate(resource); | 1281 resource_provider_->LazyCreate(resource); |
| 1273 resource->gpu_memory_buffer = std::move(gpu_memory_buffer_); | 1282 resource->gpu_memory_buffer = std::move(gpu_memory_buffer_); |
| 1274 resource->allocated = true; | 1283 resource->allocated = true; |
| 1275 resource_provider_->LazyCreateImage(resource); | 1284 resource_provider_->LazyCreateImage(resource); |
| 1276 resource->dirty_image = true; | 1285 resource->dirty_image = true; |
| 1277 resource->is_overlay_candidate = true; | 1286 resource->is_overlay_candidate = true; |
| 1278 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 1287 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
| 1279 // Read lock fences are required to ensure that we're not trying to map a | 1288 // Read lock fences are required to ensure that we're not trying to map a |
| 1280 // buffer that is currently in-use by the GPU. | 1289 // buffer that is currently in-use by the GPU. |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 resource->allocated = true; | 1851 resource->allocated = true; |
| 1843 GLES2Interface* gl = ContextGL(); | 1852 GLES2Interface* gl = ContextGL(); |
| 1844 gfx::Size& size = resource->size; | 1853 gfx::Size& size = resource->size; |
| 1845 ResourceFormat format = resource->format; | 1854 ResourceFormat format = resource->format; |
| 1846 gl->BindTexture(resource->target, resource->gl_id); | 1855 gl->BindTexture(resource->target, resource->gl_id); |
| 1847 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) { | 1856 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) { |
| 1848 resource->gpu_memory_buffer = | 1857 resource->gpu_memory_buffer = |
| 1849 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 1858 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
| 1850 size, BufferFormat(format), resource->usage, | 1859 size, BufferFormat(format), resource->usage, |
| 1851 gpu::kNullSurfaceHandle); | 1860 gpu::kNullSurfaceHandle); |
| 1861 if (resource->gpu_memory_buffer && enable_color_correct_rendering_) { |
| 1862 resource->gpu_memory_buffer->SetColorSpaceForScanout( |
| 1863 resource->color_space); |
| 1864 } |
| 1865 |
| 1852 LazyCreateImage(resource); | 1866 LazyCreateImage(resource); |
| 1853 resource->dirty_image = true; | 1867 resource->dirty_image = true; |
| 1854 resource->is_overlay_candidate = true; | 1868 resource->is_overlay_candidate = true; |
| 1855 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 1869 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
| 1856 // Read lock fences are required to ensure that we're not trying to map a | 1870 // Read lock fences are required to ensure that we're not trying to map a |
| 1857 // buffer that is currently in-use by the GPU. | 1871 // buffer that is currently in-use by the GPU. |
| 1858 resource->read_lock_fences_enabled = true; | 1872 resource->read_lock_fences_enabled = true; |
| 1859 } else if (use_texture_storage_ext_ && | 1873 } else if (use_texture_storage_ext_ && |
| 1860 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && | 1874 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && |
| 1861 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { | 1875 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 | 2041 |
| 2028 const int kImportance = 2; | 2042 const int kImportance = 2; |
| 2029 pmd->CreateSharedGlobalAllocatorDump(guid); | 2043 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 2030 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2044 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 2031 } | 2045 } |
| 2032 | 2046 |
| 2033 return true; | 2047 return true; |
| 2034 } | 2048 } |
| 2035 | 2049 |
| 2036 } // namespace cc | 2050 } // namespace cc |
| OLD | NEW |