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

Unified Diff: android_webview/browser/context_provider_in_process.cc

Issue 1083843002: android_webview: Remove dependency on webkit's ContextProviderInProcess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/browser/context_provider_in_process.h ('k') | android_webview/browser/hardware_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/context_provider_in_process.cc
diff --git a/webkit/common/gpu/context_provider_in_process.cc b/android_webview/browser/context_provider_in_process.cc
similarity index 85%
copy from webkit/common/gpu/context_provider_in_process.cc
copy to android_webview/browser/context_provider_in_process.cc
index 87b5df6297239a73083d1b8af17e1092ff1d787b..d90c7ca0a9b245acabf9d902338d65a41d4bc467 100644
--- a/webkit/common/gpu/context_provider_in_process.cc
+++ b/android_webview/browser/context_provider_in_process.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/common/gpu/context_provider_in_process.h"
+#include "android_webview/browser/context_provider_in_process.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
@@ -10,12 +10,12 @@
#include "cc/output/managed_memory_policy.h"
#include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
-#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
+#include "third_party/skia/include/gpu/GrContext.h"
+#include "third_party/skia/include/gpu/gl/SkNullGLContext.h"
using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl;
-namespace webkit {
-namespace gpu {
+namespace android_webview {
class ContextProviderInProcess::LostContextCallbackProxy
: public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
@@ -46,23 +46,6 @@ scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create(
return new ContextProviderInProcess(context3d.Pass(), debug_name);
}
-// static
-scoped_refptr<ContextProviderInProcess>
-ContextProviderInProcess::CreateOffscreen(
- bool lose_context_when_out_of_memory) {
- blink::WebGraphicsContext3D::Attributes attributes;
- attributes.depth = false;
- attributes.stencil = true;
- attributes.antialias = false;
- attributes.shareResources = true;
- attributes.noAutomaticFlushes = true;
-
- return Create(
- WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- attributes, lose_context_when_out_of_memory),
- "Offscreen");
-}
-
ContextProviderInProcess::ContextProviderInProcess(
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
const std::string& debug_name)
@@ -154,10 +137,19 @@ class GrContext* ContextProviderInProcess::GrContext() {
DCHECK(context_thread_checker_.CalledOnValidThread());
if (gr_context_)
- return gr_context_->get();
+ return gr_context_.get();
+
+ skia::RefPtr<class SkGLContext> gl_context =
tfarina 2015/04/13 22:52:28 I copied this from cc/test/test_context_provide.cc
boliu 2015/04/14 00:29:52 You are creating a *new* context for GrContext, bu
+ skia::AdoptRef(SkNullGLContext::Create(kNone_GrGLStandard));
+ gl_context->makeCurrent();
+ gr_context_ = skia::AdoptRef(GrContext::Create(
+ kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(gl_context->gl())));
- gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get()));
- return gr_context_->get();
+ // If GlContext is already lost, also abandon the new GrContext.
+ if (IsContextLost())
+ gr_context_->abandonContext();
+
+ return gr_context_.get();
}
void ContextProviderInProcess::SetupLock() {
@@ -184,10 +176,6 @@ void ContextProviderInProcess::VerifyContexts() {
}
void ContextProviderInProcess::DeleteCachedResources() {
- DCHECK(context_thread_checker_.CalledOnValidThread());
-
- if (gr_context_)
- gr_context_->FreeGpuResources();
}
void ContextProviderInProcess::OnLostContext() {
@@ -201,7 +189,7 @@ void ContextProviderInProcess::OnLostContext() {
if (!lost_context_callback_.is_null())
base::ResetAndReturn(&lost_context_callback_).Run();
if (gr_context_)
- gr_context_->OnLostContext();
+ gr_context_->abandonContext();
}
bool ContextProviderInProcess::DestroyedOnMainThread() {
@@ -224,5 +212,4 @@ void ContextProviderInProcess::SetMemoryPolicyChangedCallback(
// There's no memory manager for the in-process implementation.
}
-} // namespace gpu
-} // namespace webkit
+} // namespace android_webview
« no previous file with comments | « android_webview/browser/context_provider_in_process.h ('k') | android_webview/browser/hardware_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698