/// /// Function which computes 6 view matrix to get the cube projection from a looak position /// @return a vector of 6 position /// std::vector<glm::mat4x4> CGBuffer::getViewProjMatrices(const glm::vec3 & vCenter, const glm::vec3 & vAtPosition, const glm::vec3 & vUpCenter) { std::vector<glm::mat4x4> matrices(6); glm::vec3 vDistance = vAtPosition - vCenter; glm::vec3 vTemp, pZPositive, pYPositive; float lenght; matrices[0] = glm::lookAt(vCenter, vAtPosition, -vUpCenter); pZPositive = vCenter - vDistance; matrices[1] = glm::lookAt(vCenter , pZPositive, -vUpCenter); //negative X lenght = glm::length(vDistance); vTemp = glm::cross(glm::normalize(vDistance), vUpCenter) * lenght; matrices[2] = glm::lookAt(vCenter , vCenter + vTemp, -glm::cross(glm::normalize(vTemp), glm::normalize(vDistance))); matrices[3] = glm::lookAt(vCenter , vCenter - vTemp, -glm::cross(glm::normalize(vTemp), glm::normalize(vDistance))); //negative Y glm::vec3 value = glm::cross(glm::normalize(vDistance), vUpCenter); pYPositive = glm::cross(glm::normalize(vDistance), value); matrices[4] = glm::lookAt(vCenter , vCenter + pYPositive, glm::normalize(vDistance)); matrices[5] = glm::lookAt(vCenter , vCenter - pYPositive, -glm::normalize(vDistance)); std::vector<glm::mat4x4> mSorted(6); //sorting according to the GL_TEXTURE_CUBE_MAP mSorted[0] = matrices[2]; mSorted[1] = matrices[3]; mSorted[2] = matrices[5]; mSorted[3] = matrices[4]; mSorted[4] = matrices[1]; mSorted[5] = matrices[0]; return mSorted; }
void GroupImpl::updateMatrices( ) { dp::util::ProfileEntry p("cull::updateMatrices"); if ( m_matricesChanged ) { if ( ! m_matricesBuffer ) { m_matricesBuffer = dp::gl::Buffer::create(dp::gl::Buffer::CORE, GL_STATIC_DRAW, GL_SHADER_STORAGE_BUFFER); } // copy over matrices m_matricesBuffer->setSize(getMatricesCount() * sizeof( dp::math::Mat44f )); dp::gl::MappedBuffer<dp::math::Mat44f> matrices( m_matricesBuffer, GL_MAP_WRITE_BIT ); char const* basePtr = reinterpret_cast<char const*>(getMatrices()); for ( size_t index = 0; index < getMatricesCount(); ++index ) { dp::math::Mat44f const& modelView = reinterpret_cast<dp::math::Mat44f const&>(*(basePtr + index * getMatricesStride())); matrices[index] = modelView; } m_matricesChanged = false; } else { struct MatrixUpdater { MatrixUpdater( char const* matricesInBasePtr, size_t matricesInStride ) : m_matricesInBasePtr( matricesInBasePtr ) , m_matricesInStride( matricesInStride ) { } void operator()( size_t index ) { glBufferSubData( GL_SHADER_STORAGE_BUFFER, index * sizeof(dp::math::Mat44f), sizeof(dp::math::Mat44f), m_matricesInBasePtr + index * m_matricesInStride ); } private: char const* m_matricesInBasePtr; size_t m_matricesInStride; }; bind( GL_SHADER_STORAGE_BUFFER, m_matricesBuffer ); MatrixUpdater matrixUpdater( reinterpret_cast<char const*>(getMatrices()), getMatricesStride() ); m_dirtyMatrices.traverseBits( matrixUpdater ); } m_dirtyMatrices.clear(); }
size_t SkPictureRecord::size() const { size_t result = 0; size_t sizeData; bitmaps(&sizeData); result += sizeData; matrices(&sizeData); result += sizeData; paints(&sizeData); result += sizeData; paths(&sizeData); result += sizeData; pictures(&sizeData); result += sizeData; regions(&sizeData); result += sizeData; result += streamlen(); return result; }
void ScatterResidual<PHX::MyTraits::Jacobian, Traits>:: evaluateFields(typename Traits::EvalData workset) { std::vector<Element_Linear2D>::iterator element = workset.begin; std::size_t cell = 0; for (; element != workset.end; ++element,++cell) { // Sum element residual and Jacobian into global residual, Jacobian // Loop over nodes in element int row, col; int lrow, lcol; for (int node_row = 0; node_row < num_nodes; node_row++) { int row_dim; int num_block_entries; int* block_indices; Jac->BeginExtractMyBlockRowView(Jac->LRID(element->globalNodeId(node_row)),row_dim, num_block_entries,block_indices); std::vector<Epetra_SerialDenseMatrix*> matrices(num_block_entries); for (std::size_t i = 0; i < matrices.size(); ++i) Jac->ExtractEntryView(matrices[i]); // Loop over equations per node for (int eq_row = 0; eq_row < num_eq; eq_row++) { lrow = num_eq * node_row + eq_row; // Global row row = static_cast<int>( f->Map().LID(element->globalNodeId(node_row)) * num_eq + eq_row); // Sum residual if (f != Teuchos::null) //f->SumIntoGlobalValue(row, 0, val[eq_row](cell,node_row).val()); (*f)[row] += val[eq_row](cell,node_row).val(); // std::cout << "val[" << eq_row << "](" << cell << "," << node_row << ") = " // << val[eq_row](cell,node_row).val() << std::endl; // Check derivative array is nonzero if (val[eq_row](cell,node_row).hasFastAccess()) { // Loop over nodes in element for (int node_col=0; node_col<num_nodes; node_col++){ // Loop over equations per node for (int eq_col=0; eq_col<num_eq; eq_col++) { lcol = num_eq * node_col + eq_col; // Global column col = static_cast<int>(Jac->LCID(element->globalNodeId(node_col)) * num_eq + eq_col); // Sum Jacobian Epetra_SerialDenseMatrix* block = 0; for (int i = 0; i < num_block_entries; ++i) { if ( block_indices[i] == (Jac->LCID(element->globalNodeId(node_col))) ) block = matrices[i]; } TEUCHOS_TEST_FOR_EXCEPTION(block == 0, std::logic_error,"Failed to find block column index for this entry!"); (*block)(eq_row,eq_col) += val[eq_row](cell,node_row).fastAccessDx(lcol); // Jac->SumIntoGlobalValues(row, 1, // &(val[eq_row](cell,node_row).fastAccessDx(lcol)), // &col); } // column equations } // column nodes } // has fast access } // row equations } // row node } // element }
void SkPicturePlayback::handleOp(SkReadBuffer* reader, DrawType op, uint32_t size, SkCanvas* canvas, const SkMatrix& initialMatrix) { #define BREAK_ON_READ_ERROR(r) if (!r->isValid()) break switch (op) { case NOOP: { SkASSERT(size >= 4); reader->skip(size - 4); } break; case FLUSH: canvas->flush(); break; case CLIP_PATH: { const SkPath& path = fPictureData->getPath(reader); uint32_t packed = reader->readInt(); SkClipOp clipOp = ClipParams_unpackRegionOp(reader, packed); bool doAA = ClipParams_unpackDoAA(packed); size_t offsetToRestore = reader->readInt(); validate_offsetToRestore(reader, offsetToRestore); BREAK_ON_READ_ERROR(reader); canvas->clipPath(path, clipOp, doAA); if (canvas->isClipEmpty() && offsetToRestore) { reader->skip(offsetToRestore - reader->offset()); } } break; case CLIP_REGION: { SkRegion region; reader->readRegion(®ion); uint32_t packed = reader->readInt(); SkClipOp clipOp = ClipParams_unpackRegionOp(reader, packed); size_t offsetToRestore = reader->readInt(); validate_offsetToRestore(reader, offsetToRestore); BREAK_ON_READ_ERROR(reader); canvas->clipRegion(region, clipOp); if (canvas->isClipEmpty() && offsetToRestore) { reader->skip(offsetToRestore - reader->offset()); } } break; case CLIP_RECT: { SkRect rect; reader->readRect(&rect); uint32_t packed = reader->readInt(); SkClipOp clipOp = ClipParams_unpackRegionOp(reader, packed); bool doAA = ClipParams_unpackDoAA(packed); size_t offsetToRestore = reader->readInt(); validate_offsetToRestore(reader, offsetToRestore); BREAK_ON_READ_ERROR(reader); canvas->clipRect(rect, clipOp, doAA); if (canvas->isClipEmpty() && offsetToRestore) { reader->skip(offsetToRestore - reader->offset()); } } break; case CLIP_RRECT: { SkRRect rrect; reader->readRRect(&rrect); uint32_t packed = reader->readInt(); SkClipOp clipOp = ClipParams_unpackRegionOp(reader, packed); bool doAA = ClipParams_unpackDoAA(packed); size_t offsetToRestore = reader->readInt(); validate_offsetToRestore(reader, offsetToRestore); BREAK_ON_READ_ERROR(reader); canvas->clipRRect(rrect, clipOp, doAA); if (canvas->isClipEmpty() && offsetToRestore) { reader->skip(offsetToRestore - reader->offset()); } } break; case PUSH_CULL: break; // Deprecated, safe to ignore both push and pop. case POP_CULL: break; case CONCAT: { SkMatrix matrix; reader->readMatrix(&matrix); BREAK_ON_READ_ERROR(reader); canvas->concat(matrix); break; } case DRAW_ANNOTATION: { SkRect rect; reader->readRect(&rect); SkString key; reader->readString(&key); sk_sp<SkData> data = reader->readByteArrayAsData(); BREAK_ON_READ_ERROR(reader); SkASSERT(data); canvas->drawAnnotation(rect, key.c_str(), data.get()); } break; case DRAW_ARC: { const SkPaint* paint = fPictureData->getPaint(reader); SkRect rect; reader->readRect(&rect); SkScalar startAngle = reader->readScalar(); SkScalar sweepAngle = reader->readScalar(); int useCenter = reader->readInt(); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawArc(rect, startAngle, sweepAngle, SkToBool(useCenter), *paint); } } break; case DRAW_ATLAS: { const SkPaint* paint = fPictureData->getPaint(reader); const SkImage* atlas = fPictureData->getImage(reader); const uint32_t flags = reader->readUInt(); const int count = reader->readUInt(); const SkRSXform* xform = (const SkRSXform*)reader->skip(count, sizeof(SkRSXform)); const SkRect* tex = (const SkRect*)reader->skip(count, sizeof(SkRect)); const SkColor* colors = nullptr; SkBlendMode mode = SkBlendMode::kDst; if (flags & DRAW_ATLAS_HAS_COLORS) { colors = (const SkColor*)reader->skip(count, sizeof(SkColor)); mode = (SkBlendMode)reader->readUInt(); } const SkRect* cull = nullptr; if (flags & DRAW_ATLAS_HAS_CULL) { cull = (const SkRect*)reader->skip(sizeof(SkRect)); } BREAK_ON_READ_ERROR(reader); canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); } break; case DRAW_CLEAR: { auto c = reader->readInt(); BREAK_ON_READ_ERROR(reader); canvas->clear(c); } break; case DRAW_DATA: { // This opcode is now dead, just need to skip it for backwards compatibility size_t length = reader->readInt(); (void)reader->skip(length); // skip handles padding the read out to a multiple of 4 } break; case DRAW_DRAWABLE: { auto* d = fPictureData->getDrawable(reader); BREAK_ON_READ_ERROR(reader); canvas->drawDrawable(d); } break; case DRAW_DRAWABLE_MATRIX: { SkMatrix matrix; reader->readMatrix(&matrix); SkDrawable* drawable = fPictureData->getDrawable(reader); BREAK_ON_READ_ERROR(reader); canvas->drawDrawable(drawable, &matrix); } break; case DRAW_DRRECT: { const SkPaint* paint = fPictureData->getPaint(reader); SkRRect outer, inner; reader->readRRect(&outer); reader->readRRect(&inner); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawDRRect(outer, inner, *paint); } } break; case DRAW_EDGEAA_QUAD: { SkRect rect; reader->readRect(&rect); SkCanvas::QuadAAFlags aaFlags = static_cast<SkCanvas::QuadAAFlags>(reader->read32()); SkColor color = reader->read32(); SkBlendMode blend = static_cast<SkBlendMode>(reader->read32()); bool hasClip = reader->readInt(); SkPoint* clip = nullptr; if (hasClip) { clip = (SkPoint*) reader->skip(4, sizeof(SkPoint)); } BREAK_ON_READ_ERROR(reader); canvas->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, color, blend); } break; case DRAW_EDGEAA_IMAGE_SET: { static const size_t kEntryReadSize = 4 * sizeof(uint32_t) + 2 * sizeof(SkRect) + sizeof(SkScalar); static const size_t kMatrixSize = 9 * sizeof(SkScalar); // != sizeof(SkMatrix) int cnt = reader->readInt(); if (!reader->validate(cnt >= 0)) { break; } const SkPaint* paint = fPictureData->getPaint(reader); SkCanvas::SrcRectConstraint constraint = static_cast<SkCanvas::SrcRectConstraint>(reader->readInt()); if (!reader->validate(SkSafeMath::Mul(cnt, kEntryReadSize) <= reader->available())) { break; } // Track minimum necessary clip points and matrices that must be provided to satisfy // the entries. int expectedClips = 0; int maxMatrixIndex = -1; SkAutoTArray<SkCanvas::ImageSetEntry> set(cnt); for (int i = 0; i < cnt && reader->isValid(); ++i) { set[i].fImage = sk_ref_sp(fPictureData->getImage(reader)); reader->readRect(&set[i].fSrcRect); reader->readRect(&set[i].fDstRect); set[i].fMatrixIndex = reader->readInt(); set[i].fAlpha = reader->readScalar(); set[i].fAAFlags = reader->readUInt(); set[i].fHasClip = reader->readInt(); expectedClips += set[i].fHasClip ? 1 : 0; if (set[i].fMatrixIndex > maxMatrixIndex) { maxMatrixIndex = set[i].fMatrixIndex; } } int dstClipCount = reader->readInt(); SkPoint* dstClips = nullptr; if (!reader->validate(expectedClips <= dstClipCount)) { // Entries request more dstClip points than are provided in the buffer break; } else if (dstClipCount > 0) { dstClips = (SkPoint*) reader->skip(dstClipCount, sizeof(SkPoint)); if (dstClips == nullptr) { // Not enough bytes remaining so the reader has been invalidated break; } } int matrixCount = reader->readInt(); if (!reader->validate((maxMatrixIndex + 1) <= matrixCount) || !reader->validate( SkSafeMath::Mul(matrixCount, kMatrixSize) <= reader->available())) { // Entries access out-of-bound matrix indices, given provided matrices or // there aren't enough bytes to provide that many matrices break; } SkTArray<SkMatrix> matrices(matrixCount); for (int i = 0; i < matrixCount && reader->isValid(); ++i) { reader->readMatrix(&matrices.push_back()); } BREAK_ON_READ_ERROR(reader); canvas->experimental_DrawEdgeAAImageSet(set.get(), cnt, dstClips, matrices.begin(), paint, constraint); } break; case DRAW_IMAGE: { const SkPaint* paint = fPictureData->getPaint(reader); const SkImage* image = fPictureData->getImage(reader); SkPoint loc; reader->readPoint(&loc); BREAK_ON_READ_ERROR(reader); canvas->drawImage(image, loc.fX, loc.fY, paint); } break; case DRAW_IMAGE_LATTICE: { const SkPaint* paint = fPictureData->getPaint(reader); const SkImage* image = fPictureData->getImage(reader); SkCanvas::Lattice lattice; (void)SkCanvasPriv::ReadLattice(*reader, &lattice); const SkRect* dst = reader->skipT<SkRect>(); BREAK_ON_READ_ERROR(reader); canvas->drawImageLattice(image, lattice, *dst, paint); } break; case DRAW_IMAGE_NINE: { const SkPaint* paint = fPictureData->getPaint(reader); const SkImage* image = fPictureData->getImage(reader); SkIRect center; reader->readIRect(¢er); SkRect dst; reader->readRect(&dst); BREAK_ON_READ_ERROR(reader); canvas->drawImageNine(image, center, dst, paint); } break; case DRAW_IMAGE_RECT: { const SkPaint* paint = fPictureData->getPaint(reader); const SkImage* image = fPictureData->getImage(reader); SkRect storage; const SkRect* src = get_rect_ptr(reader, &storage); // may be null SkRect dst; reader->readRect(&dst); // required // DRAW_IMAGE_RECT_STRICT assumes this constraint, and doesn't store it SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint; if (DRAW_IMAGE_RECT == op) { // newer op-code stores the constraint explicitly constraint = (SkCanvas::SrcRectConstraint)reader->readInt(); } BREAK_ON_READ_ERROR(reader); canvas->legacy_drawImageRect(image, src, dst, paint, constraint); } break; case DRAW_OVAL: { const SkPaint* paint = fPictureData->getPaint(reader); SkRect rect; reader->readRect(&rect); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawOval(rect, *paint); } } break; case DRAW_PAINT: { const SkPaint* paint = fPictureData->getPaint(reader); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawPaint(*paint); } } break; case DRAW_BEHIND_PAINT: { const SkPaint* paint = fPictureData->getPaint(reader); BREAK_ON_READ_ERROR(reader); if (paint) { SkCanvasPriv::DrawBehind(canvas, *paint); } } break; case DRAW_PATCH: { const SkPaint* paint = fPictureData->getPaint(reader); const SkPoint* cubics = (const SkPoint*)reader->skip(SkPatchUtils::kNumCtrlPts, sizeof(SkPoint)); uint32_t flag = reader->readInt(); const SkColor* colors = nullptr; if (flag & DRAW_VERTICES_HAS_COLORS) { colors = (const SkColor*)reader->skip(SkPatchUtils::kNumCorners, sizeof(SkColor)); } const SkPoint* texCoords = nullptr; if (flag & DRAW_VERTICES_HAS_TEXS) { texCoords = (const SkPoint*)reader->skip(SkPatchUtils::kNumCorners, sizeof(SkPoint)); } SkBlendMode bmode = SkBlendMode::kModulate; if (flag & DRAW_VERTICES_HAS_XFER) { unsigned mode = reader->readInt(); if (mode <= (unsigned)SkBlendMode::kLastMode) { bmode = (SkBlendMode)mode; } } BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawPatch(cubics, colors, texCoords, bmode, *paint); } } break; case DRAW_PATH: { const SkPaint* paint = fPictureData->getPaint(reader); const auto& path = fPictureData->getPath(reader); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawPath(path, *paint); } } break; case DRAW_PICTURE: { const auto* pic = fPictureData->getPicture(reader); BREAK_ON_READ_ERROR(reader); canvas->drawPicture(pic); } break; case DRAW_PICTURE_MATRIX_PAINT: { const SkPaint* paint = fPictureData->getPaint(reader); SkMatrix matrix; reader->readMatrix(&matrix); const SkPicture* pic = fPictureData->getPicture(reader); BREAK_ON_READ_ERROR(reader); canvas->drawPicture(pic, &matrix, paint); } break; case DRAW_POINTS: { const SkPaint* paint = fPictureData->getPaint(reader); SkCanvas::PointMode mode = (SkCanvas::PointMode)reader->readInt(); size_t count = reader->readInt(); const SkPoint* pts = (const SkPoint*)reader->skip(count, sizeof(SkPoint)); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawPoints(mode, count, pts, *paint); } } break; case DRAW_RECT: { const SkPaint* paint = fPictureData->getPaint(reader); SkRect rect; reader->readRect(&rect); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawRect(rect, *paint); } } break; case DRAW_REGION: { const SkPaint* paint = fPictureData->getPaint(reader); SkRegion region; reader->readRegion(®ion); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawRegion(region, *paint); } } break; case DRAW_RRECT: { const SkPaint* paint = fPictureData->getPaint(reader); SkRRect rrect; reader->readRRect(&rrect); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawRRect(rrect, *paint); } } break; case DRAW_SHADOW_REC: { const auto& path = fPictureData->getPath(reader); SkDrawShadowRec rec; reader->readPoint3(&rec.fZPlaneParams); reader->readPoint3(&rec.fLightPos); rec.fLightRadius = reader->readScalar(); if (reader->isVersionLT(SkReadBuffer::kTwoColorDrawShadow_Version)) { SkScalar ambientAlpha = reader->readScalar(); SkScalar spotAlpha = reader->readScalar(); SkColor color = reader->read32(); rec.fAmbientColor = SkColorSetA(color, SkColorGetA(color)*ambientAlpha); rec.fSpotColor = SkColorSetA(color, SkColorGetA(color)*spotAlpha); } else { rec.fAmbientColor = reader->read32(); rec.fSpotColor = reader->read32(); } rec.fFlags = reader->read32(); BREAK_ON_READ_ERROR(reader); canvas->private_draw_shadow_rec(path, rec); } break; case DRAW_TEXT_BLOB: { const SkPaint* paint = fPictureData->getPaint(reader); const SkTextBlob* blob = fPictureData->getTextBlob(reader); SkScalar x = reader->readScalar(); SkScalar y = reader->readScalar(); BREAK_ON_READ_ERROR(reader); if (paint) { canvas->drawTextBlob(blob, x, y, *paint); } } break; case DRAW_VERTICES_OBJECT: { const SkPaint* paint = fPictureData->getPaint(reader); const SkVertices* vertices = fPictureData->getVertices(reader); const int boneCount = reader->readInt(); const SkVertices::Bone* bones = boneCount ? (const SkVertices::Bone*) reader->skip(boneCount, sizeof(SkVertices::Bone)) : nullptr; SkBlendMode bmode = reader->read32LE(SkBlendMode::kLastMode); BREAK_ON_READ_ERROR(reader); if (paint && vertices) { canvas->drawVertices(vertices, bones, boneCount, bmode, *paint); } } break; case RESTORE: canvas->restore(); break; case ROTATE: { auto deg = reader->readScalar(); canvas->rotate(deg); } break; case SAVE: canvas->save(); break; case SAVE_BEHIND: { uint32_t flags = reader->readInt(); const SkRect* subset = nullptr; SkRect storage; if (flags & SAVEBEHIND_HAS_SUBSET) { reader->readRect(&storage); subset = &storage; } SkCanvasPriv::SaveBehind(canvas, subset); } break; case SAVE_LAYER_SAVEFLAGS_DEPRECATED: { SkRect storage; const SkRect* boundsPtr = get_rect_ptr(reader, &storage); const SkPaint* paint = fPictureData->getPaint(reader); auto flags = SkCanvasPriv::LegacySaveFlagsToSaveLayerFlags(reader->readInt()); BREAK_ON_READ_ERROR(reader); canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, flags)); } break; case SAVE_LAYER_SAVELAYERREC: { SkCanvas::SaveLayerRec rec(nullptr, nullptr, nullptr, nullptr, nullptr, 0); SkMatrix clipMatrix; const uint32_t flatFlags = reader->readInt(); SkRect bounds; if (flatFlags & SAVELAYERREC_HAS_BOUNDS) { reader->readRect(&bounds); rec.fBounds = &bounds; } if (flatFlags & SAVELAYERREC_HAS_PAINT) { rec.fPaint = fPictureData->getPaint(reader); } if (flatFlags & SAVELAYERREC_HAS_BACKDROP) { if (const auto* paint = fPictureData->getPaint(reader)) { rec.fBackdrop = paint->getImageFilter(); } } if (flatFlags & SAVELAYERREC_HAS_FLAGS) { rec.fSaveLayerFlags = reader->readInt(); } if (flatFlags & SAVELAYERREC_HAS_CLIPMASK) { rec.fClipMask = fPictureData->getImage(reader); } if (flatFlags & SAVELAYERREC_HAS_CLIPMATRIX) { reader->readMatrix(&clipMatrix); rec.fClipMatrix = &clipMatrix; } BREAK_ON_READ_ERROR(reader); canvas->saveLayer(rec); } break; case SCALE: { SkScalar sx = reader->readScalar(); SkScalar sy = reader->readScalar(); canvas->scale(sx, sy); } break; case SET_MATRIX: { SkMatrix matrix; reader->readMatrix(&matrix); matrix.postConcat(initialMatrix); canvas->setMatrix(matrix); } break; case SKEW: { SkScalar sx = reader->readScalar(); SkScalar sy = reader->readScalar(); canvas->skew(sx, sy); } break; case TRANSLATE: { SkScalar dx = reader->readScalar(); SkScalar dy = reader->readScalar(); canvas->translate(dx, dy); } break; default: reader->validate(false); // unknown op break; } #undef BREAK_ON_READ_ERROR }