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

Side by Side Diff: src/gpu/vk/GrVkVertexBuffer.cpp

Issue 1718693002: Add vulkan files into skia repo. (Closed) Base URL: https://skia.googlesource.com/skia.git@merge
Patch Set: fix path Created 4 years, 10 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 | « src/gpu/vk/GrVkVertexBuffer.h ('k') | tests/VkClearTests.cpp » ('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 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrVkVertexBuffer.h"
9 #include "GrVkGpu.h"
10
11 GrVkVertexBuffer::GrVkVertexBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc,
12 const GrVkBuffer::Resource* bufferResource)
13 : INHERITED(gpu, desc.fSizeInBytes, desc.fDynamic, false)
14 , GrVkBuffer(desc, bufferResource) {
15 this->registerWithCache();
16 }
17
18 GrVkVertexBuffer* GrVkVertexBuffer::Create(GrVkGpu* gpu, size_t size, bool dynam ic) {
19 GrVkBuffer::Desc desc;
20 desc.fDynamic = dynamic;
21 desc.fType = GrVkBuffer::kVertex_Type;
22 desc.fSizeInBytes = size;
23
24 const GrVkBuffer::Resource* bufferResource = GrVkBuffer::Create(gpu, desc);
25 if (!bufferResource) {
26 return nullptr;
27 }
28
29 GrVkVertexBuffer* buffer = new GrVkVertexBuffer(gpu, desc, bufferResource);
30 if (!buffer) {
31 bufferResource->unref(gpu);
32 }
33 return buffer;
34 }
35
36 void GrVkVertexBuffer::onRelease() {
37 if (!this->wasDestroyed()) {
38 this->vkRelease(this->getVkGpu());
39 }
40
41 INHERITED::onRelease();
42 }
43
44 void GrVkVertexBuffer::onAbandon() {
45 this->vkAbandon();
46 INHERITED::onAbandon();
47 }
48
49 void* GrVkVertexBuffer::onMap() {
50 if (!this->wasDestroyed()) {
51 return this->vkMap(this->getVkGpu());
52 } else {
53 return NULL;
54 }
55 }
56
57 void GrVkVertexBuffer::onUnmap() {
58 if (!this->wasDestroyed()) {
59 this->vkUnmap(this->getVkGpu());
60 }
61 }
62
63 bool GrVkVertexBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) {
64 if (!this->wasDestroyed()) {
65 return this->vkUpdateData(this->getVkGpu(), src, srcSizeInBytes);
66 } else {
67 return false;
68 }
69 }
70
71 GrVkGpu* GrVkVertexBuffer::getVkGpu() const {
72 SkASSERT(!this->wasDestroyed());
73 return static_cast<GrVkGpu*>(this->getGpu());
74 }
75
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkVertexBuffer.h ('k') | tests/VkClearTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698