Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / cc / resources / scoped_gpu_raster.cc
blob517c7a7d81465371729cda5f4b2ca99aaa97917e
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
3 // found in the LICENSE file.
5 #include "cc/resources/scoped_gpu_raster.h"
6 #include "gpu/command_buffer/client/gles2_interface.h"
7 #include "third_party/khronos/GLES2/gl2.h"
8 #include "third_party/khronos/GLES2/gl2ext.h"
9 #include "third_party/skia/include/gpu/GrContext.h"
11 using gpu::gles2::GLES2Interface;
13 namespace cc {
15 ScopedGpuRaster::ScopedGpuRaster(ContextProvider* context_provider)
16 : context_provider_(context_provider) {
17 BeginGpuRaster();
20 ScopedGpuRaster::~ScopedGpuRaster() {
21 EndGpuRaster();
24 void ScopedGpuRaster::BeginGpuRaster() {
25 GLES2Interface* gl = context_provider_->ContextGL();
27 // TODO(alokp): Use a trace macro to push/pop markers.
28 // Using push/pop functions directly incurs cost to evaluate function
29 // arguments even when tracing is disabled.
30 gl->PushGroupMarkerEXT(0, "GpuRasterization");
32 class GrContext* gr_context = context_provider_->GrContext();
33 // TODO(sohanjg): Remove when TestContextProvider gives a GrContext.
34 if (gr_context)
35 gr_context->resetContext();
38 void ScopedGpuRaster::EndGpuRaster() {
39 GLES2Interface* gl = context_provider_->ContextGL();
41 class GrContext* gr_context = context_provider_->GrContext();
42 // TODO(sohanjg): Remove when TestContextProvider gives a GrContext.
43 if (gr_context)
44 gr_context->flush();
46 // TODO(alokp): Use a trace macro to push/pop markers.
47 // Using push/pop functions directly incurs cost to evaluate function
48 // arguments even when tracing is disabled.
49 gl->PopGroupMarkerEXT();
52 } // namespace cc