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

Side by Side Diff: skia/public/interfaces/bitmap_skbitmap_struct_traits.cc

Issue 2253293002: Mojo C++ bindings: change the first template parameter of StructTraits and UnionTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@91_extra
Patch Set: rebase Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" 5 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 8
9 namespace { 9 namespace {
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 skia::mojom::ColorProfileType SkColorSpaceToMojo(SkColorSpace* cs) { 101 skia::mojom::ColorProfileType SkColorSpaceToMojo(SkColorSpace* cs) {
102 if (cs && cs->gammaCloseToSRGB()) 102 if (cs && cs->gammaCloseToSRGB())
103 return skia::mojom::ColorProfileType::SRGB; 103 return skia::mojom::ColorProfileType::SRGB;
104 return skia::mojom::ColorProfileType::LINEAR; 104 return skia::mojom::ColorProfileType::LINEAR;
105 } 105 }
106 106
107 } // namespace 107 } // namespace
108 108
109 // static 109 // static
110 bool StructTraits<skia::mojom::Bitmap, SkBitmap>::IsNull(const SkBitmap& b) { 110 bool StructTraits<skia::mojom::BitmapDataView, SkBitmap>::IsNull(
111 const SkBitmap& b) {
111 return b.isNull(); 112 return b.isNull();
112 } 113 }
113 114
114 // static 115 // static
115 void StructTraits<skia::mojom::Bitmap, SkBitmap>::SetToNull(SkBitmap* b) { 116 void StructTraits<skia::mojom::BitmapDataView, SkBitmap>::SetToNull(
117 SkBitmap* b) {
116 b->reset(); 118 b->reset();
117 } 119 }
118 120
119 // static 121 // static
120 skia::mojom::ColorType StructTraits<skia::mojom::Bitmap, SkBitmap>::color_type( 122 skia::mojom::ColorType StructTraits<skia::mojom::BitmapDataView,
121 const SkBitmap& b) { 123 SkBitmap>::color_type(const SkBitmap& b) {
122 return SkColorTypeToMojo(b.colorType()); 124 return SkColorTypeToMojo(b.colorType());
123 } 125 }
124 126
125 // static 127 // static
126 skia::mojom::AlphaType StructTraits<skia::mojom::Bitmap, SkBitmap>::alpha_type( 128 skia::mojom::AlphaType StructTraits<skia::mojom::BitmapDataView,
127 const SkBitmap& b) { 129 SkBitmap>::alpha_type(const SkBitmap& b) {
128 return SkAlphaTypeToMojo(b.alphaType()); 130 return SkAlphaTypeToMojo(b.alphaType());
129 } 131 }
130 132
131 // static 133 // static
132 skia::mojom::ColorProfileType 134 skia::mojom::ColorProfileType
133 StructTraits<skia::mojom::Bitmap, SkBitmap>::profile_type(const SkBitmap& b) { 135 StructTraits<skia::mojom::BitmapDataView, SkBitmap>::profile_type(
136 const SkBitmap& b) {
134 return SkColorSpaceToMojo(b.colorSpace()); 137 return SkColorSpaceToMojo(b.colorSpace());
135 } 138 }
136 139
137 // static 140 // static
138 uint32_t StructTraits<skia::mojom::Bitmap, SkBitmap>::width(const SkBitmap& b) { 141 uint32_t StructTraits<skia::mojom::BitmapDataView, SkBitmap>::width(
142 const SkBitmap& b) {
139 return b.width() < 0 ? 0 : static_cast<uint32_t>(b.width()); 143 return b.width() < 0 ? 0 : static_cast<uint32_t>(b.width());
140 } 144 }
141 145
142 // static 146 // static
143 uint32_t StructTraits<skia::mojom::Bitmap, SkBitmap>::height( 147 uint32_t StructTraits<skia::mojom::BitmapDataView, SkBitmap>::height(
144 const SkBitmap& b) { 148 const SkBitmap& b) {
145 return b.height() < 0 ? 0 : static_cast<uint32_t>(b.height()); 149 return b.height() < 0 ? 0 : static_cast<uint32_t>(b.height());
146 } 150 }
147 151
148 // static 152 // static
149 BitmapBuffer StructTraits<skia::mojom::Bitmap, SkBitmap>::pixel_data( 153 BitmapBuffer StructTraits<skia::mojom::BitmapDataView, SkBitmap>::pixel_data(
150 const SkBitmap& b) { 154 const SkBitmap& b) {
151 return {b.getSize(), b.getSize(), static_cast<uint8_t*>(b.getPixels())}; 155 return {b.getSize(), b.getSize(), static_cast<uint8_t*>(b.getPixels())};
152 } 156 }
153 157
154 // static 158 // static
155 bool StructTraits<skia::mojom::Bitmap, SkBitmap>::Read( 159 bool StructTraits<skia::mojom::BitmapDataView, SkBitmap>::Read(
156 skia::mojom::BitmapDataView data, 160 skia::mojom::BitmapDataView data,
157 SkBitmap* b) { 161 SkBitmap* b) {
158 // TODO: Ensure width and height are reasonable, eg. <= kMaxBitmapSize? 162 // TODO: Ensure width and height are reasonable, eg. <= kMaxBitmapSize?
159 *b = SkBitmap(); 163 *b = SkBitmap();
160 if (!b->tryAllocPixels(SkImageInfo::Make( 164 if (!b->tryAllocPixels(SkImageInfo::Make(
161 data.width(), data.height(), MojoColorTypeToSk(data.color_type()), 165 data.width(), data.height(), MojoColorTypeToSk(data.color_type()),
162 MojoAlphaTypeToSk(data.alpha_type()), 166 MojoAlphaTypeToSk(data.alpha_type()),
163 MojoProfileTypeToSk(data.profile_type())))) { 167 MojoProfileTypeToSk(data.profile_type())))) {
164 return false; 168 return false;
165 } 169 }
(...skipping 13 matching lines...) Expand all
179 BitmapBuffer bitmap_buffer = {0, b->getSize(), 183 BitmapBuffer bitmap_buffer = {0, b->getSize(),
180 static_cast<uint8_t*>(b->getPixels())}; 184 static_cast<uint8_t*>(b->getPixels())};
181 if (!data.ReadPixelData(&bitmap_buffer) || bitmap_buffer.size != b->getSize()) 185 if (!data.ReadPixelData(&bitmap_buffer) || bitmap_buffer.size != b->getSize())
182 return false; 186 return false;
183 187
184 b->notifyPixelsChanged(); 188 b->notifyPixelsChanged();
185 return true; 189 return true;
186 } 190 }
187 191
188 // static 192 // static
189 void* StructTraits<skia::mojom::Bitmap, SkBitmap>::SetUpContext( 193 void* StructTraits<skia::mojom::BitmapDataView, SkBitmap>::SetUpContext(
190 const SkBitmap& b) { 194 const SkBitmap& b) {
191 b.lockPixels(); 195 b.lockPixels();
192 return nullptr; 196 return nullptr;
193 } 197 }
194 198
195 // static 199 // static
196 void StructTraits<skia::mojom::Bitmap, SkBitmap>::TearDownContext( 200 void StructTraits<skia::mojom::BitmapDataView, SkBitmap>::TearDownContext(
197 const SkBitmap& b, 201 const SkBitmap& b,
198 void* context) { 202 void* context) {
199 b.unlockPixels(); 203 b.unlockPixels();
200 } 204 }
201 205
202 } // namespace mojo 206 } // namespace mojo
OLDNEW
« no previous file with comments | « skia/public/interfaces/bitmap_skbitmap_struct_traits.h ('k') | skia/public/interfaces/image_filter_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698