| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "cc/debug/lap_timer.h" | 12 #include "cc/debug/lap_timer.h" |
| 13 #include "cc/output/context_cache_controller.h" |
| 13 #include "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
| 14 #include "cc/raster/bitmap_raster_buffer_provider.h" | 15 #include "cc/raster/bitmap_raster_buffer_provider.h" |
| 15 #include "cc/raster/gpu_raster_buffer_provider.h" | 16 #include "cc/raster/gpu_raster_buffer_provider.h" |
| 16 #include "cc/raster/one_copy_raster_buffer_provider.h" | 17 #include "cc/raster/one_copy_raster_buffer_provider.h" |
| 17 #include "cc/raster/raster_buffer_provider.h" | 18 #include "cc/raster/raster_buffer_provider.h" |
| 18 #include "cc/raster/synchronous_task_graph_runner.h" | 19 #include "cc/raster/synchronous_task_graph_runner.h" |
| 19 #include "cc/raster/zero_copy_raster_buffer_provider.h" | 20 #include "cc/raster/zero_copy_raster_buffer_provider.h" |
| 20 #include "cc/resources/platform_color.h" | 21 #include "cc/resources/platform_color.h" |
| 21 #include "cc/resources/resource_pool.h" | 22 #include "cc/resources/resource_pool.h" |
| 22 #include "cc/resources/resource_provider.h" | 23 #include "cc/resources/resource_provider.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 GLbyte* sync_token) override { | 74 GLbyte* sync_token) override { |
| 74 // Copy the data over after setting the data to ensure alignment. | 75 // Copy the data over after setting the data to ensure alignment. |
| 75 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, | 76 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 76 gpu::CommandBufferId(), fence_sync); | 77 gpu::CommandBufferId(), fence_sync); |
| 77 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); | 78 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); |
| 78 } | 79 } |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 class PerfContextProvider : public ContextProvider { | 82 class PerfContextProvider : public ContextProvider { |
| 82 public: | 83 public: |
| 83 PerfContextProvider() : context_gl_(new PerfGLES2Interface) {} | 84 PerfContextProvider() |
| 85 : context_gl_(new PerfGLES2Interface), cache_controller_(&support_) {} |
| 84 | 86 |
| 85 bool BindToCurrentThread() override { return true; } | 87 bool BindToCurrentThread() override { return true; } |
| 86 gpu::Capabilities ContextCapabilities() override { | 88 gpu::Capabilities ContextCapabilities() override { |
| 87 gpu::Capabilities capabilities; | 89 gpu::Capabilities capabilities; |
| 88 capabilities.image = true; | 90 capabilities.image = true; |
| 89 capabilities.sync_query = true; | 91 capabilities.sync_query = true; |
| 90 return capabilities; | 92 return capabilities; |
| 91 } | 93 } |
| 92 gpu::gles2::GLES2Interface* ContextGL() override { return context_gl_.get(); } | 94 gpu::gles2::GLES2Interface* ContextGL() override { return context_gl_.get(); } |
| 93 gpu::ContextSupport* ContextSupport() override { return &support_; } | 95 gpu::ContextSupport* ContextSupport() override { return &support_; } |
| 94 class GrContext* GrContext() override { | 96 class GrContext* GrContext() override { |
| 95 if (gr_context_) | 97 if (gr_context_) |
| 96 return gr_context_.get(); | 98 return gr_context_.get(); |
| 97 | 99 |
| 98 sk_sp<const GrGLInterface> null_interface(GrGLCreateNullInterface()); | 100 sk_sp<const GrGLInterface> null_interface(GrGLCreateNullInterface()); |
| 99 gr_context_ = sk_sp<class GrContext>(GrContext::Create( | 101 gr_context_ = sk_sp<class GrContext>(GrContext::Create( |
| 100 kOpenGL_GrBackend, | 102 kOpenGL_GrBackend, |
| 101 reinterpret_cast<GrBackendContext>(null_interface.get()))); | 103 reinterpret_cast<GrBackendContext>(null_interface.get()))); |
| 104 cache_controller_.SetGrContext(gr_context_.get()); |
| 102 return gr_context_.get(); | 105 return gr_context_.get(); |
| 103 } | 106 } |
| 107 ContextCacheController* CacheController() override { |
| 108 return &cache_controller_; |
| 109 } |
| 104 void InvalidateGrContext(uint32_t state) override { | 110 void InvalidateGrContext(uint32_t state) override { |
| 105 if (gr_context_) | 111 if (gr_context_) |
| 106 gr_context_.get()->resetContext(state); | 112 gr_context_.get()->resetContext(state); |
| 107 } | 113 } |
| 108 base::Lock* GetLock() override { return &context_lock_; } | 114 base::Lock* GetLock() override { return &context_lock_; } |
| 109 void DeleteCachedResources() override {} | |
| 110 void SetLostContextCallback(const LostContextCallback& cb) override {} | 115 void SetLostContextCallback(const LostContextCallback& cb) override {} |
| 111 | 116 |
| 112 private: | 117 private: |
| 113 ~PerfContextProvider() override {} | 118 ~PerfContextProvider() override {} |
| 114 | 119 |
| 115 std::unique_ptr<PerfGLES2Interface> context_gl_; | 120 std::unique_ptr<PerfGLES2Interface> context_gl_; |
| 116 sk_sp<class GrContext> gr_context_; | 121 sk_sp<class GrContext> gr_context_; |
| 117 TestContextSupport support_; | 122 TestContextSupport support_; |
| 123 ContextCacheController cache_controller_; |
| 118 base::Lock context_lock_; | 124 base::Lock context_lock_; |
| 119 }; | 125 }; |
| 120 | 126 |
| 121 enum RasterBufferProviderType { | 127 enum RasterBufferProviderType { |
| 122 RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY, | 128 RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY, |
| 123 RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY, | 129 RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY, |
| 124 RASTER_BUFFER_PROVIDER_TYPE_GPU, | 130 RASTER_BUFFER_PROVIDER_TYPE_GPU, |
| 125 RASTER_BUFFER_PROVIDER_TYPE_BITMAP | 131 RASTER_BUFFER_PROVIDER_TYPE_BITMAP |
| 126 }; | 132 }; |
| 127 | 133 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 RunBuildTileTaskGraphTest("1_0", 1, 0); | 599 RunBuildTileTaskGraphTest("1_0", 1, 0); |
| 594 RunBuildTileTaskGraphTest("32_0", 32, 0); | 600 RunBuildTileTaskGraphTest("32_0", 32, 0); |
| 595 RunBuildTileTaskGraphTest("1_1", 1, 1); | 601 RunBuildTileTaskGraphTest("1_1", 1, 1); |
| 596 RunBuildTileTaskGraphTest("32_1", 32, 1); | 602 RunBuildTileTaskGraphTest("32_1", 32, 1); |
| 597 RunBuildTileTaskGraphTest("1_4", 1, 4); | 603 RunBuildTileTaskGraphTest("1_4", 1, 4); |
| 598 RunBuildTileTaskGraphTest("32_4", 32, 4); | 604 RunBuildTileTaskGraphTest("32_4", 32, 4); |
| 599 } | 605 } |
| 600 | 606 |
| 601 } // namespace | 607 } // namespace |
| 602 } // namespace cc | 608 } // namespace cc |
| OLD | NEW |