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

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

Issue 1263913002: FREEZE.unindexed Base URL: https://chromium.googlesource.com/chromium/src.git@textures3
Patch Set: Created 5 years, 4 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 | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_glx.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_egl.h" 5 #include "ui/gl/gl_image_egl.h"
6 6
7 #include "ui/gl/egl_util.h" 7 #include "ui/gl/egl_util.h"
8 #include "ui/gl/gl_surface_egl.h" 8 #include "ui/gl/gl_surface_egl.h"
9 9
10 namespace gfx { 10 namespace gfx {
11 11
12 GLImageEGL::GLImageEGL(const gfx::Size& size) 12 GLImageEGL::GLImageEGL(const gfx::Size& size)
13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) { 13 : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {}
14 }
15 14
16 GLImageEGL::~GLImageEGL() { 15 GLImageEGL::~GLImageEGL() {
17 DCHECK(thread_checker_.CalledOnValidThread()); 16 DCHECK(thread_checker_.CalledOnValidThread());
18 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 17 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
19 } 18 }
20 19
21 bool GLImageEGL::Initialize(EGLenum target, 20 bool GLImageEGL::Initialize(
22 EGLClientBuffer buffer, 21 base::trace_event::GenericSharedMemoryId shared_memory_id,
23 const EGLint* attrs) { 22 EGLenum target,
23 EGLClientBuffer buffer,
24 const EGLint* attrs) {
24 DCHECK(thread_checker_.CalledOnValidThread()); 25 DCHECK(thread_checker_.CalledOnValidThread());
25 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); 26 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
26 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(), 27 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
27 EGL_NO_CONTEXT, 28 EGL_NO_CONTEXT, target, buffer, attrs);
28 target,
29 buffer,
30 attrs);
31 if (egl_image_ == EGL_NO_IMAGE_KHR) { 29 if (egl_image_ == EGL_NO_IMAGE_KHR) {
32 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString(); 30 DLOG(ERROR) << "Error creating EGLImage: " << ui::GetLastEGLErrorString();
33 return false; 31 return false;
34 } 32 }
35 33
34 shared_memory_id_ = shared_memory_id;
36 return true; 35 return true;
37 } 36 }
38 37
39 void GLImageEGL::Destroy(bool have_context) { 38 void GLImageEGL::Destroy(bool have_context) {
40 DCHECK(thread_checker_.CalledOnValidThread()); 39 DCHECK(thread_checker_.CalledOnValidThread());
41 if (egl_image_ != EGL_NO_IMAGE_KHR) { 40 if (egl_image_ != EGL_NO_IMAGE_KHR) {
42 EGLBoolean result = 41 EGLBoolean result =
43 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); 42 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
44 if (result == EGL_FALSE) { 43 if (result == EGL_FALSE) {
45 DLOG(ERROR) << "Error destroying EGLImage: " 44 DLOG(ERROR) << "Error destroying EGLImage: "
(...skipping 22 matching lines...) Expand all
68 } 67 }
69 68
70 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 69 bool GLImageEGL::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
71 int z_order, 70 int z_order,
72 OverlayTransform transform, 71 OverlayTransform transform,
73 const Rect& bounds_rect, 72 const Rect& bounds_rect,
74 const RectF& crop_rect) { 73 const RectF& crop_rect) {
75 return false; 74 return false;
76 } 75 }
77 76
77 void GLImageEGL::DumpMemory(base::trace_event::ProcessMemoryDump* pmd,
78 uint64_t process_tracing_id,
79 const std::string& dump_name) {
80 // TODO(ericrk): Don't always assume 4BPP.
81 const size_t bytes_per_pixel = 4;
82 size_t size_in_bytes =
83 bytes_per_pixel * GetSize().width() * GetSize().height();
84
85 base::trace_event::MemoryAllocatorDump* dump =
86 pmd->CreateAllocatorDump(dump_name);
87 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
88 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
89 static_cast<uint64_t>(size_in_bytes));
90
91 auto guid = base::trace_event::GetGenericSharedMemoryGUIDForTracing(
92 process_tracing_id, shared_memory_id_);
93 pmd->CreateSharedGlobalAllocatorDump(guid);
94 pmd->AddOwnershipEdge(dump->guid(), guid);
95 }
96
78 } // namespace gfx 97 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_glx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698