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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 817673004: cc: TextureUploader - Reset GL_UNPACK_ALIGNMENT to 4 before uploading images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bind context provider to current thread. Created 5 years, 12 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 | « cc/cc_tests.gyp ('k') | cc/resources/scoped_gpu_raster.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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "cc/base/math_util.h" 15 #include "cc/base/math_util.h"
16 #include "cc/layers/video_layer_impl.h" 16 #include "cc/layers/video_layer_impl.h"
17 #include "cc/output/compositor_frame.h" 17 #include "cc/output/compositor_frame.h"
18 #include "cc/output/compositor_frame_metadata.h" 18 #include "cc/output/compositor_frame_metadata.h"
19 #include "cc/output/context_provider.h" 19 #include "cc/output/context_provider.h"
20 #include "cc/output/copy_output_request.h" 20 #include "cc/output/copy_output_request.h"
21 #include "cc/output/geometry_binding.h" 21 #include "cc/output/geometry_binding.h"
22 #include "cc/output/gl_frame_data.h" 22 #include "cc/output/gl_frame_data.h"
23 #include "cc/output/output_surface.h" 23 #include "cc/output/output_surface.h"
24 #include "cc/output/render_surface_filters.h" 24 #include "cc/output/render_surface_filters.h"
25 #include "cc/quads/picture_draw_quad.h" 25 #include "cc/quads/picture_draw_quad.h"
26 #include "cc/quads/render_pass.h" 26 #include "cc/quads/render_pass.h"
27 #include "cc/quads/stream_video_draw_quad.h" 27 #include "cc/quads/stream_video_draw_quad.h"
28 #include "cc/quads/texture_draw_quad.h" 28 #include "cc/quads/texture_draw_quad.h"
29 #include "cc/resources/layer_quad.h" 29 #include "cc/resources/layer_quad.h"
30 #include "cc/resources/scoped_gpu_raster.h"
30 #include "cc/resources/scoped_resource.h" 31 #include "cc/resources/scoped_resource.h"
31 #include "cc/resources/texture_mailbox_deleter.h" 32 #include "cc/resources/texture_mailbox_deleter.h"
32 #include "gpu/GLES2/gl2extchromium.h" 33 #include "gpu/GLES2/gl2extchromium.h"
33 #include "gpu/command_buffer/client/context_support.h" 34 #include "gpu/command_buffer/client/context_support.h"
34 #include "gpu/command_buffer/client/gles2_interface.h" 35 #include "gpu/command_buffer/client/gles2_interface.h"
35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 36 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
36 #include "third_party/skia/include/core/SkBitmap.h" 37 #include "third_party/skia/include/core/SkBitmap.h"
37 #include "third_party/skia/include/core/SkColor.h" 38 #include "third_party/skia/include/core/SkColor.h"
38 #include "third_party/skia/include/core/SkColorFilter.h" 39 #include "third_party/skia/include/core/SkColorFilter.h"
39 #include "third_party/skia/include/core/SkImage.h" 40 #include "third_party/skia/include/core/SkImage.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return active_unit; 152 return active_unit;
152 } 153 }
153 154
154 class GLRenderer::ScopedUseGrContext { 155 class GLRenderer::ScopedUseGrContext {
155 public: 156 public:
156 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, 157 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer,
157 DrawingFrame* frame) { 158 DrawingFrame* frame) {
158 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); 159 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame));
159 } 160 }
160 161
161 ~ScopedUseGrContext() { PassControlToGLRenderer(); } 162 ~ScopedUseGrContext() {
163 // Pass context control back to GLrenderer.
164 scoped_gpu_raster_ = nullptr;
165 renderer_->RestoreGLState();
166 renderer_->RestoreFramebuffer(frame_);
167 }
162 168
163 GrContext* context() const { 169 GrContext* context() const {
164 return renderer_->output_surface_->context_provider()->GrContext(); 170 return renderer_->output_surface_->context_provider()->GrContext();
165 } 171 }
166 172
167 private: 173 private:
168 ScopedUseGrContext(GLRenderer* renderer, DrawingFrame* frame) 174 ScopedUseGrContext(GLRenderer* renderer, DrawingFrame* frame)
169 : renderer_(renderer), frame_(frame) { 175 : scoped_gpu_raster_(
170 PassControlToSkia(); 176 new ScopedGpuRaster(renderer->output_surface_->context_provider())),
177 renderer_(renderer),
178 frame_(frame) {
179 // scoped_gpu_raster_ passes context control to Skia.
171 } 180 }
172 181
173 void PassControlToSkia() { context()->resetContext(); } 182 scoped_ptr<ScopedGpuRaster> scoped_gpu_raster_;
174
175 void PassControlToGLRenderer() {
176 renderer_->RestoreGLState();
177 renderer_->RestoreFramebuffer(frame_);
178 }
179
180 GLRenderer* renderer_; 183 GLRenderer* renderer_;
181 DrawingFrame* frame_; 184 DrawingFrame* frame_;
182 185
183 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext); 186 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext);
184 }; 187 };
185 188
186 struct GLRenderer::PendingAsyncReadPixels { 189 struct GLRenderer::PendingAsyncReadPixels {
187 PendingAsyncReadPixels() : buffer(0) {} 190 PendingAsyncReadPixels() : buffer(0) {}
188 191
189 scoped_ptr<CopyOutputRequest> copy_request; 192 scoped_ptr<CopyOutputRequest> copy_request;
(...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 context_support_->ScheduleOverlayPlane( 3292 context_support_->ScheduleOverlayPlane(
3290 overlay.plane_z_order, 3293 overlay.plane_z_order,
3291 overlay.transform, 3294 overlay.transform,
3292 pending_overlay_resources_.back()->texture_id(), 3295 pending_overlay_resources_.back()->texture_id(),
3293 overlay.display_rect, 3296 overlay.display_rect,
3294 overlay.uv_rect); 3297 overlay.uv_rect);
3295 } 3298 }
3296 } 3299 }
3297 3300
3298 } // namespace cc 3301 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/resources/scoped_gpu_raster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698