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

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

Issue 11428140: gpu: Add async pixel transfer interface, stub and tests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Fix lint. Created 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/gl/async_pixel_transfer_delegate_stub.h"
6
7 #include "base/bind.h"
8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/shared_memory.h"
11 #include "build/build_config.h"
12 #include "third_party/angle/include/EGL/egl.h"
13 #include "third_party/angle/include/EGL/eglext.h"
14 #include "ui/gl/async_pixel_transfer_delegate.h"
15 #include "ui/gl/gl_bindings.h"
16
17 using base::SharedMemory;
18 using base::SharedMemoryHandle;
19
20 // Gets the address of the data from shared memory.
21 void* GetAddress(SharedMemory* shared_memory,
greggman 2012/12/12 03:51:36 style: this wants to be in an anonymous namespace
epennerAtGoogle 2012/12/12 04:49:49 Done.
22 uint32 shm_size,
23 uint32 shm_data_offset,
24 uint32 shm_data_size) {
25 // Memory bounds have already been validated, so there
26 // is just DCHECKS here.
27 DCHECK(shared_memory);
28 DCHECK(shared_memory->memory());
29 DCHECK_LE(shm_data_offset + shm_data_size, shm_size);
30 return static_cast<int8*>(shared_memory->memory()) + shm_data_offset;
31 }
32
33 namespace gfx {
34
35 class AsyncTransferStateStub : public AsyncPixelTransferState {
36 public:
37 explicit AsyncTransferStateStub(GLuint texture_id) {}
38 // implement AsyncPixelTransferState:
39 virtual bool TransferIsInProgress() { return false; }
40 virtual bool BindAsyncTransferToTexture(GLenum target) { return true; }
41
42 private:
43 virtual ~AsyncTransferStateStub() {}
44 DISALLOW_COPY_AND_ASSIGN(AsyncTransferStateStub);
45 };
46
47 // Class which handles async pixel transfers on Android (using
48 // EGLImageKHR and another upload thread)
49 class AsyncPixelTransferDelegateStub : public AsyncPixelTransferDelegate {
50 public:
51 AsyncPixelTransferDelegateStub() {}
52 virtual ~AsyncPixelTransferDelegateStub() {}
53
54 // implement AsyncPixelTransferDelegate:
55 virtual scoped_refptr<AsyncPixelTransferState>
56 CreatePixelTransferState(GLuint texture_id) OVERRIDE {
57 return make_scoped_refptr(
58 static_cast<AsyncPixelTransferState*>(
59 new AsyncTransferStateStub(texture_id)));
60 }
61
62 virtual void AsyncNotifyCompletion(
63 const base::Closure& task) OVERRIDE {
64 task.Run();
65 }
66
67 virtual void AsyncTexImage2D(
68 AsyncPixelTransferState*,
69 AsyncTexImage2DParams t,
greggman 2012/12/12 03:51:36 style: single letter names are discouraged in the
epennerAtGoogle 2012/12/12 04:49:49 Done.
70 AsyncMemoryParams m) {
71 void* data = GetAddress(m.shared_memory, m.shm_size,
72 m.shm_data_offset, m.shm_data_size);
73 glTexImage2D(
greggman 2012/12/12 03:51:36 I'm a little confused. This is temporary impl that
epennerAtGoogle 2012/12/12 04:49:49 Yes this is a stub that allows the API to work by
74 t.target, t.level, t.internal_format,
75 t.width, t.height, t.border, t.format, t.type, data);
76 }
77
78 virtual void AsyncTexSubImage2D(
79 AsyncPixelTransferState*,
80 AsyncTexSubImage2DParams t,
81 AsyncMemoryParams m) {
82 void* data = GetAddress(m.shared_memory, m.shm_size,
83 m.shm_data_offset, m.shm_data_size);
84 glTexSubImage2D(
85 t.target, t.level, t.xoffset, t.yoffset,
86 t.width, t.height, t.format, t.type, data);
87 }
88
89 private:
90 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateStub);
91 };
92
93 scoped_ptr<AsyncPixelTransferDelegate> AsyncPixelTransferDelegate::Create() {
94 return make_scoped_ptr(
95 static_cast<AsyncPixelTransferDelegate*>(
96 new AsyncPixelTransferDelegateStub()));
97 }
98
99 } // namespace gfx
100
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698