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

Side by Side Diff: mojo/skia/ganesh_context.h

Issue 2011713003: Roll skia to 8cc209111876b7c78b5ec577c9221d8ed5e21024 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 6 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 | « examples/ui/png_viewer/png_viewer.cc ('k') | mojo/skia/ganesh_context.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MOJO_SKIA_GANESH_CONTEXT_H_ 5 #ifndef MOJO_SKIA_GANESH_CONTEXT_H_
6 #define MOJO_SKIA_GANESH_CONTEXT_H_ 6 #define MOJO_SKIA_GANESH_CONTEXT_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "mojo/gpu/gl_context.h" 10 #include "mojo/gpu/gl_context.h"
11 #include "skia/ext/refptr.h" 11 #include "third_party/skia/include/core/SkRefCnt.h"
12 #include "third_party/skia/include/gpu/GrContext.h" 12 #include "third_party/skia/include/gpu/GrContext.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace skia { 15 namespace skia {
16 16
17 // Binds a Ganesh rendering context to a GL context. 17 // Binds a Ganesh rendering context to a GL context.
18 // 18 //
19 // Instances of this object is not thread-safe and must be used on the 19 // Instances of this object is not thread-safe and must be used on the
20 // same thread as the GL context was created on. 20 // same thread as the GL context was created on.
21 class GaneshContext : public base::RefCounted<GaneshContext>, 21 class GaneshContext : public base::RefCounted<GaneshContext>,
(...skipping 19 matching lines...) Expand all
41 // Upon exit from the scope, flushes the Ganesh context state and 41 // Upon exit from the scope, flushes the Ganesh context state and
42 // reactivates the prior GL context. 42 // reactivates the prior GL context.
43 ~Scope(); 43 ~Scope();
44 44
45 // Gets the underlying Ganesh context, never null. 45 // Gets the underlying Ganesh context, never null.
46 const scoped_refptr<GaneshContext>& ganesh_context() const { 46 const scoped_refptr<GaneshContext>& ganesh_context() const {
47 return ganesh_context_; 47 return ganesh_context_;
48 } 48 }
49 49
50 // Gets the underlying Ganesh rendering context, never null. 50 // Gets the underlying Ganesh rendering context, never null.
51 const ::skia::RefPtr<GrContext>& gr_context() const { 51 const sk_sp<GrContext>& gr_context() const {
52 return ganesh_context_->gr_context_; 52 return ganesh_context_->gr_context_;
53 } 53 }
54 54
55 // Gets the underlying GL context scope. 55 // Gets the underlying GL context scope.
56 // 56 //
57 // Be careful when manipulating the GL context from within a Ganesh 57 // Be careful when manipulating the GL context from within a Ganesh
58 // scope since the Ganesh renderer caches GL state. Queries are safe 58 // scope since the Ganesh renderer caches GL state. Queries are safe
59 // but operations which modify the state of the GL context, such as binding 59 // but operations which modify the state of the GL context, such as binding
60 // textures, should be followed by a call to |GrContext::resetContext| 60 // textures, should be followed by a call to |GrContext::resetContext|
61 // before performing other Ganesh related actions within the scope. 61 // before performing other Ganesh related actions within the scope.
(...skipping 15 matching lines...) Expand all
77 // Returns true if the GL context was lost. 77 // Returns true if the GL context was lost.
78 bool is_lost() const { return gl_context_->is_lost(); } 78 bool is_lost() const { return gl_context_->is_lost(); }
79 79
80 private: 80 private:
81 friend class base::RefCounted<GaneshContext>; 81 friend class base::RefCounted<GaneshContext>;
82 82
83 ~GaneshContext() override; 83 ~GaneshContext() override;
84 void OnContextLost() override; 84 void OnContextLost() override;
85 85
86 const scoped_refptr<GLContext> gl_context_; 86 const scoped_refptr<GLContext> gl_context_;
87 ::skia::RefPtr<GrContext> gr_context_; 87 sk_sp<GrContext> gr_context_;
88 bool scope_entered_ = false; 88 bool scope_entered_ = false;
89 89
90 DISALLOW_COPY_AND_ASSIGN(GaneshContext); 90 DISALLOW_COPY_AND_ASSIGN(GaneshContext);
91 }; 91 };
92 92
93 } // namespace skia 93 } // namespace skia
94 } // namespace mojo 94 } // namespace mojo
95 95
96 #endif // MOJO_SKIA_GANESH_CONTEXT_H_ 96 #endif // MOJO_SKIA_GANESH_CONTEXT_H_
OLDNEW
« no previous file with comments | « examples/ui/png_viewer/png_viewer.cc ('k') | mojo/skia/ganesh_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698