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

Side by Side Diff: ui/compositor/context_provider_from_context_factory.cc

Issue 21026005: aura: Remove CreateOffscreenContext from ui::ContextFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: offscreencontext: clang-format Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/compositor/context_provider_from_context_factory.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "context_provider_from_context_factory.h"
6
7 #include "base/logging.h"
8
9 namespace ui {
10
11 // static
12 scoped_refptr<ContextProviderFromContextFactory>
13 ContextProviderFromContextFactory::CreateForOffscreen(ContextFactory* factory) {
14 scoped_refptr<ContextProviderFromContextFactory> provider =
15 new ContextProviderFromContextFactory(factory);
16 if (!provider->InitializeOnMainThread())
17 return NULL;
18 return provider;
19 }
20
21 ContextProviderFromContextFactory::ContextProviderFromContextFactory(
22 ContextFactory* factory)
23 : factory_(factory),
24 destroyed_(false) {
25 }
26
27 ContextProviderFromContextFactory::~ContextProviderFromContextFactory() {
28 }
29
30 bool ContextProviderFromContextFactory::BindToCurrentThread() {
31 DCHECK(context3d_);
32 return context3d_->makeContextCurrent();
33 }
34
35 WebKit::WebGraphicsContext3D* ContextProviderFromContextFactory::Context3d() {
36 DCHECK(context3d_);
37 return context3d_.get();
38 }
39
40 class GrContext* ContextProviderFromContextFactory::GrContext() {
41 DCHECK(context3d_);
42
43 if (!gr_context_) {
44 gr_context_.reset(
45 new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get()));
46 }
47 return gr_context_->get();
48 }
49
50 void ContextProviderFromContextFactory::VerifyContexts() {
51 DCHECK(context3d_);
52
53 if (context3d_->isContextLost()) {
54 base::AutoLock lock(destroyed_lock_);
55 destroyed_ = true;
56 }
57 }
58
59 bool ContextProviderFromContextFactory::DestroyedOnMainThread() {
60 base::AutoLock lock(destroyed_lock_);
61 return destroyed_;
62 }
63
64 void ContextProviderFromContextFactory::SetLostContextCallback(
65 const LostContextCallback& cb) {
66 NOTIMPLEMENTED();
67 }
68
69 bool ContextProviderFromContextFactory::InitializeOnMainThread() {
70 if (context3d_)
71 return true;
72 context3d_ = factory_->CreateOffscreenContext();
73 return !!context3d_;
74 }
75
76 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/context_provider_from_context_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698