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

Unified Diff: cc/resources/scoped_gpu_raster.cc

Issue 375303002: cc: Refactor ResourceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed. Created 6 years, 5 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
Index: cc/resources/scoped_gpu_raster.cc
diff --git a/cc/resources/scoped_gpu_raster.cc b/cc/resources/scoped_gpu_raster.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4688304de8065a1eaaf88cf08c356fe7d05a0d5f
--- /dev/null
+++ b/cc/resources/scoped_gpu_raster.cc
@@ -0,0 +1,48 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
danakj 2014/07/11 17:39:59 2014
sohanjg 2014/07/12 11:08:26 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/resources/scoped_gpu_raster.h"
+#include "gpu/command_buffer/client/gles2_interface.h"
+#include "third_party/khronos/GLES2/gl2.h"
+#include "third_party/khronos/GLES2/gl2ext.h"
+#include "third_party/skia/include/gpu/GrContext.h"
+
+using gpu::gles2::GLES2Interface;
+
+namespace cc {
+
+ScopedGpuRaster::ScopedGpuRaster(ContextProvider* context_provider)
+ : context_provider_(context_provider) {
+ BeginGpuRaster();
+}
+
+ScopedGpuRaster::~ScopedGpuRaster() {
+ EndGpuRaster();
+}
+
+void ScopedGpuRaster::BeginGpuRaster() {
+ GLES2Interface* gl = context_provider_->ContextGL();
+
+ // TODO(alokp): Use a trace macro to push/pop markers.
+ // Using push/pop functions directly incurs cost to evaluate function
+ // arguments even when tracing is disabled.
+ gl->PushGroupMarkerEXT(0, "GpuRasterization");
+
+ class GrContext* gr_context = context_provider_->GrContext();
+ gr_context->resetContext();
+}
+
+void ScopedGpuRaster::EndGpuRaster() {
+ GLES2Interface* gl = context_provider_->ContextGL();
+
+ class GrContext* gr_context = context_provider_->GrContext();
+ gr_context->flush();
+
+ // TODO(alokp): Use a trace macro to push/pop markers.
+ // Using push/pop functions directly incurs cost to evaluate function
+ // arguments even when tracing is disabled.
+ gl->PopGroupMarkerEXT();
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698