Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrSurface.h" | 8 #include "GrSurface.h" |
| 9 #include "GrSurfacePriv.h" | 9 #include "GrSurfacePriv.h" |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 const void** data, | 85 const void** data, |
| 86 size_t* rowBytes) { | 86 size_t* rowBytes) { |
| 87 return adjust_params<const void>(surfaceWidth, surfaceHeight, bpp, left, top , width, height, | 87 return adjust_params<const void>(surfaceWidth, surfaceHeight, bpp, left, top , width, height, |
| 88 data, rowBytes); | 88 data, rowBytes); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 ////////////////////////////////////////////////////////////////////////////// | 92 ////////////////////////////////////////////////////////////////////////////// |
| 93 | 93 |
| 94 bool GrSurface::writePixels(int left, int top, int width, int height, | 94 bool GrSurface::writePixels(int left, int top, int width, int height, |
| 95 GrPixelConfig config, const void* buffer, size_t row Bytes, | 95 GrPixelConfig config, const SkTArray<SkMipMapLevel>& texels, |
| 96 uint32_t pixelOpsFlags) { | 96 uint32_t pixelOpsFlags) { |
| 97 // go through context so that all necessary flushing occurs | 97 // go through context so that all necessary flushing occurs |
| 98 GrContext* context = this->getContext(); | 98 GrContext* context = this->getContext(); |
| 99 if (nullptr == context) { | 99 if (nullptr == context) { |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 return context->writeSurfacePixels(this, left, top, width, height, config, b uffer, rowBytes, | 102 return context->writeSurfacePixels(this, left, top, width, height, config, t exels, |
| 103 pixelOpsFlags); | 103 pixelOpsFlags); |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool GrSurface::writePixels(int left, int top, int width, int height, | |
| 107 GrPixelConfig config, const void* buffer, size_t row Bytes, | |
| 108 uint32_t pixelOpsFlags) { | |
| 109 if (width < 0 || height < 0) { | |
|
bsalomon
2015/09/30 18:01:29
<= 0?
cblume
2015/10/08 09:27:57
Done.
| |
| 110 return nullptr; | |
|
bsalomon
2015/09/30 18:01:29
false rather than nullptr
cblume
2015/10/08 09:27:57
Done.
| |
| 111 } | |
| 112 const uint32_t baseLevelWidth = width; | |
| 113 const uint32_t baseLevelHeight = height; | |
| 114 | |
| 115 SkMipMapLevel level(buffer, rowBytes, baseLevelWidth, baseLevelHeight); | |
|
bsalomon
2015/09/30 18:01:29
This doesn't copy the buffer, right?
cblume
2015/10/08 09:27:57
Correct. SkMipMapLevel only does a shallow copy of
| |
| 116 const int levelCount = 1; | |
| 117 SkTArray<SkMipMapLevel> texels(levelCount); | |
| 118 texels.push_back(level); | |
| 119 | |
| 120 return this->writePixels(left, top, width, height, config, texels, pixelOpsF lags); | |
| 121 } | |
| 122 | |
| 106 bool GrSurface::readPixels(int left, int top, int width, int height, | 123 bool GrSurface::readPixels(int left, int top, int width, int height, |
| 107 GrPixelConfig config, void* buffer, size_t rowBytes, | 124 GrPixelConfig config, void* buffer, size_t rowBytes, |
| 108 uint32_t pixelOpsFlags) { | 125 uint32_t pixelOpsFlags) { |
| 109 // go through context so that all necessary flushing occurs | 126 // go through context so that all necessary flushing occurs |
| 110 GrContext* context = this->getContext(); | 127 GrContext* context = this->getContext(); |
| 111 if (nullptr == context) { | 128 if (nullptr == context) { |
| 112 return false; | 129 return false; |
| 113 } | 130 } |
| 114 return context->readSurfacePixels(this, left, top, width, height, config, bu ffer, | 131 return context->readSurfacePixels(this, left, top, width, height, config, bu ffer, |
| 115 rowBytes, pixelOpsFlags); | 132 rowBytes, pixelOpsFlags); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 | 219 |
| 203 void GrSurface::onRelease() { | 220 void GrSurface::onRelease() { |
| 204 this->invokeReleaseProc(); | 221 this->invokeReleaseProc(); |
| 205 this->INHERITED::onRelease(); | 222 this->INHERITED::onRelease(); |
| 206 } | 223 } |
| 207 | 224 |
| 208 void GrSurface::onAbandon() { | 225 void GrSurface::onAbandon() { |
| 209 this->invokeReleaseProc(); | 226 this->invokeReleaseProc(); |
| 210 this->INHERITED::onAbandon(); | 227 this->INHERITED::onAbandon(); |
| 211 } | 228 } |
| OLD | NEW |