| OLD | NEW |
| 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 #include "mojo/skia/ganesh_context.h" | 5 #include "mojo/skia/ganesh_context.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_lib.h" | 7 #include "gpu/command_buffer/client/gles2_lib.h" |
| 8 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 8 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
| 9 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 9 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 DCHECK(interface); | 39 DCHECK(interface); |
| 40 | 40 |
| 41 context_ = skia::AdoptRef(GrContext::Create( | 41 context_ = skia::AdoptRef(GrContext::Create( |
| 42 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); | 42 kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); |
| 43 DCHECK(context_); | 43 DCHECK(context_); |
| 44 context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, | 44 context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, |
| 45 kMaxGaneshResourceCacheBytes); | 45 kMaxGaneshResourceCacheBytes); |
| 46 } | 46 } |
| 47 | 47 |
| 48 GaneshContext::~GaneshContext() { | 48 GaneshContext::~GaneshContext() { |
| 49 if (context_) { |
| 50 Scope scope(this); |
| 51 context_.clear(); |
| 52 } |
| 49 if (gl_context_.get()) | 53 if (gl_context_.get()) |
| 50 gl_context_->RemoveObserver(this); | 54 gl_context_->RemoveObserver(this); |
| 51 } | 55 } |
| 52 | 56 |
| 53 bool GaneshContext::InScope() const { | 57 bool GaneshContext::InScope() const { |
| 54 return gles2::GetGLContext() == gl_context_->gl(); | 58 return gles2::GetGLContext() == gl_context_->gl(); |
| 55 } | 59 } |
| 56 | 60 |
| 57 void GaneshContext::OnContextLost() { | 61 void GaneshContext::OnContextLost() { |
| 58 context_->abandonContext(); | 62 context_->abandonContext(); |
| 59 context_.clear(); | 63 context_.clear(); |
| 60 gl_context_.reset(); | 64 gl_context_.reset(); |
| 61 } | 65 } |
| 62 | 66 |
| 63 } // namespace mojo | 67 } // namespace mojo |
| OLD | NEW |