OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_COMPOSITOR_GL_HELPER_H_ | 5 #ifndef COMPONENTS_DISPLAY_COMPOSITOR_GL_HELPER_H_ |
6 #define CONTENT_BROWSER_COMPOSITOR_GL_HELPER_H_ | 6 #define COMPONENTS_DISPLAY_COMPOSITOR_GL_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "content/common/content_export.h" | 13 #include "components/display_compositor/display_compositor_export.h" |
14 #include "gpu/command_buffer/client/gles2_interface.h" | 14 #include "gpu/command_buffer/client/gles2_interface.h" |
15 #include "gpu/command_buffer/common/mailbox_holder.h" | 15 #include "gpu/command_buffer/common/mailbox_holder.h" |
16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 class Point; | 19 class Point; |
20 class Rect; | 20 class Rect; |
21 class Size; | 21 class Size; |
22 } | 22 } |
23 | 23 |
24 namespace gpu { | 24 namespace gpu { |
25 class ContextSupport; | 25 class ContextSupport; |
26 struct Mailbox; | 26 struct Mailbox; |
27 } | 27 } |
28 | 28 |
29 class SkRegion; | 29 class SkRegion; |
30 | 30 |
31 namespace content { | 31 namespace display_compositor { |
32 | 32 |
33 class GLHelperScaling; | 33 class GLHelperScaling; |
34 | 34 |
35 class ScopedGLuint { | 35 class DISPLAY_COMPOSITOR_EXPORT ScopedGLuint { |
36 public: | 36 public: |
37 typedef void (gpu::gles2::GLES2Interface::*GenFunc)(GLsizei n, GLuint* ids); | 37 typedef void (gpu::gles2::GLES2Interface::*GenFunc)(GLsizei n, GLuint* ids); |
38 typedef void (gpu::gles2::GLES2Interface::*DeleteFunc)(GLsizei n, | 38 typedef void (gpu::gles2::GLES2Interface::*DeleteFunc)(GLsizei n, |
39 const GLuint* ids); | 39 const GLuint* ids); |
40 ScopedGLuint(gpu::gles2::GLES2Interface* gl, | 40 ScopedGLuint(gpu::gles2::GLES2Interface* gl, |
41 GenFunc gen_func, | 41 GenFunc gen_func, |
42 DeleteFunc delete_func) | 42 DeleteFunc delete_func) |
43 : gl_(gl), id_(0u), delete_func_(delete_func) { | 43 : gl_(gl), id_(0u), delete_func_(delete_func) { |
44 (gl_->*gen_func)(1, &id_); | 44 (gl_->*gen_func)(1, &id_); |
45 } | 45 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 ScopedTextureBinder(gpu::gles2::GLES2Interface* gl, GLuint id) | 127 ScopedTextureBinder(gpu::gles2::GLES2Interface* gl, GLuint id) |
128 : ScopedBinder<Target>(gl, id, &gpu::gles2::GLES2Interface::BindTexture) { | 128 : ScopedBinder<Target>(gl, id, &gpu::gles2::GLES2Interface::BindTexture) { |
129 } | 129 } |
130 }; | 130 }; |
131 | 131 |
132 class ReadbackYUVInterface; | 132 class ReadbackYUVInterface; |
133 class GLHelperReadbackSupport; | 133 class GLHelperReadbackSupport; |
134 | 134 |
135 // Provides higher level operations on top of the gpu::gles2::GLES2Interface | 135 // Provides higher level operations on top of the gpu::gles2::GLES2Interface |
136 // interfaces. | 136 // interfaces. |
137 class CONTENT_EXPORT GLHelper { | 137 class DISPLAY_COMPOSITOR_EXPORT GLHelper { |
138 public: | 138 public: |
139 GLHelper(gpu::gles2::GLES2Interface* gl, | 139 GLHelper(gpu::gles2::GLES2Interface* gl, |
140 gpu::ContextSupport* context_support); | 140 gpu::ContextSupport* context_support); |
141 ~GLHelper(); | 141 ~GLHelper(); |
142 | 142 |
143 enum ScalerQuality { | 143 enum ScalerQuality { |
144 // Bilinear single pass, fastest possible. | 144 // Bilinear single pass, fastest possible. |
145 SCALER_QUALITY_FAST = 1, | 145 SCALER_QUALITY_FAST = 1, |
146 | 146 |
147 // Bilinear upscale + N * 50% bilinear downscales. | 147 // Bilinear upscale + N * 50% bilinear downscales. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 // Force commands in the current command buffer to be executed before commands | 274 // Force commands in the current command buffer to be executed before commands |
275 // in other command buffers from the same process (ie channel to the GPU | 275 // in other command buffers from the same process (ie channel to the GPU |
276 // process). | 276 // process). |
277 void InsertOrderingBarrier(); | 277 void InsertOrderingBarrier(); |
278 | 278 |
279 // A scaler will cache all intermediate textures and programs | 279 // A scaler will cache all intermediate textures and programs |
280 // needed to scale from a specified size to a destination size. | 280 // needed to scale from a specified size to a destination size. |
281 // If the source or destination sizes changes, you must create | 281 // If the source or destination sizes changes, you must create |
282 // a new scaler. | 282 // a new scaler. |
283 class CONTENT_EXPORT ScalerInterface { | 283 class DISPLAY_COMPOSITOR_EXPORT ScalerInterface { |
284 public: | 284 public: |
285 ScalerInterface() {} | 285 ScalerInterface() {} |
286 virtual ~ScalerInterface() {} | 286 virtual ~ScalerInterface() {} |
287 | 287 |
288 // Note that the src_texture will have the min/mag filter set to GL_LINEAR | 288 // Note that the src_texture will have the min/mag filter set to GL_LINEAR |
289 // and wrap_s/t set to CLAMP_TO_EDGE in this call. | 289 // and wrap_s/t set to CLAMP_TO_EDGE in this call. |
290 virtual void Scale(GLuint source_texture, GLuint dest_texture) = 0; | 290 virtual void Scale(GLuint source_texture, GLuint dest_texture) = 0; |
291 virtual const gfx::Size& SrcSize() = 0; | 291 virtual const gfx::Size& SrcSize() = 0; |
292 virtual const gfx::Rect& SrcSubrect() = 0; | 292 virtual const gfx::Rect& SrcSubrect() = 0; |
293 virtual const gfx::Size& DstSize() = 0; | 293 virtual const gfx::Size& DstSize() = 0; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 DISALLOW_COPY_AND_ASSIGN(GLHelper); | 346 DISALLOW_COPY_AND_ASSIGN(GLHelper); |
347 }; | 347 }; |
348 | 348 |
349 // Similar to a ScalerInterface, a yuv readback pipeline will | 349 // Similar to a ScalerInterface, a yuv readback pipeline will |
350 // cache a scaler and all intermediate textures and frame buffers | 350 // cache a scaler and all intermediate textures and frame buffers |
351 // needed to scale, crop, letterbox and read back a texture from | 351 // needed to scale, crop, letterbox and read back a texture from |
352 // the GPU into CPU-accessible RAM. A single readback pipeline | 352 // the GPU into CPU-accessible RAM. A single readback pipeline |
353 // can handle multiple outstanding readbacks at the same time, but | 353 // can handle multiple outstanding readbacks at the same time, but |
354 // if the source or destination sizes change, you'll need to create | 354 // if the source or destination sizes change, you'll need to create |
355 // a new readback pipeline. | 355 // a new readback pipeline. |
356 class CONTENT_EXPORT ReadbackYUVInterface { | 356 class DISPLAY_COMPOSITOR_EXPORT ReadbackYUVInterface { |
357 public: | 357 public: |
358 ReadbackYUVInterface() {} | 358 ReadbackYUVInterface() {} |
359 virtual ~ReadbackYUVInterface() {} | 359 virtual ~ReadbackYUVInterface() {} |
360 | 360 |
361 // Note that |target| must use YV12 format. |paste_location| specifies where | 361 // Note that |target| must use YV12 format. |paste_location| specifies where |
362 // the captured pixels that are read back will be placed in the video frame. | 362 // the captured pixels that are read back will be placed in the video frame. |
363 // The region defined by the |paste_location| and the |dst_size| specified in | 363 // The region defined by the |paste_location| and the |dst_size| specified in |
364 // the call to CreateReadbackPipelineYUV() must be fully contained within | 364 // the call to CreateReadbackPipelineYUV() must be fully contained within |
365 // |target->visible_rect()|. | 365 // |target->visible_rect()|. |
366 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, | 366 virtual void ReadbackYUV(const gpu::Mailbox& mailbox, |
367 const gpu::SyncToken& sync_token, | 367 const gpu::SyncToken& sync_token, |
368 const gfx::Rect& target_visible_rect, | 368 const gfx::Rect& target_visible_rect, |
369 int y_plane_row_stride_bytes, | 369 int y_plane_row_stride_bytes, |
370 unsigned char* y_plane_data, | 370 unsigned char* y_plane_data, |
371 int u_plane_row_stride_bytes, | 371 int u_plane_row_stride_bytes, |
372 unsigned char* u_plane_data, | 372 unsigned char* u_plane_data, |
373 int v_plane_row_stride_bytes, | 373 int v_plane_row_stride_bytes, |
374 unsigned char* v_plane_data, | 374 unsigned char* v_plane_data, |
375 const gfx::Point& paste_location, | 375 const gfx::Point& paste_location, |
376 const base::Callback<void(bool)>& callback) = 0; | 376 const base::Callback<void(bool)>& callback) = 0; |
377 virtual GLHelper::ScalerInterface* scaler() = 0; | 377 virtual GLHelper::ScalerInterface* scaler() = 0; |
378 }; | 378 }; |
379 | 379 |
380 } // namespace content | 380 } // namespace display_compositor |
381 | 381 |
382 #endif // CONTENT_BROWSER_COMPOSITOR_GL_HELPER_H_ | 382 #endif // COMPONENTS_DISPLAY_COMPOSITOR_GL_HELPER_H_ |
OLD | NEW |