aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrGpu.cpp')
-rw-r--r--src/gpu/GrGpu.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index efd687d6a8..4e0464a4ce 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -98,7 +98,7 @@ static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget)
* @param isRT Indicates if the texture can be a render target.
*/
static bool check_texture_creation_params(const GrCaps& caps, const GrSurfaceDesc& desc,
- bool* isRT, const SkTArray<GrMipLevel>& texels) {
+ bool* isRT) {
if (!caps.isConfigTexturable(desc.fConfig)) {
return false;
}
@@ -124,12 +124,6 @@ static bool check_texture_creation_params(const GrCaps& caps, const GrSurfaceDes
return false;
}
}
-
- for (int i = 0; i < texels.count(); ++i) {
- if (!texels[i].fPixels) {
- return false;
- }
- }
return true;
}
@@ -139,7 +133,7 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
const GrCaps* caps = this->caps();
bool isRT = false;
- bool textureCreationParamsValid = check_texture_creation_params(*caps, desc, &isRT, texels);
+ bool textureCreationParamsValid = check_texture_creation_params(*caps, desc, &isRT);
if (!textureCreationParamsValid) {
return nullptr;
}
@@ -185,6 +179,17 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
return tex;
}
+GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const void* srcData, size_t rowBytes) {
+ GrMipLevel level;
+ level.fPixels = srcData;
+ level.fRowBytes = rowBytes;
+ SkSTArray<1, GrMipLevel> levels;
+ levels.push_back(level);
+
+ return this->createTexture(desc, budgeted, levels);
+}
+
GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
this->handleDirtyContext();
if (!this->caps()->isConfigTexturable(desc.fConfig)) {
@@ -386,11 +391,16 @@ bool GrGpu::writePixels(GrSurface* surface,
if (!surface) {
return false;
}
+ bool validMipDataFound = false;
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) {
- if (!texels[currentMipLevel].fPixels ) {
- return false;
+ if (texels[currentMipLevel].fPixels != nullptr) {
+ validMipDataFound = true;
+ break;
}
}
+ if (!validMipDataFound) {
+ return false;
+ }
this->handleDirtyContext();
if (this->onWritePixels(surface, left, top, width, height, config, texels)) {