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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.cc

Issue 1055403010: content: Add GpuMemoryBuffer MemoryDumpProvider implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move register out of ifdef Created 5 years, 7 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
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 "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "content/common/android/surface_texture_manager.h" 9 #include "content/common/android/surface_texture_manager.h"
10 #include "ui/gl/gl_bindings.h" 10 #include "ui/gl/gl_bindings.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 DCHECK(!mapped_); 76 DCHECK(!mapped_);
77 DCHECK(native_window_); 77 DCHECK(native_window_);
78 ANativeWindow_Buffer buffer; 78 ANativeWindow_Buffer buffer;
79 int status = ANativeWindow_lock(native_window_, &buffer, NULL); 79 int status = ANativeWindow_lock(native_window_, &buffer, NULL);
80 if (status) { 80 if (status) {
81 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; 81 VLOG(1) << "ANativeWindow_lock failed with error code: " << status;
82 return false; 82 return false;
83 } 83 }
84 84
85 size_t stride_in_bytes = 0; 85 DCHECK_LE(size_.width(), buffer.stride);
86 if (!StrideInBytes(buffer.stride, format_, 0, &stride_in_bytes)) 86 size_t row_size_in_bytes = 0;
87 return false; 87 bool valid_row_size =
88 RowSizeInBytes(buffer.stride, format_, 0, &row_size_in_bytes);
89 DCHECK(valid_row_size);
88 90
89 DCHECK_LE(size_.width(), buffer.stride); 91 stride_ = row_size_in_bytes;
90 stride_ = stride_in_bytes;
91 mapped_ = true; 92 mapped_ = true;
92 *data = buffer.bits; 93 *data = buffer.bits;
93 return true; 94 return true;
94 } 95 }
95 96
96 void GpuMemoryBufferImplSurfaceTexture::Unmap() { 97 void GpuMemoryBufferImplSurfaceTexture::Unmap() {
97 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); 98 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap");
98 99
99 DCHECK(mapped_); 100 DCHECK(mapped_);
100 ANativeWindow_unlockAndPost(native_window_); 101 ANativeWindow_unlockAndPost(native_window_);
101 mapped_ = false; 102 mapped_ = false;
102 } 103 }
103 104
104 void GpuMemoryBufferImplSurfaceTexture::GetStride(int* stride) const { 105 void GpuMemoryBufferImplSurfaceTexture::GetStride(int* stride) const {
105 *stride = stride_; 106 *stride = stride_;
106 } 107 }
107 108
108 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() 109 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle()
109 const { 110 const {
110 gfx::GpuMemoryBufferHandle handle; 111 gfx::GpuMemoryBufferHandle handle;
111 handle.type = gfx::SURFACE_TEXTURE_BUFFER; 112 handle.type = gfx::SURFACE_TEXTURE_BUFFER;
112 handle.id = id_; 113 handle.id = id_;
113 return handle; 114 return handle;
114 } 115 }
115 116
116 } // namespace content 117 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698