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

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 1412223009: Reland: GpuMemoryBuffer interface change: Map(**) to Map() and memory(plane); stride(plane) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Win X64 compile fix Created 5 years, 2 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 (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 #include "gpu/command_buffer/tests/gl_manager.h" 5 #include "gpu/command_buffer/tests/gl_manager.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 namespace gpu { 42 namespace gpu {
43 namespace { 43 namespace {
44 44
45 uint64_t g_next_command_buffer_id = 0; 45 uint64_t g_next_command_buffer_id = 0;
46 46
47 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { 47 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
48 public: 48 public:
49 GpuMemoryBufferImpl(base::RefCountedBytes* bytes, 49 GpuMemoryBufferImpl(base::RefCountedBytes* bytes,
50 const gfx::Size& size, 50 const gfx::Size& size,
51 gfx::BufferFormat format) 51 gfx::BufferFormat format)
52 : bytes_(bytes), size_(size), format_(format) {} 52 : mapped_(false), bytes_(bytes), size_(size), format_(format) {}
53 53
54 static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer) { 54 static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer) {
55 return reinterpret_cast<GpuMemoryBufferImpl*>(buffer); 55 return reinterpret_cast<GpuMemoryBufferImpl*>(buffer);
56 } 56 }
57 57
58 // Overridden from gfx::GpuMemoryBuffer: 58 // Overridden from gfx::GpuMemoryBuffer:
59 bool Map(void** data) override { 59 bool Map() override {
60 size_t offset = 0; 60 DCHECK(!mapped_);
61 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format_); 61 mapped_ = true;
62 for (size_t i = 0; i < num_planes; ++i) {
63 data[i] = reinterpret_cast<uint8*>(&bytes_->data().front()) + offset;
64 offset +=
65 gfx::RowSizeForBufferFormat(size_.width(), format_, i) *
66 (size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i));
67 }
68 return true; 62 return true;
69 } 63 }
70 void Unmap() override {} 64 void* memory(size_t plane) override {
65 DCHECK(mapped_);
66 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
67 return reinterpret_cast<uint8*>(&bytes_->data().front()) +
68 gfx::BufferOffsetForBufferFormat(size_, format_, plane);
69 }
70 void Unmap() override {
71 DCHECK(mapped_);
72 mapped_ = false;
73 }
71 gfx::Size GetSize() const override { return size_; } 74 gfx::Size GetSize() const override { return size_; }
72 gfx::BufferFormat GetFormat() const override { return format_; } 75 gfx::BufferFormat GetFormat() const override { return format_; }
73 void GetStride(int* stride) const override { 76 int stride(size_t plane) const override {
74 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format_); 77 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
75 for (size_t i = 0; i < num_planes; ++i) 78 return gfx::RowSizeForBufferFormat(size_.width(), format_, plane);
76 stride[i] = gfx::RowSizeForBufferFormat(size_.width(), format_, i);
77 } 79 }
78 gfx::GpuMemoryBufferId GetId() const override { 80 gfx::GpuMemoryBufferId GetId() const override {
79 NOTREACHED(); 81 NOTREACHED();
80 return gfx::GpuMemoryBufferId(0); 82 return gfx::GpuMemoryBufferId(0);
81 } 83 }
82 gfx::GpuMemoryBufferHandle GetHandle() const override { 84 gfx::GpuMemoryBufferHandle GetHandle() const override {
83 NOTREACHED(); 85 NOTREACHED();
84 return gfx::GpuMemoryBufferHandle(); 86 return gfx::GpuMemoryBufferHandle();
85 } 87 }
86 ClientBuffer AsClientBuffer() override { 88 ClientBuffer AsClientBuffer() override {
87 return reinterpret_cast<ClientBuffer>(this); 89 return reinterpret_cast<ClientBuffer>(this);
88 } 90 }
89 91
90 base::RefCountedBytes* bytes() { return bytes_.get(); } 92 base::RefCountedBytes* bytes() { return bytes_.get(); }
91 93
92 private: 94 private:
95 bool mapped_;
93 scoped_refptr<base::RefCountedBytes> bytes_; 96 scoped_refptr<base::RefCountedBytes> bytes_;
94 const gfx::Size size_; 97 const gfx::Size size_;
95 gfx::BufferFormat format_; 98 gfx::BufferFormat format_;
96 }; 99 };
97 100
98 } // namespace 101 } // namespace
99 102
100 int GLManager::use_count_; 103 int GLManager::use_count_;
101 scoped_refptr<gfx::GLShareGroup>* GLManager::base_share_group_; 104 scoped_refptr<gfx::GLShareGroup>* GLManager::base_share_group_;
102 scoped_refptr<gfx::GLSurface>* GLManager::base_surface_; 105 scoped_refptr<gfx::GLSurface>* GLManager::base_surface_;
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 525
523 bool GLManager::IsFenceSyncFlushReceived(uint64_t release) { 526 bool GLManager::IsFenceSyncFlushReceived(uint64_t release) {
524 return IsFenceSyncRelease(release); 527 return IsFenceSyncRelease(release);
525 } 528 }
526 529
527 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 530 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
528 return false; 531 return false;
529 } 532 }
530 533
531 } // namespace gpu 534 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc ('k') | media/renderers/mock_gpu_video_accelerator_factories.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698