| OLD | NEW |
| (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 "mojo/examples/pepper_container_app/graphics_3d_resource.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h" | |
| 9 #include "mojo/examples/pepper_container_app/plugin_instance.h" | |
| 10 #include "mojo/public/c/gles2/gles2.h" | |
| 11 #include "mojo/public/cpp/environment/environment.h" | |
| 12 #include "ppapi/c/pp_errors.h" | |
| 13 | |
| 14 namespace mojo { | |
| 15 namespace examples { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 gpu::CommandBuffer::State GetErrorState() { | |
| 20 gpu::CommandBuffer::State error_state; | |
| 21 error_state.error = gpu::error::kGenericError; | |
| 22 return error_state; | |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 27 Graphics3DResource::Graphics3DResource(PP_Instance instance) | |
| 28 : Resource(ppapi::OBJECT_IS_IMPL, instance) { | |
| 29 ScopedMessagePipeHandle pipe = MojoPpapiGlobals::Get()->CreateGLES2Context(); | |
| 30 context_ = MojoGLES2CreateContext(pipe.release().value(), | |
| 31 &ContextLostThunk, | |
| 32 this, | |
| 33 Environment::GetDefaultAsyncWaiter()); | |
| 34 } | |
| 35 | |
| 36 bool Graphics3DResource::IsBoundGraphics() const { | |
| 37 PluginInstance* plugin_instance = | |
| 38 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); | |
| 39 return plugin_instance && plugin_instance->IsBoundGraphics(pp_resource()); | |
| 40 } | |
| 41 | |
| 42 void Graphics3DResource::BindGraphics() { | |
| 43 MojoGLES2MakeCurrent(context_); | |
| 44 } | |
| 45 | |
| 46 ppapi::thunk::PPB_Graphics3D_API* Graphics3DResource::AsPPB_Graphics3D_API() { | |
| 47 return this; | |
| 48 } | |
| 49 | |
| 50 int32_t Graphics3DResource::GetAttribs(int32_t attrib_list[]) { | |
| 51 NOTIMPLEMENTED(); | |
| 52 return PP_ERROR_FAILED; | |
| 53 } | |
| 54 | |
| 55 int32_t Graphics3DResource::SetAttribs(const int32_t attrib_list[]) { | |
| 56 NOTIMPLEMENTED(); | |
| 57 return PP_ERROR_FAILED; | |
| 58 } | |
| 59 | |
| 60 int32_t Graphics3DResource::GetError() { | |
| 61 NOTIMPLEMENTED(); | |
| 62 return PP_ERROR_FAILED; | |
| 63 } | |
| 64 | |
| 65 int32_t Graphics3DResource::ResizeBuffers(int32_t width, int32_t height) { | |
| 66 NOTIMPLEMENTED(); | |
| 67 return PP_ERROR_FAILED; | |
| 68 } | |
| 69 | |
| 70 int32_t Graphics3DResource::SwapBuffers( | |
| 71 scoped_refptr<ppapi::TrackedCallback> callback) { | |
| 72 if (!IsBoundGraphics()) | |
| 73 return PP_ERROR_FAILED; | |
| 74 | |
| 75 MojoGLES2SwapBuffers(); | |
| 76 return PP_OK; | |
| 77 } | |
| 78 | |
| 79 int32_t Graphics3DResource::GetAttribMaxValue(int32_t attribute, | |
| 80 int32_t* value) { | |
| 81 NOTIMPLEMENTED(); | |
| 82 return PP_ERROR_FAILED; | |
| 83 } | |
| 84 | |
| 85 PP_Bool Graphics3DResource::SetGetBuffer(int32_t shm_id) { | |
| 86 NOTIMPLEMENTED(); | |
| 87 return PP_FALSE; | |
| 88 } | |
| 89 | |
| 90 scoped_refptr<gpu::Buffer> Graphics3DResource::CreateTransferBuffer( | |
| 91 uint32_t size, | |
| 92 int32* id) { | |
| 93 NOTIMPLEMENTED(); | |
| 94 return NULL; | |
| 95 } | |
| 96 | |
| 97 PP_Bool Graphics3DResource::DestroyTransferBuffer(int32_t id) { | |
| 98 NOTIMPLEMENTED(); | |
| 99 return PP_FALSE; | |
| 100 } | |
| 101 | |
| 102 PP_Bool Graphics3DResource::Flush(int32_t put_offset) { | |
| 103 NOTIMPLEMENTED(); | |
| 104 return PP_FALSE; | |
| 105 } | |
| 106 | |
| 107 gpu::CommandBuffer::State Graphics3DResource::WaitForTokenInRange(int32_t start, | |
| 108 int32_t end) { | |
| 109 NOTIMPLEMENTED(); | |
| 110 return GetErrorState(); | |
| 111 } | |
| 112 | |
| 113 gpu::CommandBuffer::State Graphics3DResource::WaitForGetOffsetInRange( | |
| 114 int32_t start, int32_t end) { | |
| 115 NOTIMPLEMENTED(); | |
| 116 return GetErrorState(); | |
| 117 } | |
| 118 | |
| 119 void* Graphics3DResource::MapTexSubImage2DCHROMIUM(GLenum target, | |
| 120 GLint level, | |
| 121 GLint xoffset, | |
| 122 GLint yoffset, | |
| 123 GLsizei width, | |
| 124 GLsizei height, | |
| 125 GLenum format, | |
| 126 GLenum type, | |
| 127 GLenum access) { | |
| 128 NOTIMPLEMENTED(); | |
| 129 return NULL; | |
| 130 } | |
| 131 | |
| 132 void Graphics3DResource::UnmapTexSubImage2DCHROMIUM(const void* mem) { | |
| 133 NOTIMPLEMENTED(); | |
| 134 } | |
| 135 | |
| 136 uint32_t Graphics3DResource::InsertSyncPoint() { | |
| 137 NOTIMPLEMENTED(); | |
| 138 return 0; | |
| 139 } | |
| 140 | |
| 141 uint32_t Graphics3DResource::InsertFutureSyncPoint() { | |
| 142 NOTIMPLEMENTED(); | |
| 143 return 0; | |
| 144 } | |
| 145 | |
| 146 void Graphics3DResource::RetireSyncPoint(uint32_t sync_point) { | |
| 147 NOTIMPLEMENTED(); | |
| 148 } | |
| 149 | |
| 150 Graphics3DResource::~Graphics3DResource() { | |
| 151 MojoGLES2DestroyContext(context_); | |
| 152 } | |
| 153 | |
| 154 void Graphics3DResource::ContextLostThunk(void* closure) { | |
| 155 static_cast<Graphics3DResource*>(closure)->ContextLost(); | |
| 156 } | |
| 157 | |
| 158 void Graphics3DResource::ContextLost() { | |
| 159 PluginInstance* plugin_instance = | |
| 160 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); | |
| 161 if (plugin_instance) | |
| 162 plugin_instance->Graphics3DContextLost(); | |
| 163 } | |
| 164 | |
| 165 } // namespace examples | |
| 166 } // namespace mojo | |
| OLD | NEW |