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

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

Issue 1829363003: Directly use GrGLInterface in cc tests rather than SkNullGLContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no auto for smart ptr Created 4 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp » ('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_context_provider.h" 5 #include "cc/test/test_context_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback_helpers.h" 14 #include "base/callback_helpers.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "cc/test/test_gles2_interface.h" 16 #include "cc/test/test_gles2_interface.h"
17 #include "cc/test/test_web_graphics_context_3d.h" 17 #include "cc/test/test_web_graphics_context_3d.h"
18 #include "third_party/skia/include/gpu/GrContext.h" 18 #include "third_party/skia/include/gpu/GrContext.h"
19 #include "third_party/skia/include/gpu/gl/SkNullGLContext.h" 19 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
20 20
21 namespace cc { 21 namespace cc {
22 22
23 // static 23 // static
24 scoped_refptr<TestContextProvider> TestContextProvider::Create() { 24 scoped_refptr<TestContextProvider> TestContextProvider::Create() {
25 return Create(TestWebGraphicsContext3D::Create()); 25 return Create(TestWebGraphicsContext3D::Create());
26 } 26 }
27 27
28 // static 28 // static
29 scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() { 29 scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return &support_; 105 return &support_;
106 } 106 }
107 107
108 class GrContext* TestContextProvider::GrContext() { 108 class GrContext* TestContextProvider::GrContext() {
109 DCHECK(bound_); 109 DCHECK(bound_);
110 DCHECK(context_thread_checker_.CalledOnValidThread()); 110 DCHECK(context_thread_checker_.CalledOnValidThread());
111 111
112 if (gr_context_) 112 if (gr_context_)
113 return gr_context_.get(); 113 return gr_context_.get();
114 114
115 scoped_ptr<class SkGLContext> gl_context(SkNullGLContext::Create()); 115 skia::RefPtr<const GrGLInterface> gl_interface =
116 gl_context->makeCurrent(); 116 skia::AdoptRef(GrGLCreateNullInterface());
117 gr_context_ = skia::AdoptRef(GrContext::Create( 117 gr_context_ = skia::AdoptRef(GrContext::Create(
118 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(gl_context->gl()))); 118 kOpenGL_GrBackend,
119 reinterpret_cast<GrBackendContext>(gl_interface.get())));
119 120
120 // If GlContext is already lost, also abandon the new GrContext. 121 // If GlContext is already lost, also abandon the new GrContext.
121 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) 122 if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
122 gr_context_->abandonContext(); 123 gr_context_->abandonContext();
123 124
124 return gr_context_.get(); 125 return gr_context_.get();
125 } 126 }
126 127
127 void TestContextProvider::InvalidateGrContext(uint32_t state) { 128 void TestContextProvider::InvalidateGrContext(uint32_t state) {
128 DCHECK(bound_); 129 DCHECK(bound_);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 DCHECK(lost_context_callback_.is_null() || cb.is_null()); 168 DCHECK(lost_context_callback_.is_null() || cb.is_null());
168 lost_context_callback_ = cb; 169 lost_context_callback_ = cb;
169 } 170 }
170 171
171 void TestContextProvider::SetMaxTransferBufferUsageBytes( 172 void TestContextProvider::SetMaxTransferBufferUsageBytes(
172 size_t max_transfer_buffer_usage_bytes) { 173 size_t max_transfer_buffer_usage_bytes) {
173 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes); 174 context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes);
174 } 175 }
175 176
176 } // namespace cc 177 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698