void UpdateTexture2( HContext _context, HTexture _handle, UINT32 _size, const void* _data ) { mxASSERT(_size > 0); mxASSERT_PTR(_data); DeviceContext* deviceContext = (DeviceContext*) _context.ptr; deviceContext->UpdateTexture2( _handle, _data, _size ); }
static void Render(HWND window) { if (!target) { auto device = Direct3D::CreateDevice(); target = factory.CreateDevice(device).CreateDeviceContext(); auto dxgi = device.GetDxgiFactory(); Dxgi::SwapChainDescription1 description; description.SwapEffect = Dxgi::SwapEffect::Discard; swapChain = dxgi.CreateSwapChainForHwnd(device, window, description); CreateDeviceSwapChainBitmap(swapChain, target); auto const dpi = factory.GetDesktopDpi(); target.SetDpi(dpi, dpi); CreateDeviceResources(); } target.BeginDraw(); Draw(); target.EndDraw(); auto const hr = swapChain.Present(); if (S_OK != hr && DXGI_STATUS_OCCLUDED != hr) { ReleaseDevice(); } }
void SetBlendState( HContext _context, HBlendState blendState, const float* blendFactor /*= NULL*/, UINT32 sampleMask /*= ~0*/ ) { DeviceContext* deviceContext = (DeviceContext*) _context.ptr; deviceContext->SetBlendState( blendState, blendFactor, sampleMask ); //tr.commands.WriteToken(RC_SET_BLEND_STATE); //tr.commands.Put(blendState); //tr.commands.AlignPointer<4>(); }
void DeviceContext::ShutdownCallback( _In_ WDFOBJECT Object ) { DeviceContext* deviceContext = DeviceGetContext(Object); deviceContext->Shutdown(); }
void SetRasterizerState( HContext _context, HRasterizerState rasterizerState ) { DeviceContext* deviceContext = (DeviceContext*) _context.ptr; deviceContext->SetRasterizerState( rasterizerState ); //tr.commands.WriteToken(RC_SET_RASTERIZER_STATE); //tr.commands.Put(rasterizerState); //tr.commands.AlignPointer<4>(); }
NTSTATUS DeviceContext::D0ExitCallback( _In_ WDFDEVICE Device, _In_ WDF_POWER_DEVICE_STATE TargetState ) { DeviceContext* deviceContext = DeviceGetContext(Device); return deviceContext->D0Exit(TargetState); }
static void CreateDeviceSwapChainBitmap(Dxgi::SwapChain const & swapChain, DeviceContext const & target) { auto props = BitmapProperties1(BitmapOptions::Target | BitmapOptions::CannotDraw, PixelFormat(Dxgi::Format::B8G8R8A8_UNORM, AlphaMode::Ignore)); target.SetTarget(target.CreateBitmapFromDxgiSurface(swapChain, props)); }
void DeviceContext::WriteNciPacketCallback( _In_ WDFDEVICE Device, _In_ WDFREQUEST Request ) { DeviceContext* deviceContext = DeviceGetContext(Device); deviceContext->WriteNciPacket(Request); }
NTSTATUS DeviceContext::D0EntryCallback( _In_ WDFDEVICE Device, _In_ WDF_POWER_DEVICE_STATE PreviousState ) { DeviceContext* deviceContext = DeviceGetContext(Device); return deviceContext->D0Entry(PreviousState); }
void SetDepthStencilState( HContext _context, HDepthStencilState depthStencilState, UINT8 stencilReference ) { DeviceContext* deviceContext = (DeviceContext*) _context.ptr; deviceContext->SetDepthStencilState( depthStencilState, stencilReference ); //tr.commands.WriteToken(RC_SET_DEPTH_STENCIL_STATE); //tr.commands.Put(depthStencilState); //tr.commands.Put(stencilReference); //tr.commands.AlignPointer<4>(); }
void DeviceContext::SequenceHandlerCallback( _In_ WDFDEVICE Device, _In_ NFC_CX_SEQUENCE Sequence, _In_ PFN_NFC_CX_SEQUENCE_COMPLETION_ROUTINE CompletionRoutine, _In_opt_ WDFCONTEXT CompletionContext ) { DeviceContext* deviceContext = DeviceGetContext(Device); deviceContext->SequenceHandler(Sequence, CompletionRoutine, CompletionContext); }
void DeviceContext::DeviceIoCallback( _In_ WDFDEVICE Device, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode ) { DeviceContext* deviceContext = DeviceGetContext(Device); deviceContext->DeviceIo(Request, OutputBufferLength, InputBufferLength, IoControlCode); }
void Submit( HContext _context, const DrawCall& batch ) { mxASSERT(batch.program.IsValid()); //mxASSERT(batch.inputLayout.IsValid()); mxASSERT(batch.topology != Topology::Undefined); mxASSERT(batch.vertexCount > 0); DeviceContext* deviceContext = (DeviceContext*) _context.ptr; deviceContext->SubmitBatch( batch ); //tr.commands.WriteToken(RC_DRAW_BATCH); //tr.commands.Put(batch); //tr.numBatches++; }
void UpdateBuffer( HContext _context, HBuffer _handle, UINT32 _size, const void* _data, UINT32 _start ) { mxASSERT(_size > 0); mxASSERT_PTR(_data); DeviceContext* deviceContext = (DeviceContext*) _context.ptr; deviceContext->UpdateBuffer( _handle, _start, _data, _size ); //tr.commands.WriteToken(CMD_UPDATE_BUFFER); //tr.commands.Put(handle); //tr.commands.Put(start); //tr.commands.Put(size); //tr.commands.AlignPointer<16>(); //tr.commands.Put(data, size); }
///////////////////////////////////////////////////////////////////////////////////////// // ThemedSkin::draw const //! Draws a standard button control //! //! \param[in,out] &btn - Button to be drawn //! \param[in,out] &dc - Output device context //! \param[in] const &rc - Drawing rectangle ///////////////////////////////////////////////////////////////////////////////////////// void draw(Button<ENC>& btn, DeviceContext& dc, const RectL& rc) const override { Theme theme(btn.handle(), L"Button"); // Determine state ::PUSHBUTTONSTATES state = PBS_NORMAL; if (!btn.Enabled) state = PBS_DISABLED; else if (btn.State == ButtonState::Pushed) //else if (args.State && OwnerDrawState::Selected) state = PBS_PRESSED; else if (btn.isMouseOver()) state = PBS_HOT; // Draw background theme.fill(dc, BP_PUSHBUTTON, state, rc); // Query content rect RectL rcContent = theme.content(dc, BP_CHECKBOX, state, rc); // Pressed: Offset drawing rect if (state == PBS_PRESSED) rcContent += PointL(1,1); // Draw icon if (btn.Icon.exists()) { RectL rcIcon = rcContent.arrange(Metrics::WindowIcon, {RectL::FromLeft,Metrics::WindowEdge.Width}, RectL::Centre); dc.draw(btn.Icon, rcIcon); } // Calculate text rectangle RectL rcText = rcContent; if (btn.Icon.exists()) rcText.Left += Metrics::WindowIcon.Width + Metrics::WindowEdge.Width; // Draw text if (state != PBS_DISABLED) theme.write(dc, BP_PUSHBUTTON, state, btn.Text(), rcText, DrawTextFlags::Centre|DrawTextFlags::VCentre|DrawTextFlags::SingleLine); else { const auto grayString = choose<ENC>(::GrayStringA,::GrayStringW); grayString(dc.handle(), StockBrush::AppWorkspace, nullptr, (LPARAM)btn.Text().c_str(), btn.Text().size(), rcText.Left, rcText.Top, rcText.width(), rcText.height()); } // [FOCUS] Draw focus rectangle if (btn.Focus) { RectL rcFocus = rcContent.inflate(-Metrics::WindowEdge); dc.focus(rcFocus); } }
static void Draw() { target.Clear(COLOR_WHITE); auto const size = target.GetSize(); Point2F center(size.Width / 2.0f, size.Height / 2.0f); auto radius = std::min(size.Width, size.Height) / 3.0f; target.DrawEllipse(Direct2D::Ellipse(center, radius, radius), brush, 10.0f); }
DepthStencilView::DepthStencilView(DeviceContext& context) { // get the currently bound depth stencil view from the context ID3D::DepthStencilView* rawPtr = nullptr; context.GetUnderlying()->OMGetRenderTargets(0, nullptr, &rawPtr); _underlying = moveptr(rawPtr); }
ObjectManager::SpriteBatch::SpriteBatch(DeviceContext & deviceContext, Texture & texture, std::shared_ptr<SpriteCoordinateReader>& coordinate, std::shared_ptr<SpriteSequenceReader>& sequence) : _deviceContext(deviceContext), _texture(texture), _coordinate(coordinate), _sequence(sequence) { const auto width = float(coordinate->Width) / 2.f; const auto height = float(coordinate->Height) / 2.f; const UINT remapable = 1; SpriteVertex vertices[] = { { { -width, height, 0.5f }, remapable }, { { width, height, 0.5f }, remapable }, { { -width, -height, 0.5f }, remapable }, { { width, -height, 0.5f }, remapable } }; auto d3dDevice = _deviceContext.D3DDevice; { D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; heapDesc.NumDescriptors = 1; heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; // 此标志指示此描述符堆可以绑定到管道,并且其中包含的描述符可以由根表引用。 heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; ThrowIfFailed(d3dDevice->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&_sequenceUavHeap))); } ComPtr<ID3D12GraphicsCommandList> commandList; _deviceContext.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, nullptr, IID_PPV_ARGS(&commandList)); _vertexBuffer = _deviceContext.CreateVertexBuffer(commandList.Get(), std::begin(vertices), std::end(vertices), _vertexBufferView); ThrowIfFailed(commandList->Close()); deviceContext.ExecuteCommandList(commandList.Get()); }
IndexBuffer::IndexBuffer(DeviceContext& context) { ID3D::Buffer* rawPtr = nullptr; DXGI_FORMAT fmt = DXGI_FORMAT_UNKNOWN; unsigned offset = 0; context.GetUnderlying()->IAGetIndexBuffer(&rawPtr, &fmt, &offset); _underlying = moveptr(rawPtr); }
///////////////////////////////////////////////////////////////////////////////////////// // ThemedSkin::measure const //! Measures a standard CheckBox control //! //! \param[in,out] &chk - CheckBox to be measured //! \param[in,out] &dc - Output device context //! \return SizeL - Required size ///////////////////////////////////////////////////////////////////////////////////////// SizeL measure(CheckBox<ENC>& chk, DeviceContext& dc) const override { Theme theme(chk.handle(), L"Button"); // Measure checkbox + text + edges return theme.measure(dc, BP_CHECKBOX, CBS_UNCHECKEDNORMAL) + dc.measure(chk.Text()) + SizeL(3*Metrics::WindowEdge.Width, 0); }
///////////////////////////////////////////////////////////////////////////////////////// // ThemedSkin::draw const //! Draws a standard checkbox control //! //! \param[in,out] &chk - CheckBox to be drawn //! \param[in,out] &dc - Output device context //! \param[in] const &rc - Drawing rectangle ///////////////////////////////////////////////////////////////////////////////////////// void draw(CheckBox<ENC>& chk, DeviceContext& dc, const RectL& rc) const override { Theme theme(chk.handle(), L"Button"); // Determine state CHECKBOXSTATES state = CBS_UNCHECKEDNORMAL; if (!chk.Enabled) state = CBS_UNCHECKEDDISABLED; else if (chk.Check == ButtonState::Checked) //else if (args.State && OwnerDrawState::Selected) state = CBS_UNCHECKEDPRESSED; else if (chk.isMouseOver()) state = CBS_UNCHECKEDHOT; //if (chk.Checked == ButtonState::Checked) //if (args.State && OwnerDrawState::Checked) // state += (CBS_CHECKEDNORMAL-1); //if (chk.State && ButtonState::Checked) // state += (CBS_CHECKEDNORMAL-1); //else if (chk.Checked == ButtonState::Indeterminate) // state += (CBS_MIXEDNORMAL-1); // Query content rect RectL rcContent = theme.content(dc, BP_CHECKBOX, state, rc); // Draw background dc.fill(rc, StockBrush::ButtonFace); // Calculate checkbox / text rectangles SizeL szCheckBox = theme.measure(dc, BP_CHECKBOX, state); RectL rcCheckBox = rcContent.arrange(szCheckBox, {RectL::FromLeft,Metrics::WindowEdge.Width}, RectL::Centre); // Draw checkbox theme.fill(dc, BP_CHECKBOX, state, rcCheckBox); // Draw text rcContent.Left = rcCheckBox.Right + Metrics::WindowEdge.Width; theme.write(dc, BP_CHECKBOX, state, chk.Text(), rcContent, DrawTextFlags::Left|DrawTextFlags::VCentre|DrawTextFlags::SingleLine); // [FOCUS] Draw focus rectangle if (chk.Focus) //if (args.State && OwnerDrawState::Focus) { RectL rcText = theme.measure(dc, BP_CHECKBOX, state, chk.Text(), rcContent, DrawTextFlags::Left|DrawTextFlags::VCentre|DrawTextFlags::SingleLine); dc.focus(rcText); } }
void ConstantBuffer::Update(DeviceContext& context, const void* data, size_t byteCount) { // context.GetUnderlying()->UpdateSubresource( // _underlying, 0, nullptr, data, byteCount, byteCount); D3D11_MAPPED_SUBRESOURCE result; ID3D::DeviceContext* devContext = context.GetUnderlying(); HRESULT hresult = devContext->Map(_underlying.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &result); if (SUCCEEDED(hresult) && result.pData) { XlCopyMemory(result.pData, data, byteCount); devContext->Unmap(_underlying.get(), 0); } }
/** * 画像のブロック転送 * @param dest 転送先のデバイスコンテキストオブジェクト * @param sourcePosition 転送元の矩形範囲 * @param destPosition 転送先の矩形範囲 */ bool blockTransfer(const DeviceContext& dest, const geometry::Rectangle<int>& sourcePosition, const geometry::Point<int>& destPosition) const throw() { return ::BitBlt(this->deviceContext, destPosition.getX(), destPosition.getY(), sourcePosition.getWidth(), sourcePosition.getHeight(), dest.getDeviceContext(), sourcePosition.getLeft(), sourcePosition.getTop(), SRCCOPY) == TRUE; }
static void ResizeSwapChainBitmap() { target.SetTarget(); if (S_OK == swapChain.ResizeBuffers()) { CreateDeviceSwapChainBitmap(swapChain, target); } else { ReleaseDevice(); } }
///////////////////////////////////////////////////////////////////////////////////////// // ThemedSkin::draw const //! Fallback override for drawing a window //! //! \param[in,out] &wnd - Window to be drawn //! \param[in,out] &dc - Output device context //! \param[in] const &rc - Drawing rectangle ///////////////////////////////////////////////////////////////////////////////////////// void draw(Window<ENC>& wnd, DeviceContext& dc, const RectL& rc) const override { Theme theme(wnd.handle(), L"Window"); // Draw window background dc.fill(rc, theme.brush(ThemeColour::Window)); // Query window menu if (!wnd.Menu.empty()) { ::MENUBARINFO bar { sizeof(::MENUBARINFO) }; Theme menu(wnd.handle(), L"Menu"); // Draw window menu bar // [BUG] Attempting to draw into the non-client area ::GetMenuBarInfo(wnd.handle(), OBJID_MENU , 0, &bar); menu.fill(dc, MENU_BARBACKGROUND, MB_INACTIVE, wnd.toClient(bar.rcBar)); } }
DeviceCompatibleBitmap::DeviceCompatibleBitmap ( const DeviceContext& context, const Size& size ) : Bitmap(claim(::create(context.handle(), size.data()))) { }
TYPED_TEST(GemmTest, TestGemmCPUGPU) { DeviceContext *dc = Caffe::GetDefaultDeviceContext(); Blob<TypeParam> A(1, 1, 2, 3, Caffe::GetDefaultDeviceContext()); Blob<TypeParam> B(1, 1, 3, 4, Caffe::GetDefaultDeviceContext()); Blob<TypeParam> C(1, 1, 2, 4, Caffe::GetDefaultDeviceContext()); TypeParam data[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; TypeParam A_reshape_data[6] = {1, 4, 2, 5, 3, 6}; TypeParam B_reshape_data[12] = {1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12}; TypeParam result[8] = {38, 44, 50, 56, 83, 98, 113, 128}; caffe_cpu_copy(6, data, A.mutable_cpu_data()); caffe_cpu_copy(12, data, B.mutable_cpu_data()); // [1, 2, 3; 4 5 6] * [1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12]; caffe_cpu_gemm<TypeParam>(CblasNoTrans, CblasNoTrans, 2, 4, 3, 1., A.cpu_data(), B.cpu_data(), 0., C.mutable_cpu_data()); for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } if (dc->backend() == BACKEND_CUDA) { #ifdef USE_CUDA caffe_gpu_gemm<TypeParam>(CblasNoTrans, CblasNoTrans, 2, 4, 3, 1., A.gpu_data(), B.gpu_data(), 0., C.mutable_gpu_data()); #endif // USE_CUDA } else { #ifdef USE_GREENTEA greentea_gpu_gemm<TypeParam>(dc->id(), CblasNoTrans, CblasNoTrans, 2, 4, 3, 1., (cl_mem)(A.gpu_data()), 0, (cl_mem)(B.gpu_data()), 0, 0., (cl_mem)(C.mutable_gpu_data()), 0); #endif // USE_GREENTEA } for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } // Test when we have a transposed A A.Reshape(1, 1, 3, 2); caffe_cpu_copy(6, A_reshape_data, A.mutable_cpu_data()); caffe_cpu_gemm<TypeParam>(CblasTrans, CblasNoTrans, 2, 4, 3, 1., A.cpu_data(), B.cpu_data(), 0., C.mutable_cpu_data()); for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } if (dc->backend() == BACKEND_CUDA) { #ifdef USE_CUDA caffe_gpu_gemm<TypeParam>(CblasTrans, CblasNoTrans, 2, 4, 3, 1., A.gpu_data(), B.gpu_data(), 0., C.mutable_gpu_data()); #endif // USE_CUDA } else { #ifdef USE_GREENTEA greentea_gpu_gemm<TypeParam>(dc->id(), CblasTrans, CblasNoTrans, 2, 4, 3, 1., (cl_mem)(A.gpu_data()), 0, (cl_mem)(B.gpu_data()), 0, 0., (cl_mem)(C.mutable_gpu_data()), 0); #endif // USE_GREENTEA } for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } // Test when we have a transposed A and a transposed B too B.Reshape(1, 1, 4, 3); caffe_cpu_copy(12, B_reshape_data, B.mutable_cpu_data()); caffe_cpu_gemm<TypeParam>(CblasTrans, CblasTrans, 2, 4, 3, 1., A.cpu_data(), B.cpu_data(), 0., C.mutable_cpu_data()); for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } if (dc->backend() == BACKEND_CUDA) { #ifdef USE_CUDA caffe_gpu_gemm<TypeParam>(CblasTrans, CblasTrans, 2, 4, 3, 1., A.gpu_data(), B.gpu_data(), 0., C.mutable_gpu_data()); #endif // USE_CUDA } else { #ifdef USE_GREENTEA greentea_gpu_gemm<TypeParam>(dc->id(), CblasTrans, CblasTrans, 2, 4, 3, 1., (cl_mem)(A.gpu_data()), 0, (cl_mem)(B.gpu_data()), 0, 0., (cl_mem)(C.mutable_gpu_data()), 0); #endif // USE_GREENTEA } for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } // Test when we have a transposed B A.Reshape(1, 1, 2, 3); caffe_cpu_copy(6, data, A.mutable_cpu_data()); caffe_cpu_gemm<TypeParam>(CblasNoTrans, CblasTrans, 2, 4, 3, 1., A.cpu_data(), B.cpu_data(), 0., C.mutable_cpu_data()); for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } if (dc->backend() == BACKEND_CUDA) { #ifdef USE_CUDA caffe_gpu_gemm<TypeParam>(CblasNoTrans, CblasTrans, 2, 4, 3, 1., A.gpu_data(), B.gpu_data(), 0., C.mutable_gpu_data()); #endif // USE_CUDA } else { #ifdef USE_GREENTEA greentea_gpu_gemm<TypeParam>(dc->id(), CblasNoTrans, CblasTrans, 2, 4, 3, 1., (cl_mem)(A.gpu_data()), 0, (cl_mem)(B.gpu_data()), 0, 0., (cl_mem)(C.mutable_gpu_data()), 0); #endif // USE_GREENTEA } for (int i = 0; i < 8; ++i) { EXPECT_EQ(C.cpu_data()[i], result[i]); } }
BOOL HandleWaveMessage(PMMDRV_MESSAGE_PARAMS pParams, DWORD *pdwResult) { // set the error code to be no error first SetLastError(MMSYSERR_NOERROR); UINT uMsg = pParams->uMsg; UINT uDeviceId = pParams->uDeviceId; DWORD dwParam1 = pParams->dwParam1; DWORD dwParam2 = pParams->dwParam2; DWORD dwUser = pParams->dwUser; StreamContext *pStreamContext = (StreamContext *)dwUser; DWORD dwRet; g_pHWContext->Lock(); _try { switch (uMsg) { case WODM_GETNUMDEVS: { dwRet = g_pHWContext->GetNumOutputDevices(); break; } case WIDM_GETNUMDEVS: { dwRet = g_pHWContext->GetNumInputDevices(); break; } case WODM_GETDEVCAPS: { DeviceContext *pDeviceContext; UINT NumDevs = g_pHWContext->GetNumOutputDevices(); if (pStreamContext) { pDeviceContext=pStreamContext->GetDeviceContext(); } else { pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId); } dwRet = pDeviceContext->GetDevCaps((PVOID)dwParam1,dwParam2); break; } case WIDM_GETDEVCAPS: { DeviceContext *pDeviceContext; UINT NumDevs = g_pHWContext->GetNumInputDevices(); if (pStreamContext) { pDeviceContext=pStreamContext->GetDeviceContext(); } else { pDeviceContext = g_pHWContext->GetInputDeviceContext(uDeviceId); } dwRet = pDeviceContext->GetDevCaps((PVOID)dwParam1,dwParam2); break; } case WODM_GETEXTDEVCAPS: { DeviceContext *pDeviceContext; UINT NumDevs = g_pHWContext->GetNumOutputDevices(); if (pStreamContext) { pDeviceContext=pStreamContext->GetDeviceContext(); } else { pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId); } dwRet = pDeviceContext->GetExtDevCaps((PVOID)dwParam1,dwParam2); break; } case WODM_OPEN: { DEBUGMSG(ZONE_WODM, (TEXT("WODM_OPEN\r\n"))); DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId); dwRet = pDeviceContext->OpenStream((LPWAVEOPENDESC)dwParam1, dwParam2, (StreamContext **)dwUser); break; } case WIDM_OPEN: { DEBUGMSG(ZONE_WIDM, (TEXT("WIDM_OPEN\r\n"))); DeviceContext *pDeviceContext = g_pHWContext->GetInputDeviceContext(uDeviceId); dwRet = pDeviceContext->OpenStream((LPWAVEOPENDESC)dwParam1, dwParam2, (StreamContext **)dwUser); break; } case WODM_CLOSE: case WIDM_CLOSE: { DEBUGMSG(ZONE_WIDM, (TEXT("WIDM_CLOSE/WODM_CLOSE\r\n"))); dwRet = pStreamContext->Close(); // Release stream context here, rather than inside StreamContext::Close, so that if someone // (like CMidiStream) has subclassed Close there's no chance that the object will get released // out from under them. if (dwRet==MMSYSERR_NOERROR) { pStreamContext->Release(); } break; } case WODM_RESTART: case WIDM_START: { dwRet = pStreamContext->Run(); break; } case WODM_PAUSE: case WIDM_STOP: { dwRet = pStreamContext->Stop(); break; } case WODM_GETPOS: case WIDM_GETPOS: { dwRet = pStreamContext->GetPos((PMMTIME)dwParam1); break; } case WODM_RESET: case WIDM_RESET: { dwRet = pStreamContext->Reset(); break; } case WODM_WRITE: case WIDM_ADDBUFFER: { DEBUGMSG(ZONE_WIDM, (TEXT("WODM_WRITE/WIDM_ADDBUFFER, Buffer=0x%x\r\n"),dwParam1)); dwRet = pStreamContext->QueueBuffer((LPWAVEHDR)dwParam1); break; } case WODM_GETVOLUME: { PULONG pdwGain = (PULONG)dwParam1; UINT NumDevs = g_pHWContext->GetNumOutputDevices(); if (pStreamContext) { *pdwGain = pStreamContext->GetGain(); } else { DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId); *pdwGain = pDeviceContext->GetGain(); } dwRet = MMSYSERR_NOERROR; break; } case WODM_SETVOLUME: { UINT NumDevs = g_pHWContext->GetNumOutputDevices(); LONG dwGain = dwParam1; if (pStreamContext) { dwRet = pStreamContext->SetGain(dwGain); } else { DeviceContext *pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId); dwRet = pDeviceContext->SetGain(dwGain); } break; } case WODM_BREAKLOOP: { dwRet = pStreamContext->BreakLoop(); break; } case WODM_SETPLAYBACKRATE: { WaveStreamContext *pWaveStream = (WaveStreamContext *)dwUser; dwRet = pWaveStream->SetRate(dwParam1); break; } case WODM_GETPLAYBACKRATE: { WaveStreamContext *pWaveStream = (WaveStreamContext *)dwUser; dwRet = pWaveStream->GetRate((DWORD *)dwParam1); break; } case MM_WOM_SETSECONDARYGAINCLASS: { if (pStreamContext) { dwRet = pStreamContext->SetSecondaryGainClass(dwParam1); } else { dwRet = MMSYSERR_INVALPARAM; } break; } case MM_WOM_SETSECONDARYGAINLIMIT: { DeviceContext *pDeviceContext; if (pStreamContext) { pDeviceContext = pStreamContext->GetDeviceContext(); } else { pDeviceContext = g_pHWContext->GetOutputDeviceContext(uDeviceId); } dwRet = pDeviceContext->SetSecondaryGainLimit(dwParam1,dwParam2); break; } case MM_MOM_MIDIMESSAGE: { CMidiStream *pMidiStream = (CMidiStream *)dwUser; dwRet = pMidiStream->MidiMessage(dwParam1); break; } // unsupported messages case WODM_GETPITCH: case WODM_SETPITCH: case WODM_PREPARE: case WODM_UNPREPARE: case WIDM_PREPARE: case WIDM_UNPREPARE: default: dwRet = MMSYSERR_NOTSUPPORTED; } } _except (EXCEPTION_EXECUTE_HANDLER) { dwRet = MMSYSERR_INVALPARAM; } g_pHWContext->Unlock(); // Pass the return code back via pBufOut if (pdwResult) { *pdwResult = dwRet; } return TRUE; }
static void ReleaseDevice() { target.Reset(); swapChain.Reset(); brush.Reset(); }
static void CreateDeviceResources() { brush = target.CreateSolidColorBrush(COLOR_BLUE); }