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

Side by Side Diff: cc/test/test_gpu_memory_buffer_manager.cc

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: rebase Created 6 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
« no previous file with comments | « cc/test/test_gpu_memory_buffer_manager.h ('k') | cc/test/test_web_graphics_context_3d.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/test/test_gpu_memory_buffer_manager.h"
6
7 #include "ui/gfx/gpu_memory_buffer.h"
8
9 namespace cc {
10 namespace {
11
12 class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
13 public:
14 GpuMemoryBufferImpl(const gfx::Size& size, Format format)
15 : size_(size),
16 format_(format),
17 pixels_(new uint8[size.GetArea() * BytesPerPixel(format)]),
18 mapped_(false) {}
19
20 // Overridden from gfx::GpuMemoryBuffer:
21 virtual void* Map() override {
22 mapped_ = true;
23 return pixels_.get();
24 }
25 virtual void Unmap() override { mapped_ = false; }
vmpstr 2014/10/08 17:52:25 DCHECK/ASSERT/EXPECT mapped_?
reveman 2014/10/08 19:15:31 Done.
26 virtual bool IsMapped() const override { return mapped_; }
27 virtual Format GetFormat() const override { return format_; }
28 virtual uint32 GetStride() const override {
29 return size_.width() * BytesPerPixel(format_);
30 }
31 virtual gfx::GpuMemoryBufferHandle GetHandle() const override {
32 NOTREACHED();
33 return gfx::GpuMemoryBufferHandle();
34 }
35 virtual ClientBuffer AsClientBuffer() override {
36 return reinterpret_cast<ClientBuffer>(this);
37 }
38
39 private:
40 static size_t BytesPerPixel(Format format) {
41 switch (format) {
42 case RGBA_8888:
43 case RGBX_8888:
44 case BGRA_8888:
45 return 4;
46 }
47
48 NOTREACHED();
49 return 0;
50 }
51
52 const gfx::Size size_;
53 gfx::GpuMemoryBuffer::Format format_;
54 scoped_ptr<uint8[]> pixels_;
55 bool mapped_;
56 };
57
58 } // namespace
59
60 TestGpuMemoryBufferManager::TestGpuMemoryBufferManager() {
61 }
62
63 TestGpuMemoryBufferManager::~TestGpuMemoryBufferManager() {
64 }
65
66 scoped_ptr<gfx::GpuMemoryBuffer>
67 TestGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
68 const gfx::Size& size,
69 gfx::GpuMemoryBuffer::Format format,
70 gfx::GpuMemoryBuffer::Usage usage) {
71 return make_scoped_ptr<gfx::GpuMemoryBuffer>(
72 new GpuMemoryBufferImpl(size, format));
73 }
74
75 gfx::GpuMemoryBuffer*
76 TestGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer(
77 ClientBuffer buffer) {
78 return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer);
79 }
80
81 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_gpu_memory_buffer_manager.h ('k') | cc/test/test_web_graphics_context_3d.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698