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

Side by Side Diff: ui/gl/gl_image_memory.cc

Issue 2443023002: gpu: Add CHROMIUM_copy_image extension.
Patch Set: rebase Created 4 years, 1 month 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 | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_stub.h » ('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 2014 The Chromium Authors. All rights reserved. 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 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 "ui/gl/gl_image_memory.h" 5 #include "ui/gl/gl_image_memory.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "ui/gfx/buffer_format_util.h" 12 #include "ui/gfx/buffer_format_util.h"
13 #include "ui/gl/gl_bindings.h" 13 #include "ui/gl/gl_bindings.h"
14 #include "ui/gl/gl_context.h" 14 #include "ui/gl/gl_context.h"
15 #include "ui/gl/gl_fence.h"
15 #include "ui/gl/gl_version_info.h" 16 #include "ui/gl/gl_version_info.h"
17 #include "ui/gl/scoped_binders.h"
16 18
17 using gfx::BufferFormat; 19 using gfx::BufferFormat;
18 20
19 namespace gl { 21 namespace gl {
20 namespace { 22 namespace {
21 23
22 bool ValidInternalFormat(unsigned internalformat) { 24 bool ValidInternalFormat(unsigned internalformat) {
23 switch (internalformat) { 25 switch (internalformat) {
24 case GL_ATC_RGB_AMD: 26 case GL_ATC_RGB_AMD:
25 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: 27 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 rect.height(), data_format, data_type, 483 rect.height(), data_format, data_type,
482 gles2_data ? gles2_data.get() : data); 484 gles2_data ? gles2_data.get() : data);
483 485
484 if (data_row_length != rect.width()) 486 if (data_row_length != rect.width())
485 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 487 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
486 } 488 }
487 489
488 return true; 490 return true;
489 } 491 }
490 492
493 bool GLImageMemory::CopySubImageData(unsigned texture_id,
494 const gfx::Point& offset,
495 const gfx::Rect& rect,
496 GLFence* in_fence,
497 GLFence* out_fence) {
498 TRACE_EVENT2("gpu", "GLImageMemory::CopySubImageData", "width", rect.width(),
499 "height", rect.height());
500
501 // Output fence must have support for client side signaling.
502 if (out_fence && !out_fence->SignalSupported())
503 return false;
504
505 if (in_fence)
506 in_fence->ClientWait();
507
508 {
509 ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id);
510
511 bool rv = CopyTexSubImage(GL_TEXTURE_2D, offset, rect);
512 if (!rv)
513 return false;
514 }
515
516 if (out_fence)
517 out_fence->Signal();
518
519 return true;
520 }
521
491 bool GLImageMemory::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 522 bool GLImageMemory::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
492 int z_order, 523 int z_order,
493 gfx::OverlayTransform transform, 524 gfx::OverlayTransform transform,
494 const gfx::Rect& bounds_rect, 525 const gfx::Rect& bounds_rect,
495 const gfx::RectF& crop_rect) { 526 const gfx::RectF& crop_rect) {
496 return false; 527 return false;
497 } 528 }
498 529
499 // static 530 // static
500 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { 531 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) {
501 DCHECK(ValidFormat(format)); 532 DCHECK(ValidFormat(format));
502 return TextureFormat(format); 533 return TextureFormat(format);
503 } 534 }
504 535
505 } // namespace gl 536 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698