| 1 |
// Copyright 2019 Google LLC. |
| 2 |
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
| 3 |
#include "tools/fiddle/examples.h" |
| 4 |
REG_FIDDLE(Image_CrossContextTextureFromPixmap, 256, 64, false, 4) { |
| 5 |
void draw(SkCanvas * canvas) { |
| 6 |
auto dContext = GrAsDirectContext(canvas->recordingContext()); |
| 7 |
if (!dContext) { |
| 8 |
return; |
| 9 |
} |
| 10 |
|
| 11 |
SkPixmap pixmap; |
| 12 |
if (source.peekPixels(&pixmap)) { |
| 13 |
sk_sp<SkImage> image = SkImages::CrossContextTextureFromPixmap(dContext, pixmap, false); |
| 14 |
canvas->drawImage(image, 0, 0); |
| 15 |
} |
| 16 |
} |
| 17 |
} // END FIDDLE |