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

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

Issue 806653006: Update GPU memory buffers to use StrideInBytes internally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use StrideInBytes Created 6 years 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/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 DCHECK(!mapped_); 69 DCHECK(!mapped_);
70 DCHECK(native_window_); 70 DCHECK(native_window_);
71 ANativeWindow_Buffer buffer; 71 ANativeWindow_Buffer buffer;
72 int status = ANativeWindow_lock(native_window_, &buffer, NULL); 72 int status = ANativeWindow_lock(native_window_, &buffer, NULL);
73 if (status) { 73 if (status) {
74 VLOG(1) << "ANativeWindow_lock failed with error code: " << status; 74 VLOG(1) << "ANativeWindow_lock failed with error code: " << status;
75 return NULL; 75 return NULL;
76 } 76 }
77 77
78 DCHECK_LE(size_.width(), buffer.stride); 78 DCHECK_LE(size_.width(), buffer.stride);
79 stride_ = buffer.stride * BytesPerPixel(format_); 79 stride_ = StrideInBytes(buffer.stride, format_);
80 mapped_ = true; 80 mapped_ = true;
81 return buffer.bits; 81 return buffer.bits;
82 } 82 }
83 83
84 void GpuMemoryBufferImplSurfaceTexture::Unmap() { 84 void GpuMemoryBufferImplSurfaceTexture::Unmap() {
85 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap"); 85 TRACE_EVENT0("gpu", "GpuMemoryBufferImplSurfaceTexture::Unmap");
86 86
87 DCHECK(mapped_); 87 DCHECK(mapped_);
88 ANativeWindow_unlockAndPost(native_window_); 88 ANativeWindow_unlockAndPost(native_window_);
89 mapped_ = false; 89 mapped_ = false;
90 } 90 }
91 91
92 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const { 92 uint32 GpuMemoryBufferImplSurfaceTexture::GetStride() const {
93 return stride_; 93 return stride_;
94 } 94 }
95 95
96 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle() 96 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSurfaceTexture::GetHandle()
97 const { 97 const {
98 gfx::GpuMemoryBufferHandle handle; 98 gfx::GpuMemoryBufferHandle handle;
99 handle.type = gfx::SURFACE_TEXTURE_BUFFER; 99 handle.type = gfx::SURFACE_TEXTURE_BUFFER;
100 handle.id = id_; 100 handle.id = id_;
101 return handle; 101 return handle;
102 } 102 }
103 103
104 } // namespace content 104 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698