forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update some of the dox code to GrDirectContext
If we're to remove GrContext all uses must go! Change-Id: I487a973004c4f080fc5802128770b417d54628e2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301981 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
- Loading branch information
Showing
10 changed files
with
85 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
#if 0 // Disabled until updated to use current API. | ||
// Copyright 2019 Google LLC. | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
#include "tools/fiddle/examples.h" | ||
// HASH=d093aad721261f421c4bef4a296aab48 | ||
REG_FIDDLE(Image_getBackendTexture, 256, 256, false, 3) { | ||
void draw(SkCanvas* canvas) { | ||
GrContext* grContext = canvas->getGrContext(); | ||
if (!grContext) { | ||
canvas->drawString("GPU only!", 20, 40, SkPaint()); | ||
SkFont font; | ||
SkPaint paint; | ||
|
||
GrRecordingContext* context = canvas->recordingContext(); | ||
if (!context) { | ||
canvas->drawString("GPU only!", 20, 40, font, paint); | ||
return; | ||
} | ||
sk_sp<SkImage> imageFromBackend = SkImage::MakeFromAdoptedTexture(grContext, backEndTexture, | ||
kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kOpaque_SkAlphaType); | ||
GrDirectContext* direct = context->asDirectContext(); | ||
if (!direct) { | ||
canvas->drawString("Direct context only!", 20, 40, font, paint); | ||
return; | ||
} | ||
|
||
sk_sp<SkImage> imageFromBackend = SkImage::MakeFromAdoptedTexture(direct, | ||
backEndTexture, | ||
kBottomLeft_GrSurfaceOrigin, | ||
kRGBA_8888_SkColorType, | ||
kOpaque_SkAlphaType); | ||
GrBackendTexture textureFromImage = imageFromBackend->getBackendTexture(false); | ||
if (!textureFromImage.isValid()) { | ||
return; | ||
} | ||
sk_sp<SkImage> imageFromTexture = SkImage::MakeFromAdoptedTexture(grContext, textureFromImage, | ||
kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kOpaque_SkAlphaType); | ||
sk_sp<SkImage> imageFromTexture = SkImage::MakeFromAdoptedTexture(direct, | ||
textureFromImage, | ||
kTopLeft_GrSurfaceOrigin, | ||
kRGBA_8888_SkColorType, | ||
kOpaque_SkAlphaType); | ||
canvas->drawImage(imageFromTexture, 0, 0); | ||
canvas->drawImage(imageFromBackend, 128, 128); | ||
} | ||
} // END FIDDLE | ||
#endif // Disabled until updated to use current API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
#if 0 // Disabled until updated to use current API. | ||
// Copyright 2019 Google LLC. | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
#include "tools/fiddle/examples.h" | ||
// HASH=d3aec071998f871809f515e58abb1b0e | ||
REG_FIDDLE(Surface_MakeFromBackendTexture, 256, 256, false, 3) { | ||
void draw(SkCanvas* canvas) { | ||
SkFont font(nullptr, 32); | ||
SkPaint paint; | ||
paint.setTextSize(32); | ||
GrContext* context = canvas->getGrContext(); | ||
|
||
GrRecordingContext* context = canvas->recordingContext(); | ||
if (!context) { | ||
canvas->drawString("GPU only!", 20, 40, paint); | ||
canvas->drawString("GPU only!", 20, 40, font, paint); | ||
return; | ||
} | ||
sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTexture(context, | ||
backEndTexture, kTopLeft_GrSurfaceOrigin, 0, | ||
kRGBA_8888_SkColorType, nullptr, nullptr); | ||
GrDirectContext* direct = context->asDirectContext(); | ||
if (!direct) { | ||
canvas->drawString("Direct Context only!", 20, 40, font, paint); | ||
return; | ||
} | ||
|
||
sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTexture(direct, | ||
backEndTexture, | ||
kTopLeft_GrSurfaceOrigin, | ||
0, | ||
kRGBA_8888_SkColorType, | ||
nullptr, | ||
nullptr, | ||
nullptr); | ||
auto surfaceCanvas = gpuSurface->getCanvas(); | ||
surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); | ||
surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint); | ||
sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); | ||
canvas->drawImage(image, 0, 0); | ||
} | ||
} // END FIDDLE | ||
#endif // Disabled until updated to use current API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
#if 0 // Disabled until updated to use current API. | ||
// Copyright 2019 Google LLC. | ||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. | ||
#include "tools/fiddle/examples.h" | ||
// HASH=5c7629c15e9ac93f098335e72560fa2e | ||
REG_FIDDLE(Surface_MakeRenderTarget_3, 256, 256, false, 0) { | ||
void draw(SkCanvas* canvas) { | ||
SkFont font(nullptr, 32); | ||
SkPaint paint; | ||
paint.setTextSize(32); | ||
GrContext* context = canvas->getGrContext(); | ||
auto context = canvas->recordingContext(); | ||
if (!context) { | ||
canvas->drawString("GPU only!", 20, 40, paint); | ||
canvas->drawString("GPU only!", 20, 40, font, paint); | ||
return; | ||
} | ||
SkImageInfo info = SkImageInfo::MakeN32(256, 64, kOpaque_SkAlphaType); | ||
auto gpuSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)); | ||
auto surfaceCanvas = gpuSurface->getCanvas(); | ||
surfaceCanvas->clear(SK_ColorWHITE); | ||
surfaceCanvas->drawString("GPU rocks!", 20, 40, paint); | ||
surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint); | ||
sk_sp<SkImage> image(gpuSurface->makeImageSnapshot()); | ||
canvas->drawImage(image, 0, 0); | ||
} | ||
} // END FIDDLE | ||
#endif // Disabled until updated to use current API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters