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

Side by Side Diff: cc/test/test_in_process_context_provider.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/test/test_in_process_context_provider.h ('k') | cc/test/test_web_graphics_context_3d.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/test/test_in_process_context_provider.h" 5 #include "cc/test/test_in_process_context_provider.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "gpu/GLES2/gl2extchromium.h" 8 #include "gpu/GLES2/gl2extchromium.h"
9 #include "gpu/command_buffer/client/gl_in_process_context.h" 9 #include "gpu/command_buffer/client/gl_in_process_context.h"
10 #include "gpu/command_buffer/client/gles2_implementation.h" 10 #include "gpu/command_buffer/client/gles2_implementation.h"
11 #include "gpu/command_buffer/client/gles2_lib.h" 11 #include "gpu/command_buffer/client/gles2_lib.h"
12 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 12 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
13 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" 13 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
14 #include "third_party/khronos/GLES2/gl2.h" 14 #include "third_party/khronos/GLES2/gl2.h"
15 #include "third_party/khronos/GLES2/gl2ext.h" 15 #include "third_party/khronos/GLES2/gl2ext.h"
16 #include "third_party/skia/include/gpu/GrContext.h" 16 #include "third_party/skia/include/gpu/GrContext.h"
17 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 17 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
18 #include "ui/gfx/native_widget_types.h" 18 #include "ui/gfx/native_widget_types.h"
19 19
20 namespace cc { 20 namespace cc {
21 21
22 // static 22 // static
23 scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() { 23 scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext(
24 TestGpuMemoryBufferManager* gpu_memory_buffer_manager,
25 TestImageFactory* image_factory) {
24 const bool is_offscreen = true; 26 const bool is_offscreen = true;
25 const bool share_resources = true; 27 const bool share_resources = true;
26 gpu::gles2::ContextCreationAttribHelper attribs; 28 gpu::gles2::ContextCreationAttribHelper attribs;
27 attribs.alpha_size = 8; 29 attribs.alpha_size = 8;
28 attribs.blue_size = 8; 30 attribs.blue_size = 8;
29 attribs.green_size = 8; 31 attribs.green_size = 8;
30 attribs.red_size = 8; 32 attribs.red_size = 8;
31 attribs.depth_size = 24; 33 attribs.depth_size = 24;
32 attribs.stencil_size = 8; 34 attribs.stencil_size = 8;
33 attribs.samples = 0; 35 attribs.samples = 0;
34 attribs.sample_buffers = 0; 36 attribs.sample_buffers = 0;
35 attribs.fail_if_major_perf_caveat = false; 37 attribs.fail_if_major_perf_caveat = false;
36 attribs.bind_generates_resource = false; 38 attribs.bind_generates_resource = false;
37 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 39 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
38 40
39 scoped_ptr<gpu::GLInProcessContext> context = 41 scoped_ptr<gpu::GLInProcessContext> context =
40 make_scoped_ptr(gpu::GLInProcessContext::Create( 42 make_scoped_ptr(gpu::GLInProcessContext::Create(
41 NULL, 43 NULL,
42 NULL, 44 NULL,
43 is_offscreen, 45 is_offscreen,
44 gfx::kNullAcceleratedWidget, 46 gfx::kNullAcceleratedWidget,
45 gfx::Size(1, 1), 47 gfx::Size(1, 1),
46 NULL, 48 NULL,
47 share_resources, 49 share_resources,
48 attribs, 50 attribs,
49 gpu_preference, 51 gpu_preference,
50 gpu::GLInProcessContextSharedMemoryLimits())); 52 gpu::GLInProcessContextSharedMemoryLimits(),
53 gpu_memory_buffer_manager,
54 image_factory));
51 55
52 DCHECK(context); 56 DCHECK(context);
53 return context.Pass(); 57 return context.Pass();
54 } 58 }
55 59
60 scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() {
61 return CreateTestInProcessContext(nullptr, nullptr);
62 }
63
56 TestInProcessContextProvider::TestInProcessContextProvider() 64 TestInProcessContextProvider::TestInProcessContextProvider()
57 : context_(CreateTestInProcessContext()) {} 65 : context_(CreateTestInProcessContext(&gpu_memory_buffer_manager_,
66 &image_factory_)) {
67 }
58 68
59 TestInProcessContextProvider::~TestInProcessContextProvider() { 69 TestInProcessContextProvider::~TestInProcessContextProvider() {
60 } 70 }
61 71
62 bool TestInProcessContextProvider::BindToCurrentThread() { return true; } 72 bool TestInProcessContextProvider::BindToCurrentThread() { return true; }
63 73
64 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() { 74 gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() {
65 return context_->GetImplementation(); 75 return context_->GetImplementation();
66 } 76 }
67 77
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this); 119 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
110 120
111 gr_context_ = skia::AdoptRef(GrContext::Create( 121 gr_context_ = skia::AdoptRef(GrContext::Create(
112 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); 122 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get())));
113 123
114 return gr_context_.get(); 124 return gr_context_.get();
115 } 125 }
116 126
117 ContextProvider::Capabilities 127 ContextProvider::Capabilities
118 TestInProcessContextProvider::ContextCapabilities() { 128 TestInProcessContextProvider::ContextCapabilities() {
119 return ContextProvider::Capabilities(); 129 ContextProvider::Capabilities capabilities;
130 capabilities.gpu.image = true;
131 capabilities.gpu.texture_rectangle = true;
132
133 return capabilities;
120 } 134 }
121 135
122 bool TestInProcessContextProvider::IsContextLost() { return false; } 136 bool TestInProcessContextProvider::IsContextLost() { return false; }
123 137
124 void TestInProcessContextProvider::VerifyContexts() {} 138 void TestInProcessContextProvider::VerifyContexts() {}
125 139
126 void TestInProcessContextProvider::DeleteCachedResources() { 140 void TestInProcessContextProvider::DeleteCachedResources() {
127 if (gr_context_) 141 if (gr_context_)
128 gr_context_->freeGpuResources(); 142 gr_context_->freeGpuResources();
129 } 143 }
130 144
131 bool TestInProcessContextProvider::DestroyedOnMainThread() { return false; } 145 bool TestInProcessContextProvider::DestroyedOnMainThread() { return false; }
132 146
133 void TestInProcessContextProvider::SetLostContextCallback( 147 void TestInProcessContextProvider::SetLostContextCallback(
134 const LostContextCallback& lost_context_callback) {} 148 const LostContextCallback& lost_context_callback) {}
135 149
136 void TestInProcessContextProvider::SetMemoryPolicyChangedCallback( 150 void TestInProcessContextProvider::SetMemoryPolicyChangedCallback(
137 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {} 151 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {}
138 152
139 } // namespace cc 153 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_in_process_context_provider.h ('k') | cc/test/test_web_graphics_context_3d.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698